Exemplo n.º 1
0
/*==================================================================================
 psclos - closes a pdf document after writing
 ==================================================================================*/
void psclos_() {
	
	DEBUGPRINT(("In psclos.\n"));
/* DEBUGGING TESTS:
	
	cairo_identity_matrix(dmh_cr);	// remove transformations
	cairo_move_to(dmh_cr, 100, 200);
	cairo_rectangle(dmh_cr, 100, 200, 10, 10);
	cairo_set_source_rgb (dmh_cr, 0, 1, 1);
	cairo_fill(dmh_cr);

	cairo_rotate(dmh_cr, -90.0*M_PI/180);
	double x=100, y=200;
	cairo_device_to_user(dmh_cr, &x, &y);
	cairo_move_to(dmh_cr, x, y);
	
	cairo_text_extents_t te;
	cairo_set_font_size(dmh_cr, 44);
	cairo_text_extents(dmh_cr,"test",&te);
	cairo_rel_move_to(dmh_cr, -te.width * 0.5, 0);
	cairo_set_source_rgb (dmh_cr, 0, 1, 0);
	cairo_show_text (dmh_cr, "test");
	DEBUGPRINT(("Status:%s\n",cairo_status_to_string(cairo_status(dmh_cr))));
*/
	
	closeSurface();
	
	free(dmh_fontFace);
	free(dmh_fileNameRoot);
}
Exemplo n.º 2
0
/*==================================================================================
 pspltrgn - subroutine to set which small plot region to use
 	This routine is called by pschem in psvdraw_new in order to plot multiple
 	ternary chemographies on a single page.  Each page can hold MAXPLOTSPERPAGE.  If
 	another is requested, then a new document will be created with a name similar to 
 	that of the first, and the process will begin again.
 	
 	This overrides any settings made in psssc2, and assumes that x and y (real-unit) 
 	bounds are 0.0-1.0.  Note that if this routine is called, then plot_aspect_ratio will be ignored.  
 	
 	Note that plotnum is a zero-based index
 ==================================================================================*/
void pspltrgn_ (int *plotnum) {
	char *outFileName = malloc((strlen(dmh_fileNameRoot)+50) * sizeof(char));
			
	int plotPosition = *plotnum % MAXPLOTSPERPAGE;
	int pageNum = *plotnum / MAXPLOTSPERPAGE;
	int boxEdge, rowNum, colNum;
	
	DEBUGPRINT(("In pspltrgn. Plotnum = %i, plotPosition = %i, pageNum = %i\n", *plotnum, plotPosition, pageNum));
	
	if (plotPosition == 0 && pageNum > 0) {
		/* we need to start a new page, so let's close the current one, and start a new one
			with a related name */
		DEBUGPRINT(("In pspltrgn. Closing current page and starting a new one with\n page number=%i and file type=%i\n", pageNum, dmh_outputFileType));
		closeSurface();	// close existing surface
		switch(dmh_outputFileType) {
			case PDFTYPE:
				sprintf(outFileName, "%s_%i.%s", dmh_fileNameRoot, pageNum, "pdf");
				dmh_surf = cairo_pdf_surface_create (outFileName, dmh_pageWidth, dmh_pageHeight);
				break;
			case PSTYPE:
				sprintf(outFileName, "%s_%i.%s", dmh_fileNameRoot, pageNum, "ps");
				dmh_surf = cairo_ps_surface_create (outFileName, dmh_pageWidth, dmh_pageHeight);
				cairo_ps_surface_set_eps (dmh_surf, 1);
				break;
			case SVGTYPE:
				sprintf(outFileName, "%s_%i.%s", dmh_fileNameRoot, pageNum, "svg");
				dmh_surf = cairo_svg_surface_create (outFileName, dmh_pageWidth, dmh_pageHeight);
				break;
		}
		
		dmh_cr = cairo_create (dmh_surf);
		cairo_identity_matrix(dmh_cr);
		cairo_set_line_join(dmh_cr, CAIRO_LINE_JOIN_ROUND);
		
		dmh_min_tracked_x = DBL_MAX;
	}
	
	/* Set the location on the page for the small plot */
	dmh_aspectRatio = 1.0;	/* Ignores plot_aspect_ratio.  */
	boxEdge = (dmh_pageWidth - LEFTMARGIN - RIGHTMARGIN - MULTIPLOTGUTTER) / 2;
	rowNum = plotPosition / 2;
	colNum = plotPosition % 2;
	dmh_xoffset = LEFTMARGIN + ((boxEdge + MULTIPLOTGUTTER) * colNum);
	dmh_yoffset = (dmh_pageHeight * 0.5) + (boxEdge * 1.5) + MULTIPLOTGUTTER - (boxEdge * (rowNum+1)) - (MULTIPLOTGUTTER * rowNum); 
	dmh_xscale = boxEdge;
	dmh_yscale = boxEdge;
	DEBUGPRINT(("End pspltrgn.  boxEdge=%i; r,c=(%i,%i); scale=(%f, %f); offset=(%f, %f); DevPtRange=(%f,%f)-(%f,%f).\n", boxEdge, rowNum, colNum, dmh_xscale, dmh_yscale, dmh_xoffset, dmh_yoffset,deviceX(0), deviceY(0), deviceX(1), deviceY(1)));
}
Exemplo n.º 3
0
/*!
 * \brief Legge l'immagine
 */
void SurfaceWidget::loadSurface()
{
  ReadImageDialog dialog(this, "Load " + m_Name);
  if ( dialog.exec() )
  {
    // Se c'è una superficie già aperta la chiude
    if (m_Loaded)
      closeSurface();


    std::cout << "filename: " << dialog.getFilename().c_str() << std::endl;
    // Legge l'immagine
    vtkGenericMedicalImageReader* reader = vtkGenericMedicalImageReader::New();
    if (dialog.useDirectory())
      reader->SetDirectoryName(dialog.getDirectory().c_str());
    else
      reader->SetFileName (dialog.getFilename().c_str());
    reader->SetImageType(dialog.getImageType());
    reader->Update();

    // Crea l'actor
    m_Surface3DActor = Surface3DActor::New();
    m_Surface3DActor->SetInput ( reader->GetOutput() );

    // Setta il range
    double range[2];
    reader->GetOutput()->GetScalarRange(range);
    setValueWidgets(range[0]+1, range[1], range[0]+1, 1);


    // Connette i widgets, eccetera
    setDisabled(false);
    connectWidgets();

    m_Loaded = true;
    reader->Delete();

    applySurfaceValue();

    for(RendererListType::iterator iter = m_RendererList.begin(); iter != m_RendererList.end(); iter++)
    {
      (*iter)->AddActor(m_Surface3DActor);
      (*iter)->ResetCamera();
    }

    render();
  }
}
Exemplo n.º 4
0
/*!
 * \brief Distruttore
 */
SurfaceWidget::~SurfaceWidget()
{
  if (m_Loaded)
    closeSurface();
}
Exemplo n.º 5
0
/*!
 * \brief Disconnette i pulsanti del menu
 */
void SurfaceWidget::disconnectMenu()
{
  disconnect ( m_Action_Load,  SIGNAL ( triggered() ), this, SLOT ( loadSurface() ) );
  disconnect ( m_Action_Close, SIGNAL ( triggered() ), this, SLOT ( closeSurface() ) );
}