]> Creatis software - creaContours.git/commitdiff
#3216 creaContours Feature New Normal - vtk8itk4wx3-mingw64
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Tue, 7 Aug 2018 13:46:37 +0000 (15:46 +0200)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Tue, 7 Aug 2018 13:46:37 +0000 (15:46 +0200)
lib/Interface_Icons_NDimensions/interfMainPanel.cxx
lib/Interface_Icons_NDimensions/interfToolsPanels.cxx
lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx
lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h
lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx

index b9123cb266b4ed54ae2d6af1d12faeb5c7a7b91b..293100824fc8faa5a3d5b56397aa861c7e27a4fe 100644 (file)
@@ -669,7 +669,6 @@ void interfMainPanel::setStringSpread(std::string stringtemp)
 
 void interfMainPanel::onInformationPressed()
 {
-printf("EED interfMainPanel::onInformationPressed Start\n");
        // Statistics frame
        if(infoWin ==NULL)
        {
@@ -683,14 +682,14 @@ printf("EED interfMainPanel::onInformationPressed 0.3\n");
                informationPanel        = new interfInformationPanel(infoWin);//contourevent->getInformationPanel(infoWin);
 printf("EED interfMainPanel::onInformationPressed 0.3a\n");
 
-               wxBoxSizer * sizerPanel = new wxBoxSizer(wxHORIZONTAL);
+// Borrame             wxBoxSizer * sizerPanel = new wxBoxSizer(wxHORIZONTAL);
+               wxFlexGridSizer * sizerPanel            = new wxFlexGridSizer(1);
+
                sizerPanel -> Add( informationPanel, 1, wxEXPAND ,0);
 printf("EED interfMainPanel::onInformationPressed 0.4\n");
 
                infoWin->SetSizer( sizerPanel );
-printf("EED interfMainPanel::onInformationPressed 0.41\n");
                infoWin->SetAutoLayout( true );
-printf("EED interfMainPanel::onInformationPressed 0.42\n");
                infoWin->Layout();
 printf("EED interfMainPanel::onInformationPressed 0.43\n");
                infoWin->Show();
index d2505d571232b1567926022f810977ba9b4c1d16..263d4e7078c0bc46d438b0c3ee2fc13a7252e1e5 100644 (file)
@@ -107,7 +107,6 @@ void interfConfigurationPanel::onBrigthnessColorWindowLevel(wxScrollEvent& event
 
 void interfConfigurationPanel::OnInterpolation(wxCommandEvent& event)
 {
-
        interfMainPanel::getInstance()->onInterpolation(_interpolationCheckBox->GetValue());
 
 
@@ -221,7 +220,8 @@ void interfSpreadPanel::setStringSpread(std::string stringtemp){
 ** Begin of information panel
 **/
 interfInformationPanel::interfInformationPanel(wxWindow * parent)
-: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
+//: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
+: wxPanel(parent, -1)
 {
 printf("EED interfInformationPanel::interfInformationPanel Start\n");
        //wxPanel *panel                                                                        = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxTAB_TRAVERSAL);
@@ -338,7 +338,7 @@ printf("EED interfInformationPanel::interfInformationPanel 3\n");
        _grid = new wxGrid( this,
                 wxID_ANY,
                 wxPoint( 0, 0 ),
-                wxSize( 200, 500 ) );
+                wxSize( 200, 250 ) );
        int i,gridCol=10,gridRow=sizeZ+2;
        _grid->CreateGrid( 0, 0 );
        _grid->AppendRows(gridRow);
@@ -402,19 +402,13 @@ printf("EED interfInformationPanel::interfInformationPanel 5.3\n");
        sizer->Add( new wxStaticText(this      ,1,_T("Gray Range"))     , 1, wxALL , 0 );
 printf("EED interfInformationPanel::interfInformationPanel 5.4\n");
        sizer->Add( _mbarrangeRangeInformation , 1, wxALL|wxGROW        , 2 );
-printf("EED interfInformationPanel::interfInformationPanel 5.5\n");
-
+       
+       
        sizer->Add( sizerB                     , 1, wxEXPAND            , 0 );
-
-printf("EED interfInformationPanel::interfInformationPanel 5.6\n");
        sizer->Add( _staticTextInformation     , 1, wxEXPAND            , 0 );
-printf("EED interfInformationPanel::interfInformationPanel 5.7\n");
        sizer->Add( _grid                      , 1, wxEXPAND            , 0 );
-printf("EED interfInformationPanel::interfInformationPanel 5.8\n");
        this->SetSizer( sizer );
-printf("EED interfInformationPanel::interfInformationPanel 5.9\n");
        this->SetSize( wxSize(1500,1500) );
-       //this->SetBackgroundColour( wxColour(100,100,100) );
        this->SetAutoLayout( true );
 printf("EED interfInformationPanel::interfInformationPanel 5.10\n");
        this->Layout();
index ca8e2bcb7a8d23cd7001794051aa9003adbdf498..548195cb526aaa76c34da97695a741f0980e1a7d 100644 (file)
@@ -94,6 +94,8 @@ char wxContourMainFrame::COPY = 'C';
                _viewThresholdImage                     = NULL;
                _viewThresholdImagePanel        = NULL;
                _viewColorLayerImagePanel       = NULL;
+
+               _frameShowResultImages          = 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)
@@ -103,7 +105,6 @@ char wxContourMainFrame::COPY = 'C';
                _contourGroup                           = 1;
                _creatingContoursActive         = false;
                _theViewPanel                           = NULL;
-
                _instantPanel                           = NULL;
                _refLineControl                         = NULL;
                _refLineModel                           = NULL;
@@ -123,7 +124,7 @@ char wxContourMainFrame::COPY = 'C';
                inredo                                          = 0;
                inundo                                          = 0;
                _pannew = interfMainPanel::getInstance(this,datadir+"/data/Icons");//, eventHandler);
-               _performingOperation            = new PerformingOperation();
+               _performingOperation        = new PerformingOperation();
                if(images.size() > 0)
                {
                        this->setVectImages(images);
@@ -638,21 +639,27 @@ void wxContourMainFrame::ShowResultImages(int typeContourGroup, int selection, i
        nTypeView.push_back(2);
        nTypeView.push_back(0);
 
-       wxFrame *frame = new wxFrame(this, -1,_T("Result image extracted.."),wxDefaultPosition,wxSize(600,600), wxDEFAULT_FRAME_STYLE|wxSTAY_ON_TOP);
-       wxAuiManager *m_mgr_noteBookViewerResult = new wxAuiManager();
-       m_mgr_noteBookViewerResult->SetManagedWindow(frame);
+       if (_frameShowResultImages==NULL)
+       {
+//             wxFrame *_frameShowResultImages = new wxFrame(this, -1,_T("Result image extracted.."),wxDefaultPosition,wxSize(600,600), wxDEFAULT_FRAME_STYLE|wxSTAY_ON_TOP);
+               _frameShowResultImages = new wxFrame(this, -1,_T("Result image extracted.."),wxDefaultPosition,wxSize(600,600), 
+                    wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION |  wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER  );
+
+               wxAuiManager *m_mgr_noteBookViewerResult = new wxAuiManager();
+               m_mgr_noteBookViewerResult->SetManagedWindow(_frameShowResultImages);
 
-       wxAuiNotebook* noteBookViewerResult = new wxAuiNotebook(frame, -1, wxPoint(600, 600), wxSize(430,200), m_notebook_style);
-       m_mgr_noteBookViewerResult->AddPane(noteBookViewerResult, wxAuiPaneInfo().Name(wxT("notebook_content")).CenterPane().PaneBorder(false));
+               wxAuiNotebook* noteBookViewerResult = new wxAuiNotebook(_frameShowResultImages, -1, wxPoint(600, 600), wxSize(430,200), m_notebook_style);
+               m_mgr_noteBookViewerResult->AddPane(noteBookViewerResult, wxAuiPaneInfo().Name(wxT("notebook_content")).CenterPane().PaneBorder(false));
 
-       wxPanel *panelViewer1 = new wxMaracas_N_ViewersWidget(noteBookViewerResult, value,&nTypeView);
-       wxPanel *panelViewer2 = new wxMaracas_N_ViewersWidget(noteBookViewerResult, mask,&nTypeView);
+               wxPanel *panelViewer1 = new wxMaracas_N_ViewersWidget(noteBookViewerResult, value,&nTypeView);
+               wxPanel *panelViewer2 = new wxMaracas_N_ViewersWidget(noteBookViewerResult, mask,&nTypeView);
 
 
-       noteBookViewerResult->AddPage( panelViewer1, wxT("Image result") );
-       noteBookViewerResult->AddPage( panelViewer2, wxT("Mask result") );
-       m_mgr_noteBookViewerResult->Update();
-       frame->Show();
+               noteBookViewerResult->AddPage( panelViewer1, wxT("Image result") );
+               noteBookViewerResult->AddPage( panelViewer2, wxT("Mask result") );
+               m_mgr_noteBookViewerResult->Update();
+               _frameShowResultImages->Show();
+       } // if _frameShowResultImages
 }
 
 
@@ -1709,19 +1716,18 @@ printf("EED wxContourMainFrame::SegmentationOneSliceITK  Skypping this code.  No
                {
                        vecXo.push_back(p[0]);
                        vecYo.push_back(p[1]);
-               }
-               else
-               {
-               vecX.push_back( p[0] );
-               myfile <<p[0]<<","<<p[1]<<"\n";
-               //std::cout<<" x Anterior "<<xAct<<" x actual "<<x<<std::endl;
-               //std::cout<<" y Anterior "<<yAct<<" y actual "<<y<<std::endl;
-               //std::cout<<" x "<<p[0]<<" y "<<p[1]<<std::endl;
-               vecY.push_back( p[1] );
-               vecZ.push_back( 900 );
-               xAct=x;
-               yAct=y;
-               }
+               } else {
+                       vecX.push_back( p[0] );
+                       myfile <<p[0]<<","<<p[1]<<"\n";
+                       //std::cout<<" x Anterior "<<xAct<<" x actual "<<x<<std::endl;
+                       //std::cout<<" y Anterior "<<yAct<<" y actual "<<y<<std::endl;
+                       //std::cout<<" x "<<p[0]<<" y "<<p[1]<<std::endl;
+                       vecY.push_back( p[1] );
+//EED 2017-12-16
+                       vecZ.push_back( -900 );
+                       xAct = x;
+                       yAct = y;
+               } // if xAct
 
 
        }
@@ -1731,7 +1737,8 @@ printf("EED wxContourMainFrame::SegmentationOneSliceITK  Skypping this code.  No
                vecX.push_back(vecXo.back());
                //std::cout<<" x Siguiente "<<vecXo.back();
                vecXo.pop_back();
-               vecZ.push_back( 900 );
+//EED 2017-12-16
+               vecZ.push_back( -900 );
        }
        while(!vecYo.empty())
        {
@@ -2034,7 +2041,8 @@ myfile.close();
 //             double y=p[1];
                vecX.push_back( p[0] );
                vecY.push_back( p[1] );
-               vecZ.push_back( 900 );
+//EED 2017-12-16
+               vecZ.push_back( -900 );
 //                     vecZ.push_back( p[2] );
        }
 
@@ -2951,7 +2959,6 @@ void wxContourMainFrame::getMaskValue(vtkImageData ** mask,vtkImageData ** value
        int z;
        int ii,sizeLstContourThings;
 
-
        double totalZ;
        double porcent;
 
@@ -3032,13 +3039,41 @@ void wxContourMainFrame::getMaskValue(vtkImageData ** mask,vtkImageData ** value
 
 }
 
-void wxContourMainFrame::SaveImageResult(std::string directory,std::string namefile, vtkImageData* mask,vtkImageData* value)
+std::string wxContourMainFrame::GetStringTypeImage( vtkImageData* image)
 {
+       std::string result="";
+       if ( image->GetScalarType()==VTK_CHAR )
+       {
+               result="CHAR";
+       } else if ( image->GetScalarType()==VTK_UNSIGNED_CHAR ){
+               result="UCHAR";
+       } else if ( image->GetScalarType()==VTK_FLOAT ){
+               result="FLOAT";
+       } else if ( image->GetScalarType()==VTK_DOUBLE ){
+               result="DOUBLE";
+       } else if ( image->GetScalarType()==VTK_INT ){
+               result="INT";
+       } else if ( image->GetScalarType()==VTK_UNSIGNED_INT ){
+               result="UINT";
+       } else if ( image->GetScalarType()==VTK_SHORT ){
+               result="SHORT";
+       } else if ( image->GetScalarType()==VTK_UNSIGNED_SHORT ){
+               result="USHORT";
+       } else if ( image->GetScalarType()==VTK_LONG ){
+               result="LONG";
+       } else if ( image->GetScalarType()==VTK_UNSIGNED_LONG ){
+               result="ULONG";
+       }
+       return result;
+}
 
+void wxContourMainFrame::SaveImageResult(std::string directory,std::string namefile, vtkImageData* mask,vtkImageData* value)
+{
+       std::string stringType;
        double spc[3];
        kernelManager->GetSpacing(spc,0);   // returns the spacing of the first image
-       
-       std::string temp = directory + "/" + namefile + "-image-Value.mhd";
+       stringType              = GetStringTypeImage(value);
+       std::string temp = directory + "/" + namefile + "-image-Value-"+stringType+".mhd";
 
        wxString filename = crea::std2wx(temp);
 
@@ -3066,7 +3101,8 @@ void wxContourMainFrame::SaveImageResult(std::string directory,std::string namef
        writerValueImage->Write( );
 
 // Image Mask
-       temp = directory + "/" + namefile + "-image-Mask.mhd";
+       stringType              = GetStringTypeImage(mask);
+       temp = directory + "/" + namefile + "-image-Mask-"+stringType+".mhd";
 
        // LG 14/01/09 : using crea
        filename = crea::std2wx(temp);
@@ -3159,7 +3195,7 @@ void wxContourMainFrame::SetContourGroup(int contourGroup)
 
 wxPanel *wxContourMainFrame::getMaskImageViewPanel(wxWindow *parent)
 {
-
        if      (_viewMaskImagePanel==NULL)
        {
                _contourextractdata = new ContourExtractData(true);
@@ -3168,15 +3204,29 @@ wxPanel *wxContourMainFrame::getMaskImageViewPanel(wxWindow *parent)
 //             _theViewPanel->getImageData()->GetScalarRange(range);
                //int min = (int)floor (range[0]);
                //int max = (int)ceil (range[1]);
+
+//EED 2017-12-17
                int min = 254;
                int max = 256;
-               _viewMaskImagePanel = new ThresholdImageViewPanel( parent, -1, -1 , 0);
+
+               _viewMaskImagePanel = new ThresholdImageViewPanel( parent, -1, -1 , -1,-1,  0);
                _viewMaskImage = new ThresholdImageView();
-               _viewMaskImage->SetImage(_contourextractdata->GetVtkImageMaskResult() );
+               _viewMaskImage->SetImage( _contourextractdata->GetVtkImageMaskResult() );
                _viewMaskImage->SetminMaxValue( min, max);
                _viewMaskImage->SetBaseColor( 0,0,1 );
+
+
+               std::vector<int> colorbarposition;
+               colorbarposition.push_back( -999 );
+               colorbarposition.push_back( -999 );
+               _viewMaskImage->SetColorBarPosition( colorbarposition );
+               double spc[3];
+               _viewMaskImage->SetSpcBase( _theViewPanel->getImageData()->GetSpacing() );
+               _viewMaskImage->SetNewSpacingLayer( _theViewPanel->getImageData()->GetSpacing() );
+
                _viewMaskImagePanel->SetThresholdImageView( _viewMaskImage );
                _viewMaskImage->SetwxVtkBaseView( _theViewPanel->getWxVtkBaseView() );
+               _viewMaskImage->onThresholdChangeOpacity( 25 );
        }
        return _viewMaskImagePanel;
 }
@@ -3192,6 +3242,21 @@ wxPanel *wxContourMainFrame::getColorLayerImageViewPanel(wxWindow *parent)
                int max = (int)ceil (range[1]);
                _viewColorLayerImagePanel = new ColorLayerImageViewPanel( parent, min, max, 100, 1);
                _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetwxVtkBaseView( 0 , _theViewPanel->getWxVtkBaseView() );
+       //    std::vector<double> range = bbGetInputlstRangeForColorBar();
+       //    clivp->GetColorLayerImageViewManager()->SetRangeForColorBar( range );
+               std::vector<int> colorbarposition;
+               colorbarposition.push_back( 50 );
+               colorbarposition.push_back( 105 );
+               _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetColorBarPosition( colorbarposition );
+       //    std::vector<double> base_color;
+       //    _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetBaseColors( base_color );
+       //    std::vector<double> grey_level_boundaries;
+       //    clivp->GetColorLayerImageViewManager()->SetGreyLevelBoundaries( grey_level_boundaries );
+               std::vector<double> transparence_level_boundaries;
+               transparence_level_boundaries.push_back(0);
+               _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetBaseTransparence( transparence_level_boundaries );
+               _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetPlainOrGradientColor( false );
+//             _viewColorLayerImagePanel->SetFittingMode( 3 );
        }
        return _viewColorLayerImagePanel;
 }
@@ -3205,13 +3270,25 @@ wxPanel *wxContourMainFrame::getThresholdImageViewPanel(wxWindow *parent)
                _theViewPanel->getImageData()->GetScalarRange(range);
                int min = (int)floor (range[0]);
                int max = (int)ceil (range[1]);
-               _viewThresholdImagePanel = new ThresholdImageViewPanel( parent, min, max , 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->SetImage( _theViewPanel->getImageData() );
-               _viewThresholdImage->SetminMaxValue( min, max);
+               std::vector<int> colorbarposition;
+               colorbarposition.push_back( 10 );
+               colorbarposition.push_back( 105 );
+               _viewThresholdImage->SetColorBarPosition( colorbarposition );
+               double spc[3];
+               _viewThresholdImage->SetSpcBase( _theViewPanel->getImageData()->GetSpacing() );
+               _viewThresholdImage->SetNewSpacingLayer( _theViewPanel->getImageData()->GetSpacing() );
+
                _viewThresholdImage->SetBaseColor( 1,0,0 );
                _viewThresholdImagePanel->SetThresholdImageView( _viewThresholdImage );
                _viewThresholdImage->SetwxVtkBaseView( _theViewPanel->getWxVtkBaseView() );
+               _viewThresholdImage->onThresholdChangeOpacity( 25 );
+               RefreshInterface();
        }
        return _viewThresholdImagePanel;
 }
index 7af20a35e681e629868117157f588d77ccbd8433..d9445631743d9c1169aaa4358c4dd39bfb127a08 100644 (file)
@@ -339,6 +339,8 @@ class wxContourMainFrame : public wxPanel {
 
        void SetScalarRange(int grayRangeMin, int grayRangeMax);
 
+       std::string GetStringTypeImage( vtkImageData* image);
+
 //------------------------------------------------------------------------------------------------------------
 
 private:
@@ -424,6 +426,8 @@ private:
        std::string                 _fileLocation;
 //------------------------------------------------------------------------------------------------------------
 
+       wxFrame                                         *_frameShowResultImages;
+
 };
 
 #endif
index 4211b7fd57fc5803ca1a120e5df244579846ee0c..0115b33cbb411d4947cd29b5b429a575547c1a63 100644 (file)
@@ -761,21 +761,14 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHANGE )
        void wxContourViewPanel::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel)
        {
                wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)getWxVtkBaseView();
-               vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
-               imageviewer->SetColorWindow(colorwindow);
-               imageviewer->SetColorLevel(windowlevel);
+               wxvtk2dbaseview->SetColorWindow( colorwindow );
+               wxvtk2dbaseview->SetColorLevel( windowlevel );
        }
 
        void wxContourViewPanel::onInterpolation(bool interpolate)
        {
                wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)getWxVtkBaseView();
-               vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
-
-               if (interpolate){
-                       imageviewer->GetImageActor()->InterpolateOn();
-               } else {
-                       imageviewer->GetImageActor()->InterpolateOff();
-               }
+               wxvtk2dbaseview->SetInterpolate( interpolate );
        }
 
        void wxContourViewPanel::GetPointsOfActualContour( std::vector<double> *vecX, std::vector<double> *vecY, std::vector<double> *vecZ )