Changeset - 5ec450ff7c49
[Not reviewed]
default
0 5 0
Michael Guravage - 15 years ago 2010-10-19 12:56:46
michael.guravage@cwi.nl
Render PNGs instead of JPGs. See ChangeLogs for details.

--
user: Michael Guravage <michael.guravage@cwi.nl>
branch 'default'
changed src/ChangeLog
changed src/TutorialCode/Tutorial3/ChangeLog
changed src/TutorialCode/Tutorial3/tutorial3_init.xml
changed src/VirtualLeaf.cpp
changed src/mainbase.cpp
5 files changed with 25 insertions and 29 deletions:
0 comments (0 inline, 0 general)
src/ChangeLog
Show inline comments
 
2010-10-19    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* mainbase.cpp (Save): Use format specified in function prototype.
 

	
 
	* VirtualLeaf.cpp (Plot): Render PNG instead of JPEG. Write image
 
	and XML files dependent only on getTime().
 

	
 
2010-10-18    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* mainbase.cpp (Save): QDir::toNativeSeparators(fname). Invoke
 
	save with format argument set to zero to force QImage to guess the
 
	format by looking at fileName's suffix.
 

	
 
	* VirtualLeaf-install.nsi: Put uninstaller in top directory.
 

	
 
	* modelcatalogue.cpp (InstallModel): For all OS-es. Move from "bin" directory to root application folder.
 

	
 
	* VirtualLeaf.pro: MAXOSX, look for gpl3.txt in the ../doc directory.
 

	
 
	* Makefile (Makefile.libplugin): Removed -makefile qmake option.
 

	
 
	* VirtualLeaf.cpp (TIMESTEP): Removed getIterations().
 

	
 
	* mesh.h (Mesh): Removed {increment,get}Iterations().
 

	
 
	* canvas.cpp (TimeStepWrap): Replaced getIterations() with getTime().
 

	
 
2010-10-15    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* mesh.h (Mesh): Added iterations. incrementIterations() and
 
	getIterations().
 

	
 
	* VirtualLeaf.cpp (Plot): Replaced local frame counter with
 
	mesh.incrementIterations().
 

	
 
	* canvas.cpp (TimeStepWrap): Replaced local counter with
 
	mesh.incrementIterations().
 

	
 
2010-10-14    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* VirtualLeaf.pro: Turned debug off to make all profiles must be
 
	consistant.
 

	
 
	* VirtualLeaf-install.nsi: Tweaked paths to coincide with UNIX
 
	distribution, i.e. VirtualLeaf.exe, its libraries, models, and the
 
	uninstaller all go in the bin directory. And leaves directory
 
	placed under data directory.
 

	
 
	* canvas.cpp (exportCellData): Added a check to inquire before
 
	overwritting an existing file.
 

	
 

	
 
2010-10-14    <merks@cwi.nl>
 

	
 
	* mesh.cpp: In response to referees' comments, added new parameter
src/TutorialCode/Tutorial3/ChangeLog
Show inline comments
 
2010-10-19    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* tutorial3_init.xml (public): Render PNG instead of JPEG.
 

	
 
2010-10-18    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* Makefile (Makefile.tutorial3): Removed -makefile qmake option.
 

	
 
2010-10-14    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* tutorial3.h (SimPluginInterface): Added default LeafML file.
 

	
 
2010-06-25    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* tutorial3.pro: Added -Wno-write-strings and -Wno-unused-parameter to QMAKE_CXXFLAGS.
 

	
 
2010-06-23    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* tutorial3.pro: Corrected windows library path.
 

	
src/TutorialCode/Tutorial3/tutorial3_init.xml
Show inline comments
 
