]> Creatis software - creaContours.git/blobdiff - lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx
no message
[creaContours.git] / lib / Interface_ManagerContour_NDimensions / wxContourMainFrame.cxx
index aef8ba2b6772a6957d5cf48781d293730da80891..c6293c330af6fa8f8abf8ab78ca2f2f921a31e26 100644 (file)
@@ -15,6 +15,8 @@
 #include "ConceptDataWrap.h"
 #include <creaWx.h>
 
+
+
 //----------------------------------------------------------------------------------------------------------------
 // Class implementation
 //----------------------------------------------------------------------------------------------------------------
@@ -33,6 +35,7 @@ char wxContourMainFrame::COPY = 'C';
                : wxPanel(parent, id, pos, size, style)
        {
                m_mgr.SetManagedWindow(this);
+               _contourGroup                           = 1;
                _creatingContoursActive         = false;
                _theViewPanel                           = NULL;
 //             _modelManager                           = NULL;
@@ -64,12 +67,15 @@ char wxContourMainFrame::COPY = 'C';
                //wxContour_ActionCommandsID a;
                
                _contourextractdata                     = NULL;
+               _viewMaskImage                          = NULL;
+               _viewMaskImagePanel                     = NULL;
        }
 
        wxContourMainFrame :: wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style,std::string datadir)         
                : wxPanel(parent, id, pos, size, style)
        {
                m_mgr.SetManagedWindow(this);
+               _contourGroup                           = 1;
                _creatingContoursActive         = false;
                _theViewPanel                           = NULL;
 
@@ -82,6 +88,8 @@ char wxContourMainFrame::COPY = 'C';
                _thresholdMapper                        = NULL;
                _thresholdActor                         = NULL;
                _actorPresent                           = false;
+               _viewMaskImage                          = NULL;
+               _viewMaskImagePanel                     = NULL;
 
                // set up default notebook style
                m_notebook_style =wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER;
@@ -637,6 +645,19 @@ void wxContourMainFrame::changeInstant()
                kernelManager->setInstant(instantVect);
                //_modelManager->setInstant( _actualInstant );
                
+       
+               if(_viewMaskImage!=NULL){
+                       int actualSlice = instantVect[1];
+                       _viewMaskImage->SetZ(actualSlice);
+                       
+                       if (_viewMaskImagePanel->IsVisible()==true)
+                       {
+                               vtkImageData *mask, *value;
+                               getMaskValue(&mask,&value, _contourGroup , 0, -1, -1);
+                               _viewMaskImage->onThreshold();
+                       }
+               }
+       
            onThresholdChange();
                updateInstantOutlines();
                updateInstantImageData();
@@ -2368,15 +2389,10 @@ std::vector<std::string> wxContourMainFrame::getOutlinesName(int slide){
 }
 
 
-void wxContourMainFrame::GenerateContourExtractData()
-{
-       if (_contourextractdata==NULL) { _contourextractdata = new ContourExtractData(true); }
-}
-
 
 void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ,int grayRangeMin, int grayRangeMax)
 {
-       GenerateContourExtractData();
+//EED01Juillet2009     GenerateContourExtractData();
        
        wxString tempString;
        int maxContourGroup     =       0;
@@ -2401,7 +2417,7 @@ void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int sel
        std::vector<int> tempVector;
        _instantPanel->getInstant( tempVector );
 
-       vtkImageData *imagedata = _theViewPanel->getImageData();
+//EED01Juillet2009     vtkImageData *imagedata = _theViewPanel->getImageData();
 //     int sizeZ = _theViewPanel->GetImageDataSizeZ();
        int z;
        int ii,sizeLstContourThings;
@@ -2412,7 +2428,6 @@ void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int sel
        double porcent; 
        wxString tmpString;
 
-//?????        
 
        if (selection==0 ) // actual slice
        {
@@ -2426,7 +2441,7 @@ void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int sel
        
 
        totalZ  = maxZ-minZ+1;
-       _contourextractdata->SetImage( imagedata);
+//EED01Juillet2009     _contourextractdata->SetImage( imagedata);
 
        _contourextractdata->InitVolumeStatistics();
        
@@ -2640,7 +2655,6 @@ void wxContourMainFrame::onSaveResults(std::string directory,std::string namefil
                fprintf(pFile,"\n\n" );
 
                
-// ??????
                
                if (selection==0 ) // actual slice
                {
@@ -2682,7 +2696,7 @@ void wxContourMainFrame::onSaveResults(std::string directory,std::string namefil
 void wxContourMainFrame::SaveValuesXYZ(std::string directory,std::string namefile,int typeContourGroup)
 {
        wxBusyCursor wait;
-       GenerateContourExtractData();
+//EED01Juillet2009     GenerateContourExtractData();
        
        //int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
        _contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
@@ -2698,7 +2712,7 @@ void wxContourMainFrame::SaveValuesXYZ(std::string directory,std::string namefil
        std::vector<int> tempVector;
        _instantPanel->getInstant( tempVector );
 
-       vtkImageData *imagedata = _theViewPanel->getSceneManager()->GetImageData();
+//EED01Juillet2009     vtkImageData *imagedata = _theViewPanel->getSceneManager()->GetImageData();
        int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
        int z;
        int ii,sizeLstContourThings;
@@ -2712,7 +2726,7 @@ void wxContourMainFrame::SaveValuesXYZ(std::string directory,std::string namefil
        maxZ    = sizeZ;//_mbarrange->GetEnd();
        totalZ  = maxZ-minZ+1;
 
-       _contourextractdata->SetImage( imagedata);
+//EED01Juillet2009     _contourextractdata->SetImage( imagedata);
 
 // For each slice..
        for ( z=0 ; z<sizeZ ; z++)
@@ -2808,7 +2822,7 @@ void wxContourMainFrame::SaveValuesXYZ(std::string directory,std::string namefil
 
 void wxContourMainFrame::getMaskValue(vtkImageData ** mask,vtkImageData ** value,int typeContourGroup, int selection, int minZ, int maxZ){
        wxBusyCursor wait;
-       GenerateContourExtractData();
+//EED01Juillet2009     GenerateContourExtractData();
 
        //int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
        if (typeContourGroup==3)
@@ -2824,7 +2838,10 @@ void wxContourMainFrame::getMaskValue(vtkImageData ** mask,vtkImageData ** value
        std::vector<int> tempVector;
        _instantPanel->getInstant( tempVector );
 
-       vtkImageData *imagedata = _theViewPanel->getImageData();
+    vtkImageData *imagedata = _theViewPanel->getImageData();
+       int ext[6];
+       imagedata->GetExtent(ext);
+       int sizeZimage = ext[5]-ext[4]+1;
        int z;
        int ii,sizeLstContourThings;
 
@@ -2844,8 +2861,18 @@ void wxContourMainFrame::getMaskValue(vtkImageData ** mask,vtkImageData ** value
        
        totalZ  = maxZ-minZ;
 
-       _contourextractdata->SetImage( imagedata);
+//EED01Juillet2009     _contourextractdata->SetImage( imagedata);
 
+       // cleanning image before range 
+       for (z=0; z<minZ; z++){
+               _contourextractdata->ResetImageResult(z);
+       }
+       // cleanning image after range 
+       for (z=maxZ+1; z<sizeZimage; z++){
+               _contourextractdata->ResetImageResult(z);
+       }
+       
+       
 // For each slice..
        for ( z=minZ ; z<=maxZ ; z++)
        {
@@ -2994,3 +3021,49 @@ void wxContourMainFrame::ShowToolsPanel(bool show){
        _pannew->Show(show);
 }
 
+
+//EED01Juillet2009
+/*
+void wxContourMainFrame::GenerateContourExtractData()
+{
+       if (_contourextractdata==NULL) { }
+}
+*/ 
+
+
+wxPanel *wxContourMainFrame::getThresholdImageViewPanel(wxWindow *parent)
+{
+       
+       if      (_viewMaskImagePanel==NULL)
+       {
+               _contourextractdata = new ContourExtractData(true);
+               _contourextractdata->SetImage( _theViewPanel->getImageData() );
+               
+               double range[2];
+               _theViewPanel->getImageData()->GetScalarRange(range);
+               //int min = (int)floor (range[0]);
+               //int max = (int)ceil (range[1]);
+               int min = 0;
+               int max = 255;
+               
+               _viewMaskImagePanel = new ThresholdImageViewPanel( parent, min, max , 0);
+                       _viewMaskImage = new ThresholdImageView();
+                       _viewMaskImage->SetImage(_contourextractdata->GetVtkImageMaskResult() );
+                       _viewMaskImage->SetminMaxValue( 254, 256);
+                       _viewMaskImage->SetBaseColor( 0,0,1 );
+                       _viewMaskImagePanel->SetThresholdImageView( _viewMaskImage );
+                       _viewMaskImage->SetwxVtkBaseView( _theViewPanel->getWxVtkBaseView() );
+               
+       }
+       return _viewMaskImagePanel;
+}
+
+void wxContourMainFrame::SetContourGroup(int contourGroup)
+{
+       printf("EED wxContourMainFrame::SetContourGroup \n");
+       _contourGroup = contourGroup;
+}
+
+
+
+