From: Eduardo DAVILA Date: Sat, 15 Oct 2022 06:16:03 +0000 (+0200) Subject: #3493 ShowNPoints_UndoRedo X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=90d9bd3da5684acbb63cefff7b02aabd306833d3;p=creaMaracasVisu.git #3493 ShowNPoints_UndoRedo --- diff --git a/bbtk/src/bbcreaMaracasVisuShowNPoints_Reset.cxx b/bbtk/src/bbcreaMaracasVisuShowNPoints_Reset.cxx index 33c0b57..eaeb751 100644 --- a/bbtk/src/bbcreaMaracasVisuShowNPoints_Reset.cxx +++ b/bbtk/src/bbcreaMaracasVisuShowNPoints_Reset.cxx @@ -29,7 +29,7 @@ void ShowNPoints_Reset::Process() // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " <DeleteAllPoints(); + bbGetInputWidgetShowNPoints()->DeleteAllPoints_(); bbGetInputWidgetShowNPoints()->GetModelShowNPoints()->SetFirstTime(true); } //===== diff --git a/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx index f17105c..5585788 100644 --- a/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx +++ b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx @@ -32,6 +32,7 @@ void ShowNPoints_Tools::CreatePatch01() (wsp->GetModelShowNPoints()->GetLstPointsSize()==4) && (bbGetInputMesh()!=NULL ) ) { + std::vector lstIdNormal; double spc[3]; spc[0] = bbGetInputSpacing()[0]; spc[1] = bbGetInputSpacing()[1]; @@ -60,38 +61,44 @@ void ShowNPoints_Tools::CreatePatch01() p[2] = lstZ[0] + dz*s; NearestPointToMesh(points, pointLocator, spc, p,pM); wsp->InsertPoint(pM[0] ,pM[1], pM[2],""); + lstIdNormal.push_back( pointLocator->FindClosestPoint(pM) ); s=s*2; p[0] = lstX[0] + dx*s; p[1] = lstY[0] + dy*s; p[2] = lstZ[0] + dz*s; NearestPointToMesh(points, pointLocator, spc, p,pM); wsp->InsertPoint(pM[0],pM[1], pM[2],""); + lstIdNormal.push_back( pointLocator->FindClosestPoint(pM) ); // --- Group 1 --- - wsp->OnInsertCollectionAfter_(); + wsp->InsertCollectionAfter_(); p[0] = (lstX[0]+lstX[3])/2; p[1] = (lstY[0]+lstY[3])/2; p[2] = (lstZ[0]+lstZ[3])/2; NearestPointToMesh(points, pointLocator, spc, p,pM); wsp->InsertPoint(pM[0] ,pM[1], pM[2],""); + lstIdNormal.push_back( pointLocator->FindClosestPoint(pM) ); p[0] = (lstX[1]+lstX[2])/2; p[1] = (lstY[1]+lstY[2])/2; p[2] = (lstZ[1]+lstZ[2])/2; NearestPointToMesh(points, pointLocator, spc, p,pM); wsp->InsertPoint(pM[0] ,pM[1], pM[2],""); + lstIdNormal.push_back( pointLocator->FindClosestPoint(pM) ); p[0] = (lstX[0]+lstX[1]+lstX[2]+lstX[3])/4; p[1] = (lstY[0]+lstY[1]+lstY[2]+lstY[3])/4; p[2] = (lstZ[0]+lstZ[1]+lstZ[2]+lstZ[3])/4; wsp->InsertPoint(p[0] ,p[1], p[2],""); // --- Group 2 --- - wsp->OnInsertCollectionAfter_(); + wsp->InsertCollectionAfter_(); p[0] = lstX[3]; p[1] = lstY[3]; p[2] = lstZ[3]; wsp->InsertPoint(p[0] ,p[1], p[2],""); + lstIdNormal.push_back( pointLocator->FindClosestPoint(p) ); p[0] = lstX[2]; p[1] = lstY[2]; p[2] = lstZ[2]; wsp->InsertPoint(p[0] ,p[1], p[2],""); + lstIdNormal.push_back( pointLocator->FindClosestPoint(p) ); dx = lstX[2]-lstX[3]; dy = lstY[2]-lstY[3]; dz = lstZ[2]-lstZ[3]; @@ -110,6 +117,17 @@ void ShowNPoints_Tools::CreatePatch01() wsp->SetOutputBox(); pointLocator->Delete(); + + + // Check normals + 1. Recorrer las normales de lstIdNormals y calcular el promedio -> V1 + 2. Calcular el promedio de 4 normales de la nueva superficie -> V2 + 3. Calcular el angulo entre V1 y V2 + 4. Si el angulo es major de 90 Invertir las normales de la superficie actual + + + // --- Finish --- + wsp->UndoRedo_SaveCollection(); } else { printf("EED ShowNPoints_Tools::CreatePatch01 Warning patch not apply. Need juste one group with four points\n"); } // if @@ -162,7 +180,7 @@ void ShowNPoints_Tools::Process() } // if Type if (bbGetInputType()==50) { - bbGetInputWidgetShowNPoints()->DeleteAllPoints(); + bbGetInputWidgetShowNPoints()->OnDeleteAllPoints_(); } // if Type if (bbGetInputType()==100) { @@ -182,7 +200,7 @@ void ShowNPoints_Tools::Process() } // if Type if (bbGetInputType()==210) { - bbGetInputWidgetShowNPoints()->InvertLstPoints(); + bbGetInputWidgetShowNPoints()->OnInvertLstPoints_(); } // if Type } // if bbGetInputWidgetShowNPoints } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx index f31e871..ff7e623 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx @@ -515,6 +515,7 @@ void WidgetShowNPoints::OnInsertPoint_() } else {//mpoint.size printf("creaMaracasVisu::ShowNPoints (not match point) \n"); } + UndoRedo_SaveCollection(); } //------------------------------------------------------------------------ @@ -537,20 +538,19 @@ void WidgetShowNPoints::OnAddPoint_() } else {//mpoint.size printf("creaMaracasVisu::ShowNPoints (not match point) \n"); } + UndoRedo_SaveCollection(); } //------------------------------------------------------------------------ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event) { OnAddPoint_(); - UndoRedo_SaveCollection(); } //------------------------------------------------------------------------ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT { OnInsertPoint_(); - UndoRedo_SaveCollection(); } @@ -671,13 +671,13 @@ void WidgetShowNPoints::OnSetPoint_() GetViewShowNPoints()->Render(); } // if id SetOutputBox(); + UndoRedo_SaveCollection(); } //------------------------------------------------------------------------ void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event) { OnSetPoint_(); - UndoRedo_SaveCollection(); } //------------------------------------------------------------------------ @@ -780,13 +780,13 @@ void WidgetShowNPoints::StopTrackPoint( ) //renderer->GetRenderWindow()->Render(); GetViewShowNPoints()->Render(); StopTrackPoint(); + UndoRedo_SaveCollection(); } //------------------------------------------------------------------------ void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event) { OnErasePoint_(); - UndoRedo_SaveCollection(); } //------------------------------------------------------------------------ @@ -804,7 +804,7 @@ void WidgetShowNPoints::StopTrackPoint( ) } //------------------------------------------------------------------------ -void WidgetShowNPoints::DeleteAllPoints() +void WidgetShowNPoints::DeleteAllPoints_() { // EED 2022-05-19 //int id,size=lstActorsSphere.size(); @@ -815,14 +815,18 @@ void WidgetShowNPoints::DeleteAllPoints() }// for id } +void WidgetShowNPoints::OnDeleteAllPoints_() +{ + DeleteAllPoints_(); + UndoRedo_SaveCollection(); +} //------------------------------------------------------------------------ void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event) { - DeleteAllPoints(); + OnDeleteAllPoints_(); SetOutputBox(); GetViewShowNPoints()->Render(); - UndoRedo_SaveCollection(); } //NTU: Method for updating points opacity and Radio @@ -936,7 +940,7 @@ void WidgetShowNPoints::InsertCollection() } //------------------------------------------------------------------------ -void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event) +void WidgetShowNPoints::InsertCollectionBefore_() { InsertCollection(); RefreshCollectionText(); @@ -945,7 +949,22 @@ void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event) } //------------------------------------------------------------------------ -void WidgetShowNPoints::OnInsertCollectionAfter_() +void WidgetShowNPoints::OnInsertCollectionBefore_() +{ + InsertCollectionBefore_(); + UndoRedo_SaveCollection(); +} + + +//------------------------------------------------------------------------ +void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event) +{ + OnInsertCollectionBefore_(); +} + + +//------------------------------------------------------------------------ +void WidgetShowNPoints::InsertCollectionAfter_() { mActualCollection++; InsertCollection(); @@ -954,6 +973,13 @@ void WidgetShowNPoints::OnInsertCollectionAfter_() StopTrackPoint(); } +//------------------------------------------------------------------------ +void WidgetShowNPoints::OnInsertCollectionAfter_() +{ + InsertCollectionAfter_(); + UndoRedo_SaveCollection(); +} + //------------------------------------------------------------------------ void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event) { @@ -965,7 +991,7 @@ void WidgetShowNPoints::DeleteCollection_() { if ( lstModelShowNPoints.size()>1 ) { - DeleteAllPoints(); // Actual Collection + DeleteAllPoints_(); // Actual Collection lstModelShowNPoints.erase( lstModelShowNPoints.begin()+mActualCollection ); lstViewShowNPoints.erase( lstViewShowNPoints.begin()+mActualCollection ); if ( mActualCollection>=lstModelShowNPoints.size() ) @@ -973,7 +999,7 @@ void WidgetShowNPoints::DeleteCollection_() mActualCollection--; } // if } else { - DeleteAllPoints(); // Actual Collection + DeleteAllPoints_(); // Actual Collection } // if } @@ -986,17 +1012,17 @@ void WidgetShowNPoints::OnDeleteCollection_() RefreshCollectionText(); RefreshColourCollection(); StopTrackPoint(); + UndoRedo_SaveCollection(); } //------------------------------------------------------------------------ void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event) { OnDeleteCollection_(); - UndoRedo_SaveCollection(); } //------------------------------------------------------------------------ -void WidgetShowNPoints::OnResetCollections_() +void WidgetShowNPoints::ResetCollections_() { int i,size=lstModelShowNPoints.size(); for (i=0;imaxUndoRedo) { idUndoRedo=maxUndoRedo+1; } else { - OnResetCollections_(); + ResetCollections_(); OnLoadCollections_( GetUndoRedoFileName() ); idUndoRedo++; }// if idUndoRedo - - printf("EED WidgetShowNPoints::OnRedo B %d %d\n", idUndoRedo, maxUndoRedo); - } //------------------------------------------------------------------------ void WidgetShowNPoints::UndoRedo_SaveCollection() { - printf("EED \n EED WidgetShowNPoints::UndoRedo_SaveCollection %d %d\n", idUndoRedo, maxUndoRedo); OnSaveCollections_( GetUndoRedoFileName() ); maxUndoRedo = idUndoRedo; idUndoRedo++; - printf("EED WidgetShowNPoints::UndoRedo_SaveCollection %d %d\n", idUndoRedo, maxUndoRedo); } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h index a140013..a9a646b 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h @@ -33,8 +33,10 @@ class WidgetShowNPoints : public wxPanel void OnErasePoint_(); void OnErasePoint(wxCommandEvent& event); void OnEraseLastPoint(wxCommandEvent &event); + void DeleteAllPoints_(); + void OnDeleteAllPoints_(); void OnDeleteAllPoints(wxCommandEvent &event); - + void OnSavePoints(wxCommandEvent &event); void OnLoadPoints(wxCommandEvent &event); @@ -42,7 +44,10 @@ class WidgetShowNPoints : public wxPanel void UpdatePoints_(); void InsertCollection(); + void InsertCollectionBefore_(); + void OnInsertCollectionBefore_(); void OnInsertCollectionBefore(wxCommandEvent &event); + void InsertCollectionAfter_(); void OnInsertCollectionAfter_(); void OnInsertCollectionAfter(wxCommandEvent &event); void OnDeleteCollection_(); @@ -54,9 +59,10 @@ class WidgetShowNPoints : public wxPanel void OnSaveCollections_( std::string filename ); void OnLoadCollections(wxCommandEvent &event); void OnLoadCollections_( std::string filename ); - void OnResetCollections(wxCommandEvent &event); + void ResetCollections_(); void OnResetCollections_(); - + void OnResetCollections(wxCommandEvent &event); + void OnUndo(wxCommandEvent &event); void OnRedo(wxCommandEvent &event); void UndoRedo_SaveCollection(); @@ -65,8 +71,9 @@ class WidgetShowNPoints : public wxPanel void RefreshCollectionText(); void RefreshColourCollection(); - void InvertLstPoints(); - + void InvertLstPoints_(); + void OnInvertLstPoints_(); + // EED 2022-05-19 //void RefreshPoint(int id); //void RefreshPoints(); @@ -82,29 +89,24 @@ class WidgetShowNPoints : public wxPanel void AddPoint(int x, int y, int z, std::string label); void OnInsertPoint_(); void InsertPoint(int x, int y, int z, std::string label);//CFT - void DeleteAllPoints(); int GetLstModelShowNPointsSize(); ModelShowNPoints* GetModelShowNPoints(); ViewShowNPoints* GetViewShowNPoints(); void SetInitLstPoints( std::vector initLstPointsX, std::vector initLstPointsY, std::vector initLstPointsZ, std::vector initLstLabels ); - void SetType(int type); - int GetType(); - - double GetRadio(); - double GetOpacity(); - - virtual void SetOutputBox(); - void ErasePoint(int id); - - - - std::vector GetLstPointsX(); - std::vector GetLstPointsY(); - std::vector GetLstPointsZ(); - std::vector GetLstLabels(); - std::vector GetLstIndexs(); + void SetType(int type); + int GetType(); + double GetRadio(); + double GetOpacity(); + virtual void SetOutputBox(); + void ErasePoint(int id); + + std::vector GetLstPointsX(); + std::vector GetLstPointsY(); + std::vector GetLstPointsZ(); + std::vector GetLstLabels(); + std::vector GetLstIndexs();