@@ -294,107 +294,107 @@ void MainBase::Plot(int resize_stride) {
 
      FitLeafToCanvas();
 
    }
 
  }
 
  mesh.LoopCells(DrawCell(),canvas,*this);
 
	
 
  if (ShowNodeNumbersP()) 
 
    mesh.LoopNodes( bind2nd (mem_fun_ref ( &amp;Node::DrawIndex), &amp;canvas ) ) ;
 
  if (ShowCellNumbersP()) 
 
    mesh.LoopCells( bind2nd (mem_fun_ref ( &amp;Cell::DrawIndex), &amp;canvas ) ) ;
 
	
 
  if (ShowCellAxesP()) 
 
    mesh.LoopCells( bind2nd (mem_fun_ref ( &amp;Cell::DrawAxis), &amp;canvas ) );
 
	
 
  if (ShowCellStrainP()) 
 
    mesh.LoopCells( bind2nd (mem_fun_ref ( &amp;Cell::DrawStrain), &amp;canvas ) );
 
	
 
  if (ShowWallsP())
 
  
 
    mesh.LoopWalls( bind2nd( mem_fun_ref( &amp;Wall::Draw ), &amp;canvas ) );
 
	
 
	if (ShowApoplastsP()) 
 
		mesh.LoopWalls( bind2nd( mem_fun_ref( &amp;Wall::DrawApoplast ), &amp;canvas ) );
 
 
 
	if (ShowMeshP()) 
 
    mesh.DrawNodes(&amp;canvas);
 
	
 
  if (ShowBoundaryOnlyP()) 
 
    mesh.DrawBoundary(&amp;canvas);
 

	
 
  
 
	if ( ( batch || MovieFramesP() )) {
 
		
 
		static int frame = 0;
 
		// frame numbers are sequential for the most frequently written file type.
 
		// for the less frequently written file type they match the other type
 
		if (!(count%par.storage_stride) )  {
 
		
 
			stringstream fname;
 
			fname &lt;&lt; par.datadir &lt;&lt; "/leaf.";
 
			fname.fill('0');
 
			fname.width(6);
 
	
 
			/* 
 
			 fname &lt;&lt; frame &lt;&lt; ".pdf";
 
			if (par.storage_stride &lt;= par.xml_storage_stride) {
 
				frame++;
 
			}
 
			
 
			// Write high-res JPG snapshot every plot step
 
			// Write high-res PDF snapshot every plot step
 
			Save(fname.str().c_str(), "PDF");
 
			*/
 
			
 
			fname &lt;&lt; frame &lt;&lt; ".jpg";
 
			fname &lt;&lt; frame &lt;&lt; ".png";
 
			if (par.storage_stride &lt;= par.xml_storage_stride) {
 
				frame++;
 
			}
 
			
 
			// Write high-res JPG snapshot every plot step
 
			Save(fname.str().c_str(), "JPEG",1024,768);
 
			// Write high-res PNG snapshot every plot step
 
			Save(fname.str().c_str(), "PNG",1024,768);
 
			
 
		}
 
	
 
		if (!(count%par.xml_storage_stride)) {
 
			stringstream fname;
 
			fname &lt;&lt; par.datadir &lt;&lt; "/leaf.";
 
			fname.fill('0');
 
			fname.width(6);
 
			fname &lt;&lt; frame &lt;&lt; ".xml";
 
	
 
			if (par.xml_storage_stride &lt; par.storage_stride) {
 
				frame++;
 
			}
 
			// Write XML file every ten plot steps
 
			mesh.XMLSave(fname.str().c_str(), XMLSettingsTree());
 
		}
 
		
 
	}
 
}
 

	
 

	
 
void Cell::Flux(double *flux, double *D)  {
 
	
 

	
 
  // loop over cell edges
 
	
 
  for (int c=0;c&lt;Cell::nchem;c++) flux[c]=0.;
 
	
 
  for (list&lt;Wall *&gt;::iterator i=walls.begin();
 
       i!=walls.end();
 
       i++) {
 
		
 
		
 
    // leaf cannot take up chemicals from environment ("no flux boundary")
 
    if ((*i)-&gt;c2-&gt;BoundaryPolP()) continue;
 
		
 
  	
 
    // flux depends on edge length and concentration difference
 
    for (int c=0;c&lt;Cell::nchem;c++) {
 
      double phi = (*i)-&gt;length * ( D[c] ) * ( (*i)-&gt;c2-&gt;chem[c] - chem[c] );
 
			
 
      if ((*i)-&gt;c1!=this) {
 
	cerr &lt;&lt; "Warning, bad cells boundary: " &lt;&lt; (*i)-&gt;c1-&gt;index &lt;&lt; ", " &lt;&lt; index &lt;&lt; endl;
 
      }
 
			
 
      flux[c] += phi;
 
    }    
 
  }
src/VirtualLeaf.cpp
Show inline comments
 
@@ -101,168 +101,153 @@ public:
 
      cerr << (*i)->Index() << " ";
 
    }
 
    cerr << endl;
 
  }
 
};
 

	
 
double PINSum(Cell &c) {
 
  return c.Chemical(1) + c.SumTransporters(1);// + c.ReduceCellAndWalls<double>( complex_PijAj );
 
}
 

	
 

	
 
class DrawCell {
 
public:
 
