31 #include "wxVtk2DBaseView.h"
48 DEFINE_EVENT_TYPE( wxEVT_START_CREATE_MULT_ROI )
49 DEFINE_EVENT_TYPE( wxEVT_STOP_CREATE_MULT_ROI )
50 DEFINE_EVENT_TYPE( wxEVT_START_CREATE_ROI )
51 DEFINE_EVENT_TYPE( wxEVT_STOP_CREATE_ROI )
52 DEFINE_EVENT_TYPE( wxEVT_DELETE_ROI )
53 DEFINE_EVENT_TYPE( wxEVT_SELECTED_MULT_ROI )
54 DEFINE_EVENT_TYPE( wxEVT_SELECTED_ROI )
55 DEFINE_EVENT_TYPE( wxEVT_UNSLECTED_ROI )
56 DEFINE_EVENT_TYPE( wxEVT_MANUAL_HIDED_ROI )
57 DEFINE_EVENT_TYPE( wxEVT_MANUAL_SHOWED_ROI )
58 DEFINE_EVENT_TYPE( wxEVT_EDITING_ROI )
59 DEFINE_EVENT_TYPE( wxEVT_MOVING_ROI )
60 DEFINE_EVENT_TYPE( wxEVT_MOVING_ROI_POINT )
61 DEFINE_EVENT_TYPE( wxEVT_SELECTED_ROI_POINT )
62 DEFINE_EVENT_TYPE( wxEVT_UNSELECTED_ROI_POINT )
63 DEFINE_EVENT_TYPE( wxEVT_CHANGED_DEEP )
69 _lastInteraction = NULL;
70 _lastInteractionName =
"";
71 _eventHandler = theEventHandler;
75 _contours_ViewControl =
new std::map< std::string, ContourWrap_ViewControl * >();
76 _sceneContours_ViewControl =
new std::map< std::string, ContourWrap_ViewControl * >();
77 _workingGroup =
new std::map< std::string, ContourWrap_ViewControl * >();
79 _creatingMULT_ROI =
false;
81 _toIncludeAtInteractionGroup =
false;
84 _drawingSelectionROI =
false;
87 _wxVtk_BaseView = theWxBaseViewToManage;
88 if( _wxVtk_BaseView!=NULL )
90 vtkInteractorStyleBaseView* theInteractorStyleBaseView = (vtkInteractorStyleBaseView*)_wxVtk_BaseView->GetInteractorStyleBaseView();
91 theInteractorStyleBaseView->AddInteractorStyleMaracas(
this );
92 SetVtkInteractorStyleBaseView( theInteractorStyleBaseView );
94 configureSelectionROI( spc );
101 for (
int i = 0; i<size; iter++ )
126 wxCommandEvent cevent( theEventType );
127 cevent.SetString( wxString( text.c_str(), wxConvUTF8) );
162 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
166 manualContourBaseControler *manContourControl;
167 manualViewBaseContour *manViewerContour;
173 manContourControl =
new manualContourControler();
174 manViewerContour =
new manualViewContour();
179 manContourControl =
new manualRoiControler();
180 manViewerContour =
new manualViewRoi();
185 manContourControl =
new manualCircleControler();
186 manViewerContour =
new manualViewCircle();
191 manContourControl =
new manualRoiControler();
192 manViewerContour =
new manualViewBullEye();
197 manContourControl =
new manualLineControler();
198 manViewerContour =
new manualViewLine();
204 manContourControl =
new manualContourControler();
205 manViewerContour =
new manualViewPoints();
211 manContourControl =
new manualContourControler();
212 manViewerContour =
new manualViewContour();
221 manViewerContour->SetModel( manModelContour );
224 manViewerContour->SetZ( -900 );
226 manViewerContour->SetSpacing(spc);
228 manViewerContour->SetColorNormalContour(0, 0, 1);
229 manViewerContour->SetColorEditContour(0.5, 0.5, 0.5);
230 manViewerContour->SetColorSelectContour(1, 0.8, 0);
233 manContourControl->SetModelView( manModelContour , manViewerContour );
234 manContourControl->Configure();
235 int i,sizeLstPoints = manModelContour->GetSizeLstPoints();
236 for ( i=0; i<sizeLstPoints; i++ )
238 manViewerContour->AddPoint();
241 manContourControl->CreateNewManualContour();
242 manViewerContour->RefreshContour();
273 _contours_ViewControl->insert(std::pair <std::string, ContourWrap_ViewControl *> ( theKeyName, newContourWrap ));
274 return newContourWrap;
284 std::map<std::string, ContourWrap_ViewControl *> :: iterator iter;
290 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
291 this->_vtkInteractorStyleBaseView->EvaluateToRefresh();
296 std::map<std::string, ContourWrap_ViewControl *> :: iterator iter;
304 std::map<std::string, ContourWrap_ViewControl *> :: iterator iter;
305 iter = theMap->find( theName );
382 std::map <std::string, ContourWrap_ViewControl *>::iterator iter;
387 manualBaseModel *cModule = manualModel;
388 manualViewBaseContour *cViewer = iter->second->getViewer()->Clone();
389 manualContourBaseControler *cControl = iter->second->getControler()->Clone( );
391 cViewer->SetModel(cModule);
392 cControl->SetModelView( cModule , cViewer );
393 cControl->CreateNewManualContour();
394 cControl->SetActive(
true );
395 cControl->SetEditable(
false );
397 cViewer->RefreshContour();
399 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
400 this->_vtkInteractorStyleBaseView->EvaluateToRefresh();
418 ((vtkInteractorStyleBaseView*)
_wxVtk_BaseView->GetInteractorStyleBaseView())->RemoveInteractorStyleMaracas( contourWRP->
getControler() );
423 if ( !visualization && control )
425 contourWRP->
getViewer()->RemoveControlPoints( );
426 contourWRP->
getViewer()->RemoveTextActor( );
430 contourWRP->
getViewer()->RemoveCompleteContourActor();
438 std::map<std::string, ContourWrap_ViewControl *> :: iterator iter;
452 std::vector<std::string> lstContoursNameActualSlice;
455 for ( i = 0; i<size; i++ )
457 lstContoursNameActualSlice.push_back( iter->first );
460 return lstContoursNameActualSlice;
468 for (
int i = 0; i<size; i++ )
483 manualViewBaseContour * cViewer;
484 manualContourBaseControler * cControler;
486 std::map <std::string, ContourWrap_ViewControl *>::iterator iter;
491 cControler = iter->second->getControler();
492 cViewer = iter->second->getViewer();
511 addToScene( theKeyName, contourWRP,
true, visualization, control, ifActive, ifShowCtrlPoints);
524 contourWRP->
getViewer()->AddCompleteContourActor( ifShowCtrlPoints );
529 ((vtkInteractorStyleBaseView*)
_wxVtk_BaseView->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( contourWRP->
getControler() );
534 contourWRP->
getViewer()->RemoveTextActor();
541 int i, size = theKeyNameVector.size();
542 for( i=0; i< size; i++ )
551 int i, size = theKeyNameVector.size();
552 for( i=0; i< size; i++ )
554 addToScene( theKeyNameVector[i], append, visualization, control, ifActive, ifShowCtrlPoints );
574 contourWRP->
getControler()->SetActive( stateCondition );
583 if ( contourWRP!=NULL )
590 std::vector< std::string > selectedObjects;
591 std::map <std::string, ContourWrap_ViewControl *>::iterator iter =
_workingGroup->begin();
593 for (
int i = 0; i<size; i++ )
596 selectedObjects.push_back( iter->first);
600 return selectedObjects;
632 std::map <std::string, ContourWrap_ViewControl *>::iterator iter = theMap->begin();
634 for (
int i = 0; i<size; i++ )
636 manualViewBaseContour * viewer = iter->second->getViewer();
638 viewer->SetSelected(
true );
649 int i, size = theKeyNameVector.size();
650 for( i=0; i< size; i++ )
659 std::map<std::string, ContourWrap_ViewControl *>::iterator iter = theMap->begin();
660 int i, size = theMap->size();
661 for( i=0; i< size; i++ )
695 _ctrlKey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey() == 1;
696 _shiftKey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey() == 1;
698 _lastKeyCode = _vtkInteractorStyleBaseView->GetInteractor()-> GetKeyCode();
700 wxCommandEvent cevent( wxEVT_COMMAND_BUTTON_CLICKED );
752 bool condition =
true;
754 wxVTKRenderWindowInteractor *_wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
755 _wxVTKiren->GetEventPosition( X , Y );
757 bool ctrlKey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey() == 1;
783 bool foundOne =
false;
786 manualViewBaseContour * viewer = NULL;
789 bool singleMoving =
true;
791 if( selectionSize > 1 )
796 for( i =0; i<size ; i++ )
798 control = iter->second->getControler();
799 viewer = iter->second->getViewer();
800 control->SetActive(
true );
809 size = selectionSize;
823 for( i =0; i<size ; i++ )
826 viewer = iter->second->getViewer();
828 control->SetActive(
true );
830 foundOne = control->OnMouseMove();
831 foundOne &= viewer->GetPosibleSelected();
833 if ( !foundOne && singleMoving )
835 control->SetActive(
false );
837 control->SetPosibleToMove(
false );
849 viewer->UpdateColorActor();
850 control->SetPosibleToMove(
true );
873 bool condition =
false;
878 vtkRenderWindowInteractor * vtkRWInteractor = _vtkInteractorStyleBaseView->GetInteractor();
880 bool ctrlKey = vtkRWInteractor->GetControlKey() == 1;
881 bool shftKey = vtkRWInteractor->GetShiftKey() == 1;
883 if ( ctrlKey || shftKey )
935 bool condition =
false;
947 bool condition =
false;
955 bool condition =
false;
963 bool condition =
false;
975 bool condition =
false;
984 sendEnvent( wxEVT_STOP_CREATE_ROI,
"Activate");
993 control->SetActive(
false );
994 control->SetEditable(
false );
995 control->SetPosibleToMove(
false );
998 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
1008 bool condition =
false;
1016 bool condition =
false; condition =
true;
1018 _vtkInteractorStyleBaseView->OnChar();
1035 bool condition =
false;
1043 bool condition =
false;
1061 std::map<std::string, ContourWrap_ViewControl *>::iterator iter =
_workingGroup->begin();
1063 for( i=0; i< workSize; i++ )
1065 manualContourBaseControler * control = iter->second->getControler();
1066 control->SetEditable(
false );
1067 control->SetActive(
false );
1068 control->SetPosibleToMove(
false );
1069 iter->second->getViewer()->Refresh();
1080 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
1087 double minX,minY,maxX,maxY, minX_ROI,minY_ROI,maxX_ROI,maxY_ROI;
1093 manualViewBaseContour * viewer;
1094 bool insideRoi =
false;
1095 for ( i=0; i<size; i++ )
1097 viewer = iter->second->getViewer();
1098 viewer->GetMinMax( minX, minY, minZ, maxX, maxY, maxZ );
1099 insideRoi = minX >= minX_ROI && maxX <= maxX_ROI && minY_ROI && maxY <= maxY_ROI;
1102 viewer->SetSelected(
true );
1103 viewer->UpdateColorActor();
1105 _workingGroup->insert(std::pair <std::string, ContourWrap_ViewControl *> ( iter->first, iter->second ));
1115 FILE *ff = fopen(
"c:/temp/wxVtkBaseView_SceneManagerStadistics.txt",
"a+");
1116 long int start = clock();
1118 double sg = (double)(start) / (double)CLK_TCK;
1120 double sg = (double)(start) / CLOCKS_PER_SEC;
1123 wxVTKRenderWindowInteractor *wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
1124 wxVTKiren->GetEventPosition( tmpPx , tmpPy );
1125 fprintf(ff,
"::%s (x,y) = (%i, %i) t(sg): %f\n \n",method.c_str(), tmpPx, tmpPy, sg);
1133 std::map <std::string, ContourWrap_ViewControl *>::iterator iter =
_contours_ViewControl->find(nameThing);
1134 manualViewBaseContour * cViewer;
1135 manualContourBaseControler * cControler;
1153 if (currentSelection.size()>=1){
1155 manualContourBaseControler *cControler = this->
getControlerOf( currentSelection[0] );
1156 manualBaseModel *cModel = cControler->GetManualContourModel();
1157 int i,size = cModel->GetNumberOfPointsSpline();
1159 for (i=0; i<size; i++)
1161 cModel->GetSpline_i_Point(i, &x, &y, &z);
1173 return wxvtk2dbaseview->GetVtkBaseData()->GetImageData();
1181 imagedata->GetExtent(ext);
1182 int sizeZ = ext[5]-ext[4]+1;
1195 imagedata->GetExtent(ext);
1196 int sizeX = ext[1]-ext[0]+1;
1197 int sizeY = ext[3]-ext[2]+1;
1199 int sizeXYZ = sizeX*sizeY*sizeZ;
1203 unsigned short *p = (
unsigned short *)imagedata->GetScalarPointer(0,0,0);
1204 for (i=0;i<sizeXYZ;i++)
1206 if ( p[i]<range[0] ) range[0]=p[i];
1207 if ( p[i]>range[1] ) range[1]=p[i];
1216 manualViewBaseContour *cViewer;
1218 std::map <std::string, ContourWrap_ViewControl *>::iterator iter;
1224 conwraviwcont = iter->second;
1226 cViewer->SetShowText(
false );
1237 manualContourBaseControler* cControler = ccon->
getControler();
1238 if(cControler != NULL && cControler->IsEditable() ==
false){
1250 manualViewBaseContour * cViewer = ccon->
getViewer();
1251 manualContourBaseControler * cControler = ccon->
getControler();