_performingOperation = new PerformingOperation();
if(images.size() > 0)
{
- this->setVectImages(images);
+ this->configure(images);
}
_contourextractdata = NULL;
}
-void wxContourMainFrame::setVectImages(std::vector<vtkImageData*> imgs)
+
+void wxContourMainFrame::changeImage(int id, vtkImageData *img)
+{
+ if ( id<_images.size() ) _images[id]=img;
+ kernelManager->changeImage(id,img);
+ _theViewPanel->changeImage(img);
+// updateInstantImageData();
+
+}
+
+void wxContourMainFrame::configure(std::vector<vtkImageData*> imgs)
{
_images = imgs;
#if defined(_WIN32)
}
- wxContourMainFrame* wxContourMainFrame :: getInstance(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style,std::string datadir )
+ wxContourMainFrame* wxContourMainFrame::getInstance(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style,std::string datadir )
{
if(instance == NULL)
{
//
wxAuiNotebook * wxContourMainFrame::createNotebook()
{
- wxSize client_size = GetClientSize();
+ wxSize client_size = GetClientSize();
wxAuiNotebook* noteBook = new wxAuiNotebook(this, -1, wxPoint(client_size.x, client_size.y), wxSize(430,200), m_notebook_style);
- wxBitmap page_bmp = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16));
+ wxBitmap page_bmp = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16));
return noteBook;
}
{
std::vector<int> inst;
_instantPanel->getInstant(inst);
-
vtkImageData* img = kernelManager->getImageAtInstant(inst);
if(img!=NULL)
{
onLoadContours(filename,false);
}
-void wxContourMainFrame::onLoad()
+void wxContourMainFrame::onLoad(bool interactiveInterface) // interactiveInterface default true
{
std::string fileNameContourROI = GetFileLocation();
//CMRU 03-09-09-----------------------------------------------------------------------------------------------
fileNameContourROI = (const char *)(dialog.GetPath().mb_str());
} // if dialog
} // if FileLocation
- onLoadContours(fileNameContourROI,true);
+ onLoadContours(fileNameContourROI, interactiveInterface );
}
void wxContourMainFrame::SetZForAllContours(int pz)
sizeLstNameThings = lstNameThings.size();
for (i=0 ; i<sizeLstNameThings ; i++)
{
-printf("EED wxContourMainFrame::SetZForAllContours contour=%d \n", i );
manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(lstNameThings[i]);
sizeLstPoints = manualModel->GetSizeLstPoints();
for (ii=0 ; ii<sizeLstPoints ; ii++)
fprintf(pFileData,"--CreaContour--\n");
fprintf(pFileData,"Version %s\n", "1.0.3" );
fprintf(pFileData,"OnePixelSize %f\n", _onePixelSize);
-
//------------------------------------------------------------------------------------------------------------
-
vtkImageData *image = _images[0];
-
int dimRange[3];
image->GetDimensions(dimRange);
-
fprintf(pFile,"ImageDimensions %d %d %d\n", dimRange[0], dimRange[1], dimRange[2] );
-
double spaRange[3];
image->GetSpacing(spaRange);
-
fprintf(pFile,"ImageSpacing %f %f %f\n", spaRange[0], spaRange[1], spaRange[2] );
-
// Normal Contours
-
lstNameThings = kernelManager->GetLstNameThings();
sizeLstNameThings = lstNameThings.size();
fprintf(pFile,"NumberOfContours %d\n", sizeLstNameThings );
-
//CMRU 03-09-09-----------------------------------------------------------------------------------------------
fprintf(pFileData,"NumberOfContours %d\n", sizeLstNameThings );
//------------------------------------------------------------------------------------------------------------
-
-
// EED 2017-05-30
double spc[3];
spc[0]=1;
spc[1]=1;
- spc[2]=1;
-
+ spc[2]=1;
for (i=0 ; i<sizeLstNameThings ; i++)
{
//CMRU 03-09-09-----------------------------------------------------------------------------------------------
manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(lstNameThings[i]);
-
// EED 2017-05-30
// double sizeInPixel = manualModel ->GetPathSize( );
double sizeInPixel = manualModel ->GetPathSize( spc );
-
double realContourSize = sizeInPixel*_onePixelSize;
manualModel ->SetRealSize(realContourSize);
//------------------------------------------------------------------------------------------------------------
-
//int size= kernelManager->GetLstNameThings().size();
-
kernelManager->SaveThingName( pFile, pFileData, lstNameThings[i] );
_theViewPanel->getSceneManager()->SaveThingName( pFile, lstNameThings[i] );
}// for i
-
//-- Static Contours
-
// fprintf(pFile,"ImageDimensions %d %d %d\n", dimRange[0], dimRange[1], dimRange[2] );
// fprintf(pFile,"ImageSpacing %f %f %f\n", spaRange[0], spaRange[1], spaRange[2] );
-
lstNameThings = kernelManager->GetLstNameThingsStatic();
sizeLstNameThings = lstNameThings.size();
fprintf(pFile,"NumberOfContoursStatic %d\n", sizeLstNameThings );
-
//CMRU 03-09-09-----------------------------------------------------------------------------------------------
fprintf(pFileData,"NumberOfContoursStatic %d\n", sizeLstNameThings );
//------------------------------------------------------------------------------------------------------------
-
for (i=0 ; i<sizeLstNameThings ; i++)
{
kernelManager->SaveThingName( pFile, pFileData, lstNameThings[i] );
// wxBoxSizer *dialSizer = new wxBoxSizer(wxVERTICAL);
wxFlexGridSizer *dialSizer = new wxFlexGridSizer(1);
- wxString lstOptOperation[2];
- lstOptOperation[0]=_T("By Dimension");
- lstOptOperation[1]=_T("By Spacing");
- wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of Transformation"), wxDefaultPosition, wxSize(270,90), 2 , lstOptOperation, 2, wxRA_SPECIFY_COLS);
+ wxString lstOptOperation[3];
+ lstOptOperation[0]=_T("By Dimension (XY)");
+ lstOptOperation[1]=_T("By Spacing (XY)");
+ lstOptOperation[2]=_T("By Spacing (XYZ)");
+ wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of Transformation"), wxDefaultPosition, wxSize(370,200), 3 , lstOptOperation, 3, wxRA_SPECIFY_ROWS);
dialSizer->Add( new wxStaticText(dial,-1,_T("The image resolution is not compatible with the ")) , 0, wxGROW );
dialSizer->Add( new wxStaticText(dial,-1,_T("selected Roi file. Do you want to tranform it?")) , 0, wxGROW );
dial->Layout();
dial->ShowModal();
- int _tmpReadFileTypeOfTransformation = -1;
+ _tmpReadFileTypeOfTransformation = -1;
//EED bool transform = false;
if (dial->GetReturnCode() == wxID_OK)
//AD:04-06-09
void wxContourMainFrame::openContours( FILE *pFile, FILE *pFileData, bool staticContour )
{
-
char tmp[255];
vtkImageData *image = _images[0];
//nothing to do..
} else if (_tmpReadFileTypeOfTransformation==0){
double transX, transY;
- transX = (double) imageDim[0]/_tmpReadFileImageDim[0];
- transY = (double) imageDim[1]/_tmpReadFileImageDim[1];
- manModelContour->Transform_Ax_Plus_B(transX,0,transY,0);
+ transX = (double) imageDim[0]/_tmpReadFileImageDim[0]; // X
+ transY = (double) imageDim[1]/_tmpReadFileImageDim[1]; // Y
+ manModelContour->Transform_Ax_Plus_B(transX,0,transY,0);
} else if (_tmpReadFileTypeOfTransformation==1) {
double transX, transY;
- transX = (double) _tmpReadFileImageSpac[0]/imageDim[0];
- transY = (double) _tmpReadFileImageSpac[1]/imageDim[1];
+ transX = (double) _tmpReadFileImageSpac[0]/imageSpac[0]; // X
+ transY = (double) _tmpReadFileImageSpac[1]/imageSpac[1]; // Y
+ manModelContour->Transform_Ax_Plus_B(transX,0,transY,0);
+ } else if (_tmpReadFileTypeOfTransformation==2) { // with Z include
+ double transX, transY;
+ transX = (double) _tmpReadFileImageSpac[0]/imageSpac[0]; // X
+ transY = (double) _tmpReadFileImageSpac[1]/imageSpac[1]; // Y
+ instantVector[1]=instantVector[1]*_tmpReadFileImageSpac[2]/imageSpac[2]; // Z
manModelContour->Transform_Ax_Plus_B(transX,0,transY,0);
+ }else {
+ printf ("EED Warnning! wxContourMainFrame::openContours _tmpReadFileTypeOfTransformation not set. \n");
}
fscanf(pFile,"%s",tmp); // TypeView
int x = _theViewPanel->GetX();
int y = _theViewPanel->GetY();
int z = _theViewPanel->GetZ();
- SegmentationOneSlice( x,y,z,isovalue, sampling, method );
+ SegmentationOneSlice( x,y,z,isovalue, sampling, method , getImageData() );
RefreshInterface();
}
-void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method )
+void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method , vtkImageData *imagedata)
{
-
-printf("EED wxContourMainFrame::SegmentationOneSlice Start=%d %d\n",sampling,method );
-printf("EED wxContourMainFrame::SegmentationOneSlice %d %d %d \n",x,y,z );
-
int typeofcontour = 1;
//--Extracting Contour
- vtkImageData *imagedata = getImageData();
+// 2024-01-09
+// vtkImageData *imagedata = getImageData();
vtkImageReslice *imageReslice = vtkImageReslice::New();
//EED
std::vector<double> vecCtrlPointY;
std::vector<double> vecCtrlPointZ;
-printf("EED wxContourMainFrame::SegmentationOneSlice GetNumberOfLines=%d \n",polyDataResult->GetNumberOfLines() );
-
-int numberOfPointsInCell;
-int numberOfcells=polyDataResult->GetNumberOfCells();
-for (int jj=0; jj<numberOfcells ; jj++)
-{
- vtkCell* vtkcell = polyDataResult->GetCell( jj );
- numberOfPointsInCell=vtkcell->GetNumberOfPoints();
- printf("EED wxContourMainFrame::SegmentationOneSlice cell=%d points=%d \n",jj,numberOfPointsInCell );
-}// for jj
-
-printf("EED wxContourMainFrame::SegmentationOneSlice PrintSelf \n");
-
-polyDataResult->PrintSelf( std::cout, vtkIndent(0) );
+//printf("EED wxContourMainFrame::SegmentationOneSlice GetNumberOfLines=%d \n",polyDataResult->GetNumberOfLines() );
+//int numberOfPointsInCell;
+//int numberOfcells=polyDataResult->GetNumberOfCells();
+//for (int jj=0; jj<numberOfcells ; jj++)
+//{
+// vtkCell* vtkcell = polyDataResult->GetCell( jj );
+// numberOfPointsInCell=vtkcell->GetNumberOfPoints();
+// printf("EED wxContourMainFrame::SegmentationOneSlice cell=%d points=%d \n",jj,numberOfPointsInCell );
+//}// for jj
+// printf("EED wxContourMainFrame::SegmentationOneSlice PrintSelf \n");
+// polyDataResult->PrintSelf( std::cout, vtkIndent(0) );
if (polyDataResult->GetNumberOfCells()>0)
{
double *p;
- printf("EED wxContourMainFrame::SegmentationOneSlice A \n");
vtkCell* vtkcell = polyDataResult->GetCell( 0 );
- printf("EED wxContourMainFrame::SegmentationOneSlice B \n");
// int ii,size=polyDataResult->GetNumberOfPoints();
int ii,size=vtkcell->GetNumberOfPoints();
- printf("EED wxContourMainFrame::SegmentationOneSlice C \n");
int id;
for (ii=0;ii<size;ii++)
{
// id = polyDataResult->GetLines()->GetData()->GetValue(ii);
// p = polyDataResult->GetPoint(id);
p = vtkcell->GetPoints()->GetPoint(ii);
-
- printf("EED wxContourMainFrame::SegmentationOneSlice (%d) id=%d px=%f py=%f\n",ii,id, p[0],p[1]);
+// printf("EED wxContourMainFrame::SegmentationOneSlice (%d) id=%d px=%f py=%f\n",ii,id, p[0],p[1]);
// double x=p[0];
// double y=p[1];
vecX.push_back( p[0] );
vecZ.push_back( -900 );
// vecZ.push_back( p[2] );
}
-
ExtractControlPoints2D *extractcontrolpoints2d = new ExtractControlPoints2D();
extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ );
-
//PROOFS
/*if (methodRadiobox->GetSelection()==0){
extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
} // if addedModel
} // if sizeCtrPt
} // if NumberOfCells > 0
-
-printf("EED wxContourMainFrame::SegmentationOneSlice End\n");
+//printf("EED wxContourMainFrame::SegmentationOneSlice End\n");
}
int wxContourMainFrame::GetImageDataSizeZ()
_theViewPanel->GetImageDataRange(range);
}
-void wxContourMainFrame::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method)
+void wxContourMainFrame::onSegmentationAllSlices2(int step ,int isovalue,int sampling,int method,vtkImageData* imagedata)
+{
+ printf("wxContourMainFrame::onSegmentationAllSlices2 start\n");
+
+ //JCP 20-10-08 Undo redo implementation
+ saveState();
+ //JCP 20-10-08 Undo redo implementation
+ wxBusyCursor wait;
+// int x = _theViewPanel->GetX();
+// int y = _theViewPanel->GetY();
+ int z;
+// double porcent;
+// wxString tmpString;
+// double totalZ = maxZ-minZ+1;
+
+ int ext[6];
+ imagedata->GetExtent(ext);
+ int maxZ = ext[5]-ext[4]+1;
+ for( z=0 ; z<=maxZ ; z=z+step )
+ {
+ printf("wxContourMainFrame::onSegmentationAllSlices2 z=%d \n",z );
+// porcent = 100.0* (z-minZ)/totalZ;
+// tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ,z );
+// interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(tmpString);
+ //_staticTextSegmentation->SetLabel(tmpString);
+ SegmentationOneSlice( 100,100,z,isovalue, sampling,method , imagedata );
+ }
+// interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(_T(" "));
+ RefreshInterface();
+ printf("wxContourMainFrame::onSegmentationAllSlices2 end\n");
+
+}
+
+void wxContourMainFrame::onSegmentationAllSlices(int minZ,int maxZ,int isovalue,int sampling,int method)
{
//JCP 20-10-08 Undo redo implementation
saveState();
tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ,z );
interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(tmpString);
//_staticTextSegmentation->SetLabel(tmpString);
- SegmentationOneSlice( x,y,z,isovalue, sampling,method );
+ SegmentationOneSlice( x,y,z,isovalue, sampling,method , getImageData() );
}
interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(_T(" "));
RefreshInterface();
void wxContourMainFrame::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel)
{
_theViewPanel->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
-
RefreshInterface();
}
void wxContourMainFrame::saveFileWithContoursAutomatique()
{
-printf("EED wxContourMainFrame::saveFileWithContoursAutomatique \n");
std::string filename = kernelManager->getCurrentFileName();
if(filename.compare("")!=0){
saveFileWithContours(filename);
onSave();
}
}
+
void wxContourMainFrame::ShowToolsPanel(bool show)
{
_pannew->Show(show);
}
-
-
void wxContourMainFrame::SetContourGroup(int contourGroup)
{
_contourGroup = contourGroup;
}
-
wxPanel *wxContourMainFrame::getMaskImageViewPanel(wxWindow *parent)
{
-
if (_viewMaskImagePanel==NULL)
{
_contourextractdata = new ContourExtractData(true);
return _viewColorLayerImagePanel;
}
+void wxContourMainFrame::SetColorLayerImage(vtkImageData* img)
+{
+ if (_viewColorLayerImagePanel!=NULL)
+ {
+ if (img!=NULL)
+ {
+ _viewColorLayerImagePanel->SetActive(true);
+ _viewColorLayerImagePanel->SetImage( img );
+// RefreshInterface();
+ } // img
+ } // _viewColorLayerImagePanel
+}
wxPanel *wxContourMainFrame::getThresholdImageViewPanel(wxWindow *parent)
{
{
double range[2];
_theViewPanel->getImageData()->GetScalarRange(range);
- int min = (int)floor (range[0]);
- int max = (int)ceil (range[1]);
- int start= (max+min)/2 - (max-min)*0.25;
- int end= (max+min)/2 + (max-min)*0.25;
- _viewThresholdImagePanel = new ThresholdImageViewPanel( parent, min, max, start, end , 1);
- _viewThresholdImage = new ThresholdImageView();
+ int min = (int)floor (range[0]);
+ int max = (int)ceil (range[1]);
+ int start = (max+min)/2 - (max-min)*0.25;
+ int end = (max+min)/2 + (max-min)*0.25;
+ _viewThresholdImagePanel = new ThresholdImageViewPanel( parent, min, max, start, end , 1);
+ _viewThresholdImage = new ThresholdImageView();
_viewThresholdImage->SetminMaxValue(start,end);
+// _viewThresholdImage->SetminMaxValue(range[0],range[1]);
_viewThresholdImage->SetImage( _theViewPanel->getImageData() );
std::vector<int> colorbarposition;
colorbarposition.push_back( 10 );
_theViewPanel->SetXY(x,y);
}
+wxVtkBaseView* wxContourMainFrame::GetWxVtkBaseView()
+{
+ if (_theViewPanel!=NULL)
+ {
+ return _theViewPanel->getWxVtkBaseView();;
+ } else {
+ return NULL;
+ }
+}