X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FInterface_ManagerContour_NDimensions%2FwxContourViewPanel.cxx;h=85952db7722110586daf1ed22d76099a95e6f558;hb=refs%2Fheads%2Fvtk8itk4wx3-mingw64;hp=a470eba60ab0bed5d8226838c42a8b8b1587532d;hpb=8ba77b9cce93770de811bdac8a8341bcb10f036a;p=creaContours.git diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx b/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx index a470eba..85952db 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx @@ -1,3 +1,28 @@ +/*# --------------------------------------------------------------------- +# +# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image +# pour la Sant�) +# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton +# Previous Authors : Laurent Guigues, Jean-Pierre Roux +# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil +# +# This software is governed by the CeCILL-B license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL-B +# license as circulated by CEA, CNRS and INRIA at the following URL +# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +# or in the file LICENSE.txt. +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL-B license and that you accept its terms. +# ------------------------------------------------------------------------ */ + //---------------------------------------------------------------------------------------------------------------- // Class definition include @@ -27,98 +52,49 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHANGE ) //------------------------------------------------------------------------------------------------------------ // Constructors & Destructors //------------------------------------------------------------------------------------------------------------ - /*{ - - showingVID = theShowingImage; - int gapH = 20; - int gapV = 10; - createHorizontalBar(1,80); - createVerticalBar(1,200); - createViewPanel(); - - wxFlexGridSizer * panelSizer = new wxFlexGridSizer(3,1,0,0); - panelSizer->AddSpacer(gapV); - panelSizer -> AddGrowableCol(1); - panelSizer->Add(theViewPanel, 1, wxEXPAND); - panelSizer->AddSpacer(gapV); - - wxFlexGridSizer * downSizer = new wxFlexGridSizer(1,3,gapV,gapH); - downSizer->Add(_verticalBar, 1, wxEXPAND); - //downSizer->AddSpacer(gapH); - downSizer -> AddGrowableCol(1); - downSizer->Add(panelSizer, 1, wxEXPAND|wxALL|wxCENTER); - //downSizer->AddSpacer(gapH); - outSizer = new wxFlexGridSizer(3,1,1,1); - outSizer->Add(_horizontalBar, 1, wxEXPAND); - outSizer -> AddGrowableRow(1); - outSizer -> AddGrowableCol(1); - outSizer->Add(downSizer, 1, wxEXPAND); - - _horizontalBar->setDeviceBlitStart( _verticalBar->GetWidth() + gapH, gapV); - _horizontalBar->setDeviceEndMargin( gapH+10 ); - - //Connecting the events to the horizontal bar - Connect(_horizontalBar->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onBarrange_Horizontal ); - Connect(_horizontalBar->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onActualChange_Bar_Horizontal ); - Connect(_horizontalBar->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onStartChange_Bar_Horizontal ); - Connect(_horizontalBar->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onEndChange_Bar_Horizontal ); - Connect(_horizontalBar->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onSelectionEnd_Horizontal ); - Connect(_horizontalBar->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onMovedBar_Horizontal ); - - //Connecting the events to the vertical bar - Connect(_verticalBar->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onBarrange_Vertical ); - Connect(_verticalBar->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onActualChange_Bar_Vertical ); - Connect(_verticalBar->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onStartChange_Bar_Vertical ); - Connect(_verticalBar->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onEndChange_Bar_Vertical ); - Connect(_verticalBar->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onSelectionEnd_Vertical ); - Connect(_verticalBar->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onMovedBar_Vertical ); - - - this->SetAutoLayout( true ); - SetSizer( outSizer ); - this->Layout(); - - SetSize(900,700); - theViewPanel->SetSize(800,600); - theViewPanel->GetWindow(1)->SetSize(800,600); - - outSizer->Fit( this ); - SetBackgroundColour(wxColour(255,0,0)); - - }*/ //:wxScrolledWindow(parent, -1, pos, size, style) - wxContourViewPanel :: wxContourViewPanel ( vtkImageData * theShowingImage, wxWindow *parent, const wxPoint& pos, const wxSize& size,long style, int vertStart, int vertEnd, int horzStart, int horzEnd ) + wxContourViewPanel::wxContourViewPanel ( vtkImageData * theShowingImage, wxWindow *parent, const wxPoint& pos, const wxSize& size,long style, int vertStart, int vertEnd, int horzStart, int horzEnd ) :wxPanel(parent, -1, pos, size, style) { theShowingImage->GetSpacing(last_spacing); - showingVID = theShowingImage; - int gapH = 20; - int gapV = 10; - _verticalConceptName = ""; - _horizontalConceptName = ""; + showingVID = theShowingImage; + _showBeforeContour = false; + _showAfterContour = false; + int gapH = 20; + int gapV = 10; + _verticalConceptName = ""; + _horizontalConceptName = ""; createHorizontalBar(1,80); createVerticalBar(1,200); createViewPanel(); - _eventHandler = NULL; - - wxFlexGridSizer * panelSizer = new wxFlexGridSizer(1, 4, gapV, gapH); + _eventHandler = NULL; + wxFlexGridSizer * panelSizer = new wxFlexGridSizer(1,4, gapV, gapH); +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 panelSizer -> AddGrowableCol(2); panelSizer -> AddGrowableRow(2); - panelSizer->Add(_verticalBar, 1, wxGROW); +#else + panelSizer -> AddGrowableRow(0,1); + panelSizer -> AddGrowableCol(2,1); +#endif + panelSizer->Add(_verticalBar, 0, wxEXPAND); panelSizer->AddSpacer(gapV); - panelSizer->Add(theViewPanel, 1, wxGROW); + panelSizer->Add(theViewPanel, 1, wxEXPAND); panelSizer->AddSpacer(gapV); - outSizer = new wxFlexGridSizer(3, 1, gapH, gapV); +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 outSizer -> AddGrowableCol(1); outSizer -> AddGrowableRow(1); - outSizer->Add( _horizontalBar, 1, wxGROW); - outSizer->Add( panelSizer, 1, wxGROW); +#else + outSizer -> AddGrowableRow(1,1); + outSizer -> AddGrowableCol(0,1); +#endif + outSizer->Add( _horizontalBar, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT|wxTOP); + outSizer->Add( panelSizer, 1, wxEXPAND); outSizer->AddSpacer(gapH); - _horizontalBar->setDeviceBlitStart( _verticalBar->GetWidth() + 2*gapH, gapV); _horizontalBar->setDeviceEndMargin( 2*gapH+10 ); - //Connecting the events to the horizontal bar Connect(_horizontalBar->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onBarrange_Horizontal ); Connect(_horizontalBar->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onActualChange_Bar_Horizontal ); @@ -134,18 +110,13 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHANGE ) Connect(_verticalBar->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onEndChange_Bar_Vertical ); Connect(_verticalBar->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onSelectionEnd_Vertical ); Connect(_verticalBar->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onMovedBar_Vertical ); - - this->SetSizer( outSizer ); this->SetAutoLayout( true ); this->Layout(); - //SetSize(1900,1900); //theViewPanel->SetSize(800,600); //theViewPanel->GetWindow(1)->SetSize(800,600); - //outSizer->Fit( this ); - initializeScenceManager(); } @@ -155,25 +126,23 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHANGE ) delete _sceneManager; } - void wxContourViewPanel::initializeScenceManager(){ - + void wxContourViewPanel::initializeScenceManager() + { //_theViewPanel = theViewPanel; //_theViewPanel->setWxEventHandler( this ); - double spc[3]; this->getSpacing(spc); _sceneManager = new wxVtkBaseView_SceneManager ( this->getWxVtkBaseView(), this, spc ); - Connect( this->GetId(), wxINSTANT_CHANGE, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onChangeInstant ); Connect( wxID_ANY, wxEVT_START_CREATE_MULT_ROI, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onCreateMultipleROI ); Connect( wxID_ANY, wxEVT_START_CREATE_ROI, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onCreateROI ); Connect( wxID_ANY, wxEVT_STOP_CREATE_ROI, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onStopCreateROI ); Connect( wxID_ANY, wxEVT_CHANGED_DEEP, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onChangedDeep ); - Connect( wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourViewPanel :: onActionButtonPressed ); - + Connect( wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourViewPanel :: onActionButtonPressed ); } - wxVtkBaseView_SceneManager* wxContourViewPanel::getSceneManager(){ + wxVtkBaseView_SceneManager* wxContourViewPanel::getSceneManager() + { return _sceneManager; } @@ -257,6 +226,13 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHANGE ) return GetwxVtkMPR2DView()->GetVtkmprbasedata()->GetZ(); } + //------------------------------------------------------------------------------------------------------------ + void wxContourViewPanel::SetXY(int x, int y) + { + GetwxVtkMPR2DView()->GetVtkmprbasedata()->SetX(x); + GetwxVtkMPR2DView()->GetVtkmprbasedata()->SetY(y); + } + //------------------------------------------------------------------------------------------------------------ void wxContourViewPanel::Refresh() { @@ -729,27 +705,83 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHANGE ) } } - void wxContourViewPanel::removeSceneContours(){ + void wxContourViewPanel::removeSceneContours() + { _sceneManager->removeSceneContours(); } - void wxContourViewPanel::addNameWrapperToScene(){ - int size = wxContourMainFrame::getInstance()->getNamesWrappingSize(); - for(int i = 0; i < size;i++){ + void wxContourViewPanel::addNameWrapperToScene() + { + int i,size = wxContourMainFrame::getInstance()->getNamesWrappingSize(); + for(i = 0; i < size;i++) + { std::string name = wxContourMainFrame::getInstance()->getNameWrapping(i); _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 (_showBeforeContour==true) + { + size=0; + std::vector lstNameBefor; + // Contours Befor + for (i=tempVector[1]-1; i>=0; i--) + { + lstNameBefor = wxContourMainFrame::getInstance()->getOutlinesName( i ); + size = lstNameBefor.size(); + if (size!=0) + { + i=-1; + } //if size + } // for + for(i = 0; i < size;i++) + { + // ctrol active showCtr + _sceneManager->addToScene(lstNameBefor[i], true, true, false, false, false ); + } // for i + } // if _before Contour + + if (_showAfterContour==true) + { + size=0; + std::vector lstNameAfter; + // Contours After + int ext[6]; + getImageData()->GetExtent(ext); + int dimZ=ext[5]-ext[4]+1; + for (i=tempVector[1]+1; igetOutlinesName( i ); + size = lstNameAfter.size(); + if (size!=0) + { + i=dimZ; + } //if size + } // for + for(i = 0; i < size;i++) + { + // ctrol active showCtr + _sceneManager->addToScene(lstNameAfter[i], true, true, false, false, false ); + } // for i + } // if _after Contour } - 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(); } @@ -792,21 +824,25 @@ 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(); + wxvtk2dbaseview->SetInterpolate( interpolate ); + } - if (interpolate){ - imageviewer->GetImageActor()->InterpolateOn(); - } else { - imageviewer->GetImageActor()->InterpolateOff(); - } + void wxContourViewPanel::onBeforeAfterContour(bool before, bool 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 ) @@ -814,7 +850,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);