From: Eduardo DAVILA Date: Wed, 11 Dec 2019 15:44:30 +0000 (+0100) Subject: #3322 creaContours Feature New Normal - Show reference contour Befor After actual... X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=ef966ac5e14dc46db8fc657c7892c9af975eb2a3;p=creaContours.git #3322 creaContours Feature New Normal - Show reference contour Befor After actual slice --- diff --git a/lib/Interface_Icons_NDimensions/interfMainPanel.cxx b/lib/Interface_Icons_NDimensions/interfMainPanel.cxx index c54ec11..bb87ee6 100644 --- a/lib/Interface_Icons_NDimensions/interfMainPanel.cxx +++ b/lib/Interface_Icons_NDimensions/interfMainPanel.cxx @@ -600,6 +600,11 @@ void interfMainPanel::onBeforAfterContour(bool before, bool after) wxContourMainFrame::getInstance()->onBeforeAfterContour(before,after); } +void interfMainPanel::onShowTextContour(bool show) +{ + wxContourMainFrame::getInstance()->onShowTextContour(show); +} + void interfMainPanel::onConfigurationPressed() { diff --git a/lib/Interface_Icons_NDimensions/interfMainPanel.h b/lib/Interface_Icons_NDimensions/interfMainPanel.h index c9267a7..d6a40a9 100644 --- a/lib/Interface_Icons_NDimensions/interfMainPanel.h +++ b/lib/Interface_Icons_NDimensions/interfMainPanel.h @@ -169,6 +169,7 @@ public: int getWindowLevel(); void onBrigthnessColorWindowLevel(int colorwindow,int windowlevel); void onInterpolation(bool interpolate); + void onShowTextContour(bool show); void onBeforAfterContour(bool before, bool after); void onSpreadPressed(); void onConfigurationPressed(); diff --git a/lib/Interface_Icons_NDimensions/interfSegmentationPanels.cxx b/lib/Interface_Icons_NDimensions/interfSegmentationPanels.cxx index 46fb279..5578696 100644 --- a/lib/Interface_Icons_NDimensions/interfSegmentationPanels.cxx +++ b/lib/Interface_Icons_NDimensions/interfSegmentationPanels.cxx @@ -113,19 +113,19 @@ void interfSegmentationPanelVTK::onSegmentationPressedITK(wxCommandEvent& event void interfSegmentationPanelVTK::onSegmentationOneSlice( wxCommandEvent& event ) { - int isovalue = _isovalue->GetValue(); - int sampling = _sampling->GetValue(); - int method = methodRadiobox->GetSelection(); + int isovalue = _isovalue->GetValue(); + int sampling = _sampling->GetValue(); + int method = methodRadiobox->GetSelection(); interfMainPanel::getInstance()->onSegmentationOneSlice(isovalue, sampling, method); } void interfSegmentationPanelVTK::onSegmentationAllSlice( wxCommandEvent& event ) { - int minZ=_mbarrange->GetStart(); - int maxZ=_mbarrange->GetEnd(); - int isovalue = _isovalue->GetValue(); - int sampling = _sampling->GetValue(); - int method = methodRadiobox->GetSelection(); + int minZ = _mbarrange->GetStart(); + int maxZ = _mbarrange->GetEnd(); + int isovalue = _isovalue->GetValue(); + int sampling = _sampling->GetValue(); + int method = methodRadiobox->GetSelection(); interfMainPanel::getInstance()->onSegmentationAllSlice(minZ, maxZ, isovalue, sampling, method); } diff --git a/lib/Interface_Icons_NDimensions/interfToolsPanels.cxx b/lib/Interface_Icons_NDimensions/interfToolsPanels.cxx index b26ed89..ea290ac 100644 --- a/lib/Interface_Icons_NDimensions/interfToolsPanels.cxx +++ b/lib/Interface_Icons_NDimensions/interfToolsPanels.cxx @@ -51,13 +51,17 @@ interfConfigurationPanel::interfConfigurationPanel(wxWindow * parent) _brithtnessWindowLevel = new wxSlider(this, -1, windowlevel , min, max, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); _brithtnessColorLevel = new wxSlider(this, -1, colorwindow , min, max, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); - _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image Interpolation") ); + _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image Interpolation") ); _interpolationCheckBox->SetValue(true); - _beforContourCheckBox = new wxCheckBox(this, -1, _T("Befor Contour") ); + _showTextContourCheckBox = new wxCheckBox(this, -1, _T("Labels Contours") ); + _showTextContourCheckBox->SetValue(true); + + + _beforContourCheckBox = new wxCheckBox(this, -1, _T("Befor Contour") ); _beforContourCheckBox->SetValue(false); - _afterContourCheckBox = new wxCheckBox(this, -1, _T("After Contour") ); + _afterContourCheckBox = new wxCheckBox(this, -1, _T("After Contour") ); _afterContourCheckBox->SetValue(false); @@ -69,21 +73,31 @@ interfConfigurationPanel::interfConfigurationPanel(wxWindow * parent) Connect( _brithtnessColorLevel->GetId() , wxEVT_SCROLL_CHANGED, (wxObjectEventFunction) &interfConfigurationPanel::onBrigthnessColorWindowLevel); Connect( _brithtnessColorLevel->GetId() , wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &interfConfigurationPanel::onBrigthnessColorWindowLevel); Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &interfConfigurationPanel::OnInterpolation); + Connect( _showTextContourCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &interfConfigurationPanel::OnShowTextContour); Connect( _beforContourCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &interfConfigurationPanel::OnBeforAfterContour); Connect( _afterContourCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &interfConfigurationPanel::OnBeforAfterContour); - wxFlexGridSizer * sizer = new wxFlexGridSizer(1); - sizer -> Add( new wxStaticText(this,-1, _T("Contour width")) , 1, wxGROW ); - sizer -> Add( _withOfContourLine , 1, wxGROW ); - sizer -> Add( new wxStaticText(this,-1, _T(" ")) , 1, wxGROW ); - sizer -> Add( new wxStaticText(this,-1, _T("Window level")) , 1, wxGROW ); - sizer -> Add( _brithtnessWindowLevel , 1, wxGROW ); - sizer -> Add( new wxStaticText(this,-1, _T("Color level")) , 1, wxGROW ); - sizer -> Add( _brithtnessColorLevel, 1, wxGROW ); - sizer -> Add( new wxStaticText(this,-1, _T(" ")) , 1, wxGROW ); - sizer -> Add( _interpolationCheckBox , 1, wxGROW ); - sizer -> Add( _beforContourCheckBox , 1, wxGROW ); - sizer -> Add( _afterContourCheckBox , 1, wxGROW ); + wxFlexGridSizer * sizerA = new wxFlexGridSizer(1); + sizerA -> Add( new wxStaticText(this,-1, _T("Contour width")) , 1, wxGROW ); + sizerA -> Add( _withOfContourLine , 1, wxGROW ); + sizerA -> Add( new wxStaticText(this,-1, _T(" ")) , 1, wxGROW ); + sizerA -> Add( new wxStaticText(this,-1, _T("Window level")) , 1, wxGROW ); + sizerA -> Add( _brithtnessWindowLevel , 1, wxGROW ); + sizerA -> Add( new wxStaticText(this,-1, _T("Color level")) , 1, wxGROW ); + sizerA -> Add( _brithtnessColorLevel, 1, wxGROW ); + sizerA -> Add( new wxStaticText(this,-1, _T(" ")) , 1, wxGROW ); + + wxFlexGridSizer * sizerB = new wxFlexGridSizer(1); + sizerB -> Add( _interpolationCheckBox , 1, wxGROW ); + sizerB -> Add( new wxStaticText(this,-1, _T(" ")) , 1, wxGROW ); + sizerB -> Add( _showTextContourCheckBox , 1, wxGROW ); + sizerB -> Add( new wxStaticText(this,-1, _T(" ")) , 1, wxGROW ); + sizerB -> Add( _beforContourCheckBox , 1, wxGROW ); + sizerB -> Add( _afterContourCheckBox , 1, wxGROW ); + + wxFlexGridSizer * sizer = new wxFlexGridSizer(2); + sizer -> Add( sizerA , 1, wxGROW ); + sizer -> Add( sizerB , 1, wxGROW ); this->SetSizer( sizer ); //JCP 13-10-08 @@ -121,6 +135,11 @@ void interfConfigurationPanel::OnBeforAfterContour(wxCommandEvent& event) interfMainPanel::getInstance()->onBeforAfterContour(_beforContourCheckBox->GetValue() , _afterContourCheckBox->GetValue() ); } +void interfConfigurationPanel::OnShowTextContour(wxCommandEvent& event) +{ + interfMainPanel::getInstance()->onShowTextContour(_showTextContourCheckBox->GetValue() ); +} + /** ** Begin of the spread panel diff --git a/lib/Interface_Icons_NDimensions/interfToolsPanels.h b/lib/Interface_Icons_NDimensions/interfToolsPanels.h index d5c7815..5ea04f2 100644 --- a/lib/Interface_Icons_NDimensions/interfToolsPanels.h +++ b/lib/Interface_Icons_NDimensions/interfToolsPanels.h @@ -41,11 +41,13 @@ private: void onWidthOfContour(wxScrollEvent& event); void onBrigthnessColorWindowLevel(wxScrollEvent& event); void OnInterpolation(wxCommandEvent& event); + void OnShowTextContour(wxCommandEvent& event); void OnBeforAfterContour(wxCommandEvent& event); wxSlider* _withOfContourLine; wxSlider* _brithtnessWindowLevel; wxSlider* _brithtnessColorLevel; wxCheckBox* _interpolationCheckBox; + wxCheckBox* _showTextContourCheckBox; wxCheckBox* _beforContourCheckBox; wxCheckBox* _afterContourCheckBox; }; diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx index f780b86..0e7bff4 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx @@ -1899,21 +1899,17 @@ void wxContourMainFrame::onSegmentationOneSlice(int isovalue,int sampling,int me void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method ) { -printf("EED wxContourMainFrame::SegmentationOneSlice Start\n"); int typeofcontour = 1; //--Extracting Contour - //vtkImageData *imagedata = _theViewPanel->getSceneManager()->GetImageData(); vtkImageData *imagedata = getImageData(); -// double *range = imagedata->GetScalarRange(); -// double thr = 1; vtkImageReslice *imageReslice = vtkImageReslice::New(); //EED -// double spc[3]; -// imagedata->GetSpacing(spc); -// x = x*spc[0]; -// y = y*spc[1]; -// z = z*spc[3]; + double spc[3]; + imagedata->GetSpacing(spc); + x = x*spc[0]; + y = y*spc[1]; + z = z; //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 @@ -1923,7 +1919,7 @@ printf("EED wxContourMainFrame::SegmentationOneSlice Start\n"); #endif imageReslice->SetInformationInput(imagedata); imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1); - imageReslice->SetResliceAxesOrigin(0,0,z); + imageReslice->SetResliceAxesOrigin(0,0,z*spc[2]); imageReslice->SetOutputDimensionality(2); imageReslice->SetInterpolationModeToLinear(); @@ -1971,7 +1967,15 @@ printf("EED wxContourMainFrame::SegmentationOneSlice Start\n"); cpd->UpdateInformation(); vtkPolyDataConnectivityFilter* conn = vtkPolyDataConnectivityFilter::New( ); - conn->SetExtractionModeToClosestPointRegion( ); + +// conn->SetExtractionModeToPointSeededRegions(); +// conn->SetExtractionModeToCellSeededRegions(); +// conn->SetExtractionModeToSpecifiedRegions(); +// conn->SetExtractionModeToLargestRegion(); +// conn->SetExtractionModeToAllRegions(); + + conn->SetExtractionModeToClosestPointRegion(); + //conn->SetMaxRecursionDepth( 3000 ); //EED 2017-01-01 Migration VTK7 @@ -1996,12 +2000,15 @@ printf("EED wxContourMainFrame::SegmentationOneSlice Start\n"); cpd2->UpdateInformation(); vtkStripper* vtkstripper = vtkStripper::New( ); +vtkstripper->SetJoinContiguousSegments(true); vtkstripper->SetMaximumLength(20000); //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 vtkstripper->SetInput( cpd2->GetOutput() ); #else vtkstripper->SetInputData( cpd2->GetOutput() ); +// vtkstripper->SetInputData( cntVTK->GetOutput() ); + #endif vtkstripper->Update(); vtkstripper->UpdateInformation(); @@ -2026,24 +2033,19 @@ myfile << "-------------------------------------\n"; polyDataResult->GetLines()->Print(myfile); myfile.close(); */ - - cntVTK -> Delete(); - cpd2 -> Delete(); - cpd -> Delete(); - conn -> Delete(); - + cntVTK -> Delete(); + cpd2 -> Delete(); + cpd -> Delete(); + conn -> Delete(); //--Calculating control points - std::vector vecX; std::vector vecY; std::vector vecZ; - std::vector vecCtrlPointX; std::vector vecCtrlPointY; std::vector vecCtrlPointZ; - printf("EED wxContourMainFrame::SegmentationOneSlice GetNumberOfLines=%d \n",polyDataResult->GetNumberOfLines() ); int numberOfPointsInCell; @@ -2060,84 +2062,90 @@ 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=1;ii<=size;ii++) + { + // id = polyDataResult->GetLines()->GetData()->GetValue(ii); + // p = polyDataResult->GetPoint(id); + p = vtkcell->GetPoints()->GetPoint(ii); - double *p; - int ii,size=polyDataResult->GetNumberOfPoints(); - int id; - for (ii=1;ii<=size;ii++) - { - id = polyDataResult->GetLines()->GetData()->GetValue(ii); - p = polyDataResult->GetPoint(id); -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] ); - vecY.push_back( p[1] ); -//EED 2017-12-16 - vecZ.push_back( -900 ); -// vecZ.push_back( p[2] ); - } - + 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] ); + vecY.push_back( p[1] ); + //EED 2017-12-16 + vecZ.push_back( -900 ); + // vecZ.push_back( p[2] ); + } - ExtractControlPoints2D *extractcontrolpoints2d = new ExtractControlPoints2D(); - extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ ); + ExtractControlPoints2D *extractcontrolpoints2d = new ExtractControlPoints2D(); + extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ ); -//PROOFS - /*if (methodRadiobox->GetSelection()==0){ - extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ ); - } - if (methodRadiobox->GetSelection()==1){ - extractcontrolpoints2d->GetControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ ); - } - if (methodRadiobox->GetSelection()==2){ - extractcontrolpoints2d->SetSamplingControlPoints( sampling ); - extractcontrolpoints2d->GetSamplingControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ ); - }*/ + //PROOFS + /*if (methodRadiobox->GetSelection()==0){ + extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ ); + } + if (methodRadiobox->GetSelection()==1){ + extractcontrolpoints2d->GetControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ ); + } + if (methodRadiobox->GetSelection()==2){ + extractcontrolpoints2d->SetSamplingControlPoints( sampling ); + extractcontrolpoints2d->GetSamplingControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ ); + }*/ - if (method==0) - { - extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ ); - } else if (method==1){ - extractcontrolpoints2d->GetControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ ); - } else if (method==2){ - extractcontrolpoints2d->SetSamplingControlPoints( sampling ); - extractcontrolpoints2d->GetSamplingControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ ); - } + if (method==0) + { + extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ ); + } else if (method==1){ + extractcontrolpoints2d->GetControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ ); + } else if (method==2){ + extractcontrolpoints2d->SetSamplingControlPoints( sampling ); + extractcontrolpoints2d->GetSamplingControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ ); + } - //--Adding contour to the system - std::vector actualInstantVector; - _instantPanel->getInstant( actualInstantVector ); - actualInstantVector[1]=z; + //--Adding contour to the system + std::vector actualInstantVector; + _instantPanel->getInstant( actualInstantVector ); + actualInstantVector[1]=z; - int j,sizeCtrPt = vecCtrlPointX.size(); - manualBaseModel *manModelContour = kernelManager->factoryManualContourModel( typeofcontour ); -printf("EED wxContourMainFrame::SegmentationOneSlice sizeCtrPt=%d %d %d\n" , sizeCtrPt - , ((sizeCtrPt/100)+1)*100 *2 - , manModelContour->GetNumberOfPointsSpline() - ); - manModelContour->SetNumberOfPointsSpline( ((sizeCtrPt/100)+1)*100 *2 ); - if (sizeCtrPt>=3) - { - for (j=0 ; jAddPoint( vecCtrlPointX[j] , vecCtrlPointY[j] , vecCtrlPointZ[j] ); - } // for - std::string theName; - //theName = _modelManager->createOutline( manModelContour, actualInstantVector ); - theName = kernelManager->createOutline( manModelContour, actualInstantVector ); - bool addedModel = theName.compare("") != 0; - if( addedModel ) + int j,sizeCtrPt = vecCtrlPointX.size(); + manualBaseModel *manModelContour = kernelManager->factoryManualContourModel( typeofcontour ); + manModelContour->SetNumberOfPointsSpline( ((sizeCtrPt/100)+1)*100 *2 ); + manModelContour->SetLabel2( std::to_string(z) ); + if (sizeCtrPt>=3) { - double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default - _theViewPanel->getSpacing(spc); - //Adding the manualContourControler to interface objects structure - //Adding the manualViewContour to interface objects structure - //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active. - _theViewPanel->configureViewControlTo(theName, manModelContour, spc, typeofcontour); - //_theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc, typeofcontour ) ; - } // if addedModel - } // if sizeCtrPt -printf("EED wxContourMainFrame::SegmentationOneSlice End\n"); + for (j=0 ; jAddPoint( vecCtrlPointX[j] / spc[0], vecCtrlPointY[j] / spc[1], vecCtrlPointZ[j] ); + } // for + std::string theName; + //theName = _modelManager->createOutline( manModelContour, actualInstantVector ); + theName = kernelManager->createOutline( manModelContour, actualInstantVector ); + bool addedModel = theName.compare("") != 0; + if( addedModel ) + { + double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default + _theViewPanel->getSpacing(spc); + //Adding the manualContourControler to interface objects structure + //Adding the manualViewContour to interface objects structure + //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active. + _theViewPanel->configureViewControlTo(theName, manModelContour, spc, typeofcontour); + //_theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc, typeofcontour ) ; + } // if addedModel + } // if sizeCtrPt + } // if NumberOfCells > 0 + +printf("EED wxContourMainFrame::SegmentationOneSlice End\n"); } int wxContourMainFrame::GetImageDataSizeZ() @@ -2157,12 +2165,12 @@ void wxContourMainFrame::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,i //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 x = _theViewPanel->GetX(); + int y = _theViewPanel->GetY(); + int z; + double porcent; + wxString tmpString; + double totalZ = maxZ-minZ+1; for( z=minZ ; z<=maxZ ; z++ ) { porcent = 100.0* (z-minZ)/totalZ; @@ -2407,19 +2415,22 @@ void wxContourMainFrame::onBeforeAfterContour(bool before,bool after) RefreshInterface(); } +void wxContourMainFrame::onShowTextContour(bool show) +{ + _theViewPanel->onShowTextContour(show); + RefreshInterface(); +} void wxContourMainFrame::onChangeInstant(std::string name,int actual) { _instantPanel->setConceptValue( name, actual ); } - void wxContourMainFrame::resetAppend() { kernelManager->resetAppend(); } - void wxContourMainFrame::onSpreadAdd() { std::vector vecX; diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h index cceebd8..b83691a 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h +++ b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h @@ -264,6 +264,7 @@ class wxContourMainFrame : public wxPanel { int getWindowLevel(); void onBrigthnessColorWindowLevel(int colorwindow,int windowlevel); void onInterpolation(bool interpolate); + void onShowTextContour(bool show); void onBeforeAfterContour(bool before, bool after); void onChangeInstant(std::string name,int actual); void resetAppend(); diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx b/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx index de7b906..059d7ce 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx @@ -58,8 +58,8 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHANGE ) { theShowingImage->GetSpacing(last_spacing); showingVID = theShowingImage; - _before = false; - _after = false; + _showBeforeContour = false; + _showAfterContour = false; int gapH = 20; int gapV = 10; _verticalConceptName = ""; @@ -719,11 +719,14 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHANGE ) _sceneManager->addToScene(name, true, true, true, false, false ); } // for i + _sceneManager->SetLabelNumberOfContours( "contours:"+std::to_string(size) ); + std::vector tempVector; wxContourMainFrame::getInstance()->getInstantVector( tempVector ); - if (_before==true) + if (_showBeforeContour==true) { + size=0; std::vector lstNameBefor; // Contours Befor for (i=tempVector[1]-1; i>=0; i--) @@ -742,8 +745,10 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHANGE ) } // for i } // if _before Contour - if (_after==true) +printf("EED wxContourViewPanel::addNameWrapperToScene A\n"); + if (_showAfterContour==true) { + size=0; std::vector lstNameAfter; // Contours After int ext[6]; @@ -764,17 +769,22 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHANGE ) _sceneManager->addToScene(lstNameAfter[i], true, true, false, false, false ); } // for i } // if _after Contour +printf("EED wxContourViewPanel::addNameWrapperToScene B\n"); + } - std::vector wxContourViewPanel::getSelectedObjects(){ + std::vector wxContourViewPanel::getSelectedObjects() + { return _sceneManager->getSelectedObjects(); } - void wxContourViewPanel::RefreshInterface(){ + void wxContourViewPanel::RefreshInterface() + { getWxVtkBaseView()->Refresh(); } - vtkImageData* wxContourViewPanel::getImageData(){ + vtkImageData* wxContourViewPanel::getImageData() + { return _sceneManager->GetImageData(); } @@ -829,8 +839,13 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHANGE ) void wxContourViewPanel::onBeforeAfterContour(bool before, bool after) { - _before = before; - _after = after; + _showBeforeContour = before; + _showAfterContour = after; + } + + void wxContourViewPanel::onShowTextContour(bool show) + { + _sceneManager->SetShowTextContour( show ); } void wxContourViewPanel::GetPointsOfActualContour( std::vector *vecX, std::vector *vecY, std::vector *vecZ ) @@ -838,7 +853,8 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHANGE ) _sceneManager->GetPointsOfActualContour(vecX, vecY, vecZ); } - void wxContourViewPanel::setImageSlice(int z){ + void wxContourViewPanel::setImageSlice(int z) + { vtkInteractorStyleBaseView* stylebaseview = (vtkInteractorStyleBaseView*) _sceneManager->getWxVtkViewBase()->GetInteractorStyleBaseView(); wxVtk2DBaseView* baseview = (wxVtk2DBaseView*)stylebaseview->GetWxVtk2DBaseView(); baseview->SetActualSlice(z); diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.h b/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.h index 3e134a9..1ea6f26 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.h +++ b/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.h @@ -279,19 +279,19 @@ class wxContourViewPanel : public wxPanel * Gets the vertical concept name * @return _verticalConcept The name of the concept for setting at the vertical bar */ - std::string getVerticalConceptName( ); + std::string getVerticalConceptName( ); //------------------------------------------------------------------------------------------------------------ // Other functional methods //------------------------------------------------------------------------------------------------------------ - void getSpacing( double * spacing ); - wxVtkBaseView* getWxVtkBaseView(); - double getCurrentDeep(); - void SetVisibleAxis(bool ok); - int GetX(); - int GetY(); - int GetZ(); - void SetXY(int x, int y); - void Refresh(); + void getSpacing( double * spacing ); + wxVtkBaseView* getWxVtkBaseView(); + double getCurrentDeep(); + void SetVisibleAxis(bool ok); + int GetX(); + int GetY(); + int GetZ(); + void SetXY(int x, int y); + void Refresh(); //this method should be deleted @@ -321,6 +321,7 @@ class wxContourViewPanel : public wxPanel int getWindowLevel(); void onBrigthnessColorWindowLevel(int colorwindow,int windowlevel); void onInterpolation(bool interpolate); + void onShowTextContour(bool show); void onBeforeAfterContour(bool before, bool after); void GetPointsOfActualContour( std::vector *vecX, std::vector *vecY, std::vector *vecZ ); void changeImage(vtkImageData* img); @@ -358,8 +359,8 @@ private: bool _useHorizontalBar; wxEvtHandler *_eventHandler; - bool _before; - bool _after; + bool _showBeforeContour; + bool _showAfterContour; //EED diff --git a/lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.cxx b/lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.cxx index d70557f..7d9c22c 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.cxx @@ -79,6 +79,7 @@ DEFINE_EVENT_TYPE( wxEVT_CHANGED_DEEP ) _waiting = false; _creatingROI = false; _drawingSelectionROI = false; + _showTextContour = true; SetWidthContour(1.0); _wxVtk_BaseView = theWxBaseViewToManage; if( _wxVtk_BaseView!=NULL ) @@ -88,6 +89,7 @@ DEFINE_EVENT_TYPE( wxEVT_CHANGED_DEEP ) SetVtkInteractorStyleBaseView( theInteractorStyleBaseView ); } configureSelectionROI( spc ); + configureTextNumberOfContour(); } //------------------------------------------------------------------------------------------------------------ @@ -237,9 +239,9 @@ DEFINE_EVENT_TYPE( wxEVT_CHANGED_DEEP ) manViewerContour->RefreshContour(); addToScene( theKeyName ); } - //------------------------------------------------------------------------------------------------------------ - void wxVtkBaseView_SceneManager :: configureSelectionROI( double * spc ) - { +//------------------------------------------------------------------------------------------------------------ +void wxVtkBaseView_SceneManager :: configureSelectionROI( double * spc ) +{ _controlerSelectionROI = new manualRoiControler(); _viewerSelectionROI = new manualViewRoi(); _modelSelectionROI = new manualContourModel(); @@ -255,10 +257,34 @@ DEFINE_EVENT_TYPE( wxEVT_CHANGED_DEEP ) _controlerSelectionROI->SetModelView( _modelSelectionROI , _viewerSelectionROI ); ((vtkInteractorStyleBaseView*)_wxVtk_BaseView->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _controlerSelectionROI ); _controlerSelectionROI->SetActive(false); - } +} - //------------------------------------------------------------------------------------------------------------ - ContourWrap_ViewControl * wxVtkBaseView_SceneManager :: insertWrap( std::string theKeyName, manualContourBaseControler * manContourControl, manualViewBaseContour * manViewerContour ) +//------------------------------------------------------------------------------------------------------------ +void wxVtkBaseView_SceneManager::configureTextNumberOfContour() +{ + // Text Window Level + vtkTextActor *textActor = vtkTextActor::New(); + textActor->SetDisplayPosition(10, 85); + textActor->SetInput("contours:--"); + // Set coordinates to match the old vtkScaledTextActor default value + textActor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport(); + textActor->GetPosition2Coordinate()->SetValue( 0.2 , 0.2 ); + vtkTextProperty *tprop = textActor->GetTextProperty(); + tprop->SetFontSize(14); + tprop->SetFontFamilyToArial(); + tprop->SetColor(1, 1, 0); + _wxVtk_BaseView->GetRenderer()->AddActor2D(textActor); + _numberOfContoursTextActor=textActor; +} + +//------------------------------------------------------------------------------------------------------------ +void wxVtkBaseView_SceneManager::SetLabelNumberOfContours( std::string label ) +{ + _numberOfContoursTextActor->SetInput( label.c_str() ); +} + +//------------------------------------------------------------------------------------------------------------ +ContourWrap_ViewControl * wxVtkBaseView_SceneManager :: insertWrap( std::string theKeyName, manualContourBaseControler * manContourControl, manualViewBaseContour * manViewerContour ) { ContourWrap_ViewControl * newContourWrap = new ContourWrap_ViewControl(manContourControl, manViewerContour); if(_contours_ViewControl == NULL) @@ -522,30 +548,34 @@ DEFINE_EVENT_TYPE( wxEVT_CHANGED_DEEP ) if( !append ) { removeSceneContours(); - } + } // if !append + _sceneContours_ViewControl->insert(std::pair ( theKeyName, contourWRP ) ); - if ( visualization ) + + if ( visualization==true ) { contourWRP->getViewer()->AddCompleteContourActor( ifShowCtrlPoints ); - } + } // if visualization - if( control ) + if( control==true ) { ((vtkInteractorStyleBaseView*)_wxVtk_BaseView->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( contourWRP->getControler() ); - } + } // if contour if( !control ) { contourWRP->getViewer()->SetColorNormalContour(1,0,0); } else { contourWRP->getViewer()->SetColorNormalContour(0,0,1); - } + } // if !contour - if( ifActive ) + if( ifActive==true ) { contourWRP->getControler()->SetActive( true ); contourWRP->getViewer()->RemoveTextActor(); - } + } // if ifActive + + contourWRP->getViewer()->SetShowText(_showTextContour); } //------------------------------------------------------------------------------------------------------------ @@ -1241,6 +1271,11 @@ DEFINE_EVENT_TYPE( wxEVT_CHANGED_DEEP ) } // if } + void wxVtkBaseView_SceneManager::SetShowTextContour(bool show) + { + _showTextContour = show; + } + bool wxVtkBaseView_SceneManager::isEditableCControler(std::string theKeyName){ ContourWrap_ViewControl* ccon = getContourWrap_ViewControlOf(theKeyName); diff --git a/lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.h b/lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.h index ecc6a51..219962f 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.h +++ b/lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.h @@ -210,6 +210,7 @@ class wxVtkBaseView_SceneManager : public InteractorStyleMaracas { int GetImageDataSizeZ(); void GetImageDataRange( double *range ); void SetWidthContour(double width); + void SetShowTextContour(bool show); //JCP 21 - 09 - 08 bool isEditableCControler(std::string theKeyName); @@ -217,10 +218,14 @@ class wxVtkBaseView_SceneManager : public InteractorStyleMaracas { bool isCtrlPressed(); bool isShiftPressed(); char getLastKeyCode(); + + void SetLabelNumberOfContours( std::string label ); + private: //------------------------------------------------------------------------------------------------------------ // Private methods //------------------------------------------------------------------------------------------------------------ + void configureTextNumberOfContour(); //------------------------------------------------------------------------------------------------------------ @@ -260,6 +265,8 @@ private: double _widthOfControlPoint; bool _ctrlKey; bool _shiftKey; + bool _showTextContour; + vtkTextActor *_numberOfContoursTextActor; }; #endif // __wxVtkBaseView_SceneManager_HEADER_FILE__