  void operator() (Cell &c,QGraphicsScene &canvas, MainBase &m) const {
 
    if (m.ShowBorderCellsP() || c.Boundary()==Cell::None) {
 
      if (!m.ShowBoundaryOnlyP() && !m.HideCellsP()) {
 
	if (m.ShowToolTipsP()) {
 
	  //QString info_string=QString("Cell %1, chemicals: ( %2, %3, %4, %5, %6)\n %7 of PIN1 at walls.\n Area is %8\n PIN sum is %9\n Circumference is %10\n Boundary type is %11").arg(c.Index()).arg(c.Chemical(0)).arg(c.Chemical(1)).arg(c.Chemical(2)).arg(c.Chemical(3)).arg(c.Chemical(4)).arg(c.SumTransporters(1)).arg(c.Area()).arg(PINSum(c)).arg(c.Circumference()).arg(c.BoundaryStr());
 
		QString info_string=QString("Cell %1, chemicals(%2): ").arg(c.Index()).arg(Cell::NChem());
 
		for (int i=0;i<Cell::NChem();i++) {
 
			info_string += QString("%1 ").arg(c.Chemical(i));
 
		}
 
		info_string += QString("\nArea is %1\n Circumference is %2\n Boundary type is %3").arg(c.Area()).arg(c.WallCircumference()).arg(c.BoundaryStr());
 
		
 
	  info_string += "\nNodes: " + c.printednodelist();
 
	  c.Draw(&canvas, info_string);
 
	} else {
 
	  c.Draw(&canvas);
 
	}
 
      }
 
      if (m.ShowCentersP()){
 
	c.DrawCenter(&canvas);
 
      }
 
      if (m.ShowFluxesP()){
 
	c.DrawFluxes(&canvas, par.arrowsize);
 
      }
 
    }
 
  }
 
};
 

	
 
Mesh mesh;
 
bool batch=false;
 

	
 
void MainBase::Plot(int resize_stride)
 
{
 

	
 
  clear();
 

	
 
  static int count=0;
 
  int count=(int)mesh.getTime();
 

	
 
  if (resize_stride) {
 
    if ( !((count)%resize_stride) ) {
 
      FitLeafToCanvas();
 
    }
 
  }
 

	
 
  mesh.LoopCells(DrawCell(),canvas,*this);
 

	
 
  if (ShowNodeNumbersP()) 
 
    mesh.LoopNodes( bind2nd (mem_fun_ref ( &Node::DrawIndex), &canvas ) ) ;
 
  if (ShowCellNumbersP()) 
 
    mesh.LoopCells( bind2nd (mem_fun_ref ( &Cell::DrawIndex), &canvas ) ) ;
 

	
 
  if (ShowCellAxesP()) 
 
    mesh.LoopCells( bind2nd (mem_fun_ref ( &Cell::DrawAxis), &canvas ) );
 

	
 
  if (ShowCellStrainP()) 
 
    mesh.LoopCells( bind2nd (mem_fun_ref ( &Cell::DrawStrain), &canvas ) );
 

	
 
  if (ShowWallsP())
 
    mesh.LoopWalls( bind2nd( mem_fun_ref( &Wall::Draw ), &canvas ) );
 

	
 
/*  if (ShowApoplastsP()) 
 
    mesh.LoopWalls( bind2nd( mem_fun_ref( &Wall::DrawApoplast ), &canvas ) );
 
*/
 
  if (ShowMeshP()) 
 
    mesh.DrawNodes(&canvas);
 

	
 
  if (ShowBoundaryOnlyP()) 
 
    mesh.DrawBoundary(&canvas);
 

	
 
  if ( ( batch || MovieFramesP() )) {
 

	
 
     static int frame = 0;
 
    // frame numbers are sequential for the most frequently written file type.
 
    // for the less frequently written file type they match the other type
 
    if (!(count%par.storage_stride) )  {
 

	
 
    if (!(count%par.storage_stride) ) {
 
      stringstream fname;
 
      fname << par.datadir << "/leaf.";
 
      fname.fill('0');
 
      fname.width(6);
 

	
 
      fname << frame << ".jpg";
 
      if (par.storage_stride <= par.xml_storage_stride) {
 
	frame = (int)mesh.getTime();
 
      }
 

	
 
      // Write high-res JPG snapshot every plot step
 
      Save(fname.str().c_str(), "JPEG",1024,768);
 
      fname << count << ".png";
 
      // Write high-res PNG snapshot every plot step
 
      Save(fname.str().c_str(), "PNG", 1024, 768);
 
    }
 

	
 
    if (!(count%par.xml_storage_stride)) {
 
      stringstream fname;
 
      fname << par.datadir << "/leaf.";
 
      fname.fill('0');
 
      fname.width(6);
 
      fname << frame << ".xml";
 

	
 
      if (par.xml_storage_stride < par.storage_stride) {
 
	frame = (int)mesh.getTime();
 
      }
 
      fname << count << ".xml";
 
      // Write XML file every ten plot steps
 
      mesh.XMLSave(fname.str().c_str(), XMLSettingsTree());
 
    }
 
  }
 
 count++;
 
}
 

	
 

	
 

	
 
INIT {
 

	
 
  //mesh.SetSimPlugin(plugin);
 
  if (leaffile) { 
 
    xmlNode *settings;
 
    mesh.XMLRead(leaffile, &settings);
 

	
 
    main_window->XMLReadSettings(settings);
 
    xmlFree(settings);
 
    main_window->UserMessage(QString("Ready. Time is %1").arg(mesh.getTimeHours().c_str()));
 

	
 
  } else {
 
    mesh.StandardInit();
 
  }
 
  
 
  Cell::SetMagnification(1);
 
  Cell::setOffset(0,0);
 
  
 
  FitLeafToCanvas();
 
  Plot();
 

	
 
}
 

	
 
TIMESTEP {
 

	
 
  static int i=0;
 
  static int t=0;
 
  static int ncells;
 

	
 
  if (!batch) {
 
    UserMessage(QString("Time: %1").arg(mesh.getTimeHours().c_str()),0);
 
  }
 

	
 
  ncells=mesh.NCells();
 

	
 

	
 
  double dh;
 

	
 
  if(DynamicCellsP()) {
 
    dh = mesh.DisplaceNodes();
 

	
 
    // Only allow for node insertion, cell division and cell growth
 
    // if the system has equillibrized
 
    // i.e. cell wall tension equillibrization is much faster
 
    // than biological processes, including division, cell wall yielding
 
    // and cell expansion
 
    mesh.InsertNodes(); // (this amounts to cell wall yielding)
 

	
src/mainbase.cpp
Show inline comments
 
@@ -299,70 +299,70 @@ void MainBase::XMLReadSettings(xmlNode *
 
      }*/
 
      if (!xmlStrcmp(name, (const xmlChar *)"save_movie_frames")) {
 
	movieframesp = strtobool( (const char *)val );
 
      }
 
      if (!xmlStrcmp(name, (const xmlChar *)"show_only_leaf_boundary")) {
 
	showboundaryonlyp = strtobool( (const char *)val );
 
      }
 
      if (!xmlStrcmp(name, (const xmlChar *)"cell_growth")) {
 
	dynamicscellsp = strtobool( (const char *)val );
 
      }
 
      if (!xmlStrcmp(name,(const xmlChar *)"hide_cells")) {
 
	hidecellsp = strtobool( (const char *)val ); 
 
      }
 
    
 
	
 
  
 
      xmlFree(name);
 
      xmlFree(val);
 
    }
 
    cur=cur->next;
 
  }
 
}
 

	
 
void MainBase::Save(const char *fname, const char *format, int sizex, int sizey)
 
{
 

	
 
  Vector ll,ur;
 
  mesh.BoundingBox(ll, ur);
 

	
 
  if (QString(fname).isEmpty()) {
 
    MyWarning::warning("No output filename given. Saving nothing.\n");
 
    return;
 
  }
 

	
 
  ll*=Cell::Magnification(); ur*=Cell::Magnification();
 

	
 
  // give the leaf some space
 
  Vector border = ((ur-ll)/5.);
 

	
 
  if (!QString(format).contains("pdf", Qt::CaseInsensitive)) {
 

	
 
    QImage *image = new QImage(QSize(sizex, sizey), QImage::Format_RGB32);
 
    image->fill(QColor(Qt::white).rgb());
 
    QPainter *painter=new QPainter(image);
 
    canvas.render(painter);
 
#ifdef QDEBUG
 
    qDebug() << "Native Image Filename: " << QDir::toNativeSeparators(QString(fname)) << endl;
 
#endif
 
    if (!image->save(QDir::toNativeSeparators(QString(fname)), 0, -1)) {
 
    if (!image->save(QDir::toNativeSeparators(QString(fname)), format)) {
 
      MyWarning::warning("Image not saved successfully. Is the disk full or the extension not recognized?");
 
    };
 
    }
 
    delete painter;
 
    delete image;
 
  } else {
 
    QPrinter pdf(QPrinter::HighResolution);
 
    pdf.setOutputFileName(fname);
 
    pdf.setOutputFormat(QPrinter::PdfFormat);
 
    QPainter painter(&pdf);
 
    canvas.render(&painter, QRectF(), QRectF(-5000,-5000, 10000, 10000));
 

	
 
    
 
    cerr << "Rendering to printer\n";
 
  }
 
}
 

	
 
void MainBase::CutSAM()
 
{
 
  mesh.CutAwaySAM();
 
}
 

	
 
/* finis */
0 comments (0 inline, 0 general)