From: donadio Date: Mon, 16 Mar 2009 15:11:26 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: EED.02Oct2009~63 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=2e4190247854f254d184bbccf1f3ffa1d12d773c;p=creaContours.git *** empty log message *** --- diff --git a/lib/Interface_Icons_NDimensions/interfMainPanel.cxx b/lib/Interface_Icons_NDimensions/interfMainPanel.cxx index d5a9e52..7d43990 100644 --- a/lib/Interface_Icons_NDimensions/interfMainPanel.cxx +++ b/lib/Interface_Icons_NDimensions/interfMainPanel.cxx @@ -703,4 +703,6 @@ void interfMainPanel::onMirrorPressed(){ } showPanel(mirrorPanel); //hideAxis(); + + wxContourMainFrame::getInstance()->referenceLine(); } diff --git a/lib/Interface_Icons_NDimensions/interfSegmentationPanels.cxx b/lib/Interface_Icons_NDimensions/interfSegmentationPanels.cxx index cc424a5..a9cd147 100644 --- a/lib/Interface_Icons_NDimensions/interfSegmentationPanels.cxx +++ b/lib/Interface_Icons_NDimensions/interfSegmentationPanels.cxx @@ -103,8 +103,8 @@ void interfSegmentationPanelVTK::onSegmentationOneSlice( wxCommandEvent& event ) { - int isovalue = _isovalue->GetValue(); - int sampling = _sampling->GetValue(); + int isovalue = _isovalue->GetValue(); + int sampling = _sampling->GetValue(); int method = methodRadiobox->GetSelection(); interfMainPanel::getInstance()->onSegmentationOneSlice(isovalue, sampling, method); diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx index 42ba17c..335d165 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx @@ -682,12 +682,58 @@ void wxContourMainFrame::onRedo(){ } } -void wxContourMainFrame :: createCopyContourOf ( std::string anExistingKName, std::vector &instantNoTouchData, bool append ){ +void wxContourMainFrame :: createCopyContourOf ( std::string anExistingKName, std::vector &instantNoTouchData, bool append ) +{ std::string cloneName = kernelManager->createCopyContourOf( anExistingKName, instantNoTouchData ); manualContourModel * manualModel = kernelManager->getOutlineByKeyName(cloneName);//_modelManager->getOutlineByKeyName( cloneName )->getModel(); _theViewPanel->getSceneManager()->createCopyContourOf( anExistingKName, cloneName, manualModel , append ); } +///AD: 03-09 Copy the object and apply the given transformation +void wxContourMainFrame :: createMirrorContourOf ( std::string anExistingKName, std::vector &instantNoTouchData, bool append ) +{ + std::string cloneName = kernelManager->createCopyContourOf( anExistingKName, instantNoTouchData ); + manualContourModel * manualModel = kernelManager->getOutlineByKeyName(cloneName); + manualContourModel * refModel = kernelManager->getOutlineByKeyName(_refName); + + manualPoint * refPoint1 = refModel->GetManualPoint(0); + manualPoint * refPoint2 = refModel->GetManualPoint(1); + + double pnt1X = refPoint1->GetX(); + double pnt1Y = refPoint1->GetY(); + double pnt2X = refPoint2->GetX(); + double pnt2Y = refPoint2->GetY(); + double angle = (atan2(pnt2Y - pnt1Y, pnt2X - pnt1X) * 180 / 3.1415926535897932384626433832795)+90; +printf("ang=%f\n",angle); + vtkTransform *t = vtkTransform::New(); + + t->PostMultiply(); + t->Identity(); + t->Translate(-pnt1X, -pnt1Y, 0); + t->RotateZ(-angle); + t->Scale(-1,1,1); + t->RotateZ(angle); + t->Translate(pnt1X, pnt1Y, 0); + t->Update(); + + int i,size=manualModel->GetSizeLstPoints(); + for (i=0;iGetManualPoint(i); + float vecIn[3]; + float vecOut[3]; + vecIn[0]=mp->GetX(); + vecIn[1]=mp->GetY(); + vecIn[2]=mp->GetZ(); + t->TransformPoint( vecIn, vecOut ); + mp->SetPointX( vecOut[0] ); + mp->SetPointY( vecOut[1] ); + mp->SetPointZ( vecOut[2] ); + } + + _theViewPanel->getSceneManager()->createCopyContourOf( anExistingKName, cloneName, manualModel , append ); +} + void wxContourMainFrame ::loadState(std::string filename){ char tmp[255]; FILE *pFile=fopen(filename.c_str(),"r+"); @@ -1077,17 +1123,119 @@ void wxContourMainFrame::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,i RefreshInterface(); } + +//Creates a reference line to be used as the axis of the mirroring +void wxContourMainFrame::referenceLine() +{ +/* + wxBusyCursor wait; + double spc[3]; + + vtkImageData *vtkimagedata = _theViewPanel->getImageData(); + vtkimagedata->UpdateInformation(); + vtkimagedata->SetUpdateExtent(vtkimagedata->GetWholeExtent()); + vtkimagedata->Update(); + vtkImageData _data = vtkimagedata; + _data->GetSpacing(spc); + //_vtkbasedata_1 = new vtkBaseData(); + //_vtkbasedata_1->SetMarImageData(marimagedata); + //_imageviewer2D_1->SetVtkBaseData( _vtkbasedata_1 ); + //_imageviewer2D_1->Configure(); + + + // Contorno 1 + manualContourControler _manContourControl_1 = new manualContourControler(); + manualContourModel _mContourModel_1 = new manualContourModel(); + manualViewContour _mViewContour_1 = new manualViewContour(); + _mViewContour_1->SetModel( _mContourModel_1 ); +// _mViewContour_1->SetWxVtkBaseView( _imageviewer2D_1 ); + _mViewContour_1->SetRange( 2 ); + _mViewContour_1->SetZ( 1200 ); + + +//EED 3 oct 2006 + _mViewContour_1->SetSpacing(spc); + + +//EED 3 oct 2006 + _mViewContour_1->SetColorNormalContour(0, 0, 1); + _mViewContour_1->SetColorEditContour(0, 0.5, 0.5); + + _manContourControl_1->SetModelView( _mContourModel_1 , _mViewContour_1 ); +// _imageviewer2D_1->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _manContourControl_1 ); + _manContourControl_1->CreateNewManualContour(); + _manContourControl_1->SetActive(false); + _mViewContour_1->RefreshContour(); + + // Rectangulo +// _manRoiControl = new manualRoiControler(); +// _mContourModel = new manualContourModel(); +// _mViewRoi = new manualViewRoi(); + _mViewRoi->SetModel( _mContourModel ); + _mViewRoi->SetWxVtkBaseView( _imageviewer2D_1 ); + _mViewRoi->SetRange( 2 ); + _mViewRoi->SetZ( 1200 ); + +//EED 3 oct 2006 + _mViewRoi->SetSpacing(spc); + +// _manRoiControl->SetModelView( _mContourModel , _mViewRoi ); +// _imageviewer2D_1->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _manRoiControl ); +// _manRoiControl->CreateNewManualContour(); +// _manRoiControl->SetActive(true); +// _mViewRoi->RefreshContour(); + +CreateNewPoint( 0,0); + + Refresh(); + +*/ + + + + + + //Crea una linea de referencia + manualContourModel * refLine = kernelManager->factoryManualContourModel(6); + + std::vector instantVector; + _instantPanel->getInstant( instantVector ); + std::string nameLine = kernelManager->createOutline(refLine, instantVector); + bool addedModel = nameLine.compare("") != 0; + if( addedModel ) + { + double spc[3]; + _theViewPanel->getSpacing(spc); + _theViewPanel->getSceneManager()->configureViewControlTo( nameLine, refLine,spc , 6); + } + + _refName = nameLine; + +} + + void wxContourMainFrame::onMirror() { - //AD:02-09 + //AD:02-09 std::vector currentSelection = _theViewPanel->getSelectedObjects(); + std::vector filterCurrentSelection; + + std::vector::iterator iter; + for (iter=currentSelection.begin(); iter!=currentSelection.end(); ++iter) + { + //Diferente de la linea de referencia + if ((_refName.compare(*iter))!=0) + { + filterCurrentSelection.push_back(*iter); + } + } std::vector tempVector; _instantPanel->getInstant( tempVector ); _performingOperation->reset(); _performingOperation->setStartCommand( COPY ); _performingOperation->setStartOperationInstantVector( tempVector ); - _performingOperation->setKeyNamesOperationElems( currentSelection ); + _performingOperation->setKeyNamesOperationElems( filterCurrentSelection ); //AD:02-09 char theStartCommand = _performingOperation->getStartCommand(); @@ -1103,9 +1251,12 @@ void wxContourMainFrame::onMirror() int i,size = elems.size(); for( i=0; i0 ); + createMirrorContourOf( elems[i], tempVector, i>0 ); } } + + deleteContour( _refName ); + _refName = ""; } void wxContourMainFrame::showAxis(bool show){ diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h index 9a38a68..c9c3456 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h +++ b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h @@ -72,6 +72,7 @@ #include "vtkImageReslice.h" #include "vtkMetaImageWriter.h" #include "vtkImageData.h" +#include "vtkTransform.h" //#include "vtkMetaImageReader.h" //------------------------------------------------------------------------------------------------------------ @@ -201,6 +202,7 @@ class wxContourMainFrame : public wxPanel { void onUndo(); void onRedo(); void createCopyContourOf ( std::string anExistingKName, std::vector &instantNoTouchData, bool append ); + void createMirrorContourOf ( std::string anExistingKName, std::vector &instantNoTouchData, bool append ); ///////////////////////7 void onLoad(); void onSave(); @@ -223,6 +225,10 @@ class wxContourMainFrame : public wxPanel { void onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method); + //AD + void referenceLine(); + + //AD void onMirror(); void showAxis(bool show); @@ -280,6 +286,9 @@ private: wxInstantChooserPanel * _instantPanel; + //AD + std::string _refName; + wxAuiManager m_mgr; /* diff --git a/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx b/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx index 2070e44..2a1586c 100644 --- a/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx +++ b/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx @@ -200,7 +200,8 @@ void KernelManagerContour::setInstant(std::vector vectInstant){ modelManager->setInstant(act); } -std::string KernelManagerContour::createCopyContourOf ( std::string anExistingKName, std::vector &instantNoTouchData){ +std::string KernelManagerContour::createCopyContourOf ( std::string anExistingKName, std::vector &instantNoTouchData) +{ return modelManager->createCopyContourOf(anExistingKName, instantNoTouchData); } manualContourModel* KernelManagerContour::getOutlineByKeyName(std::string cloneName){