From 83605410fabb141e90a3ef3c7df1453920db4edf Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Mon, 11 Jul 2022 10:18:30 +0200 Subject: [PATCH] #3485 ShowNPionts for Multiple Groups --- bbtk/src/bbcreaMaracasVisuShowNPoints_Reset.h | 2 +- .../bbcreaMaracasVisuShowNPoints_Tools.cxx | 107 ++++++++ bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.h | 55 ++++ bbtk/src/bbmaracasvisuShowNPoints.cxx | 2 +- .../wxWindows/widgets/WidgetShowNPoints.cxx | 240 +++++++++++++----- .../wxWindows/widgets/WidgetShowNPoints.h | 10 +- 6 files changed, 351 insertions(+), 65 deletions(-) create mode 100644 bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx create mode 100644 bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.h diff --git a/bbtk/src/bbcreaMaracasVisuShowNPoints_Reset.h b/bbtk/src/bbcreaMaracasVisuShowNPoints_Reset.h index 5ccc014..7f2d2eb 100644 --- a/bbtk/src/bbcreaMaracasVisuShowNPoints_Reset.h +++ b/bbtk/src/bbcreaMaracasVisuShowNPoints_Reset.h @@ -35,7 +35,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ShowNPoints_Reset,bbtk::AtomicBlackBox); BBTK_AUTHOR("InfoDev"); BBTK_DESCRIPTION("No Description."); BBTK_CATEGORY("empty"); - BBTK_INPUT(ShowNPoints_Reset,WidgetShowNPoints," WidgetShowNPoints ",WidgetShowNPoints*,""); + BBTK_INPUT(ShowNPoints_Reset,WidgetShowNPoints,"WidgetShowNPoints",WidgetShowNPoints*,""); //BBTK_OUTPUT(ShowNPoints_Reset,Out,"First output",double,""); BBTK_END_DESCRIBE_BLACK_BOX(ShowNPoints_Reset); //===== diff --git a/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx new file mode 100644 index 0000000..5f16750 --- /dev/null +++ b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx @@ -0,0 +1,107 @@ +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +#include "bbcreaMaracasVisuShowNPoints_Tools.h" +#include "bbcreaMaracasVisuPackage.h" +namespace bbcreaMaracasVisu +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ShowNPoints_Tools) +BBTK_BLACK_BOX_IMPLEMENTATION(ShowNPoints_Tools,bbtk::AtomicBlackBox); + +void ShowNPoints_Tools::CreatePatch01() +{ + bbGetInputWidgetShowNPoints()->CreatePatch01( ); +} + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void ShowNPoints_Tools::Process() +{ + +// THE MAIN PROCESSING METHOD BODY +// Here we simply set the input 'In' value to the output 'Out' +// And print out the output value +// INPUT/OUTPUT ACCESSORS ARE OF THE FORM : +// void bbSet{Input|Output}NAME(const TYPE&) +// const TYPE& bbGet{Input|Output}NAME() const +// Where : +// * NAME is the name of the input/output +// (the one provided in the attribute 'name' of the tag 'input') +// * TYPE is the C++ type of the input/output +// (the one provided in the attribute 'type' of the tag 'input') + +// bbSetOutputOut( bbGetInputIn() ); +// std::cout << "Output value = " <OnInsertPoint_(); + } // if Type + if (bbGetInputType()==20) + { + bbGetInputWidgetShowNPoints()->OnTrackPoint_tool(); + } // if Type + if (bbGetInputType()==30) + { + bbGetInputWidgetShowNPoints()->OnSetPoint_(); + } // if Type + if (bbGetInputType()==40) + { + bbGetInputWidgetShowNPoints()->OnErasePoint_(); + } // if Type + if (bbGetInputType()==50) + { + bbGetInputWidgetShowNPoints()->DeleteAllPoints(); + } // if Type + if (bbGetInputType()==100) + { + bbGetInputWidgetShowNPoints()->OnInsertCollectionAfter_(); + } // if Type + if (bbGetInputType()==110) + { + bbGetInputWidgetShowNPoints()->OnDeleteCollection_(); + } // if Type + if (bbGetInputType()==200) + { + CreatePatch01(); + } // if Type + } // if bbGetInputWidgetShowNPoints +} +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void ShowNPoints_Tools::bbUserSetDefaultValues() +{ +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + bbSetInputType(0); + bbSetInputMesh(NULL); + bbSetInputWidgetShowNPoints(NULL); +} +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void ShowNPoints_Tools::bbUserInitializeProcessing() +{ +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// if any +} +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void ShowNPoints_Tools::bbUserFinalizeProcessing() +{ +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any +} + +} // EO namespace bbcreaMaracasVisu + + diff --git a/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.h b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.h new file mode 100644 index 0000000..d974669 --- /dev/null +++ b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.h @@ -0,0 +1,55 @@ +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +#ifndef __bbcreaMaracasVisuShowNPoints_Tools_h_INCLUDED__ +#define __bbcreaMaracasVisuShowNPoints_Tools_h_INCLUDED__ + +#include "bbcreaMaracasVisu_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "WidgetShowNPoints.h" +#include "vtkPolyData.h" + +namespace bbcreaMaracasVisu +{ + +class bbcreaMaracasVisu_EXPORT ShowNPoints_Tools + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(ShowNPoints_Tools,bbtk::AtomicBlackBox); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== + BBTK_DECLARE_INPUT(WidgetShowNPoints,WidgetShowNPoints*); + BBTK_DECLARE_INPUT(Mesh,vtkPolyData*); + BBTK_DECLARE_INPUT(Type,int); +// BBTK_DECLARE_OUTPUT(Out,double); + BBTK_PROCESS(Process); + void Process(); + + void CreatePatch01(); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(ShowNPoints_Tools,bbtk::AtomicBlackBox); +BBTK_NAME("ShowNPoints_Tools"); +BBTK_AUTHOR("Info-Dev"); +BBTK_DESCRIPTION("No Description."); +BBTK_CATEGORY("empty"); + BBTK_INPUT(ShowNPoints_Tools,WidgetShowNPoints,"WidgetShowNPoints",WidgetShowNPoints*,""); + BBTK_INPUT(ShowNPoints_Tools,Mesh,"Mesh en format vtkPolyData ",vtkPolyData*,""); + BBTK_INPUT(ShowNPoints_Tools,Type,"(default 0) 0:Nothing 10:Insert Point 20:TrackPoint 30:Set nearest point 40:Erase point 50:Deleta all points 100:Insert group after 110:Delete group 200:Tool_1 - Create Mesh (based with one group and 4 points)",int,""); +// BBTK_OUTPUT(ShowNPoints_Tools,Out,"First output",double,""); +BBTK_END_DESCRIBE_BLACK_BOX(ShowNPoints_Tools); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +} +// EO namespace bbcreaMaracasVisu + +#endif // __bbcreaMaracasVisuShowNPoints_Tools_h_INCLUDED__ + diff --git a/bbtk/src/bbmaracasvisuShowNPoints.cxx b/bbtk/src/bbmaracasvisuShowNPoints.cxx index 3221c6d..6f6e591 100644 --- a/bbtk/src/bbmaracasvisuShowNPoints.cxx +++ b/bbtk/src/bbmaracasvisuShowNPoints.cxx @@ -121,7 +121,7 @@ void ShowNPoints::Process() mwxwidget->GetModelShowNPoints()->SetFirstTime(false); mwxwidget->SetInitLstPoints( bbGetInputInitLstPointsX() , bbGetInputInitLstPointsY() , bbGetInputInitLstPointsZ() , bbGetInputInitLstLabels() ); } - mwxwidget->TrackPoint(); + mwxwidget->TrackingPoint(); bbSetOutputlstPointsX( mwxwidget->GetLstPointsX() ); bbSetOutputlstPointsY( mwxwidget->GetLstPointsY() ); bbSetOutputlstPointsZ( mwxwidget->GetLstPointsZ() ); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx index a536c33..796ffb3 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx @@ -453,9 +453,30 @@ void WidgetShowNPoints::InsertPoint(int x, int y, int z, std::string label)//CFT AddPoint(x,y,z,label); } GetViewShowNPoints()->RefreshPoints(); +} + +//------------------------------------------------------------------------ +void WidgetShowNPoints::OnInsertPoint_() +{ + // EED 2022-05-19 + //if (this->renderer==NULL) + if (GetViewShowNPoints()->renderer==NULL) + { + return; + } + std::vector point = GetModelShowNPoints()->GetReferencePoint(); + if (point.size()==3) + { + InsertPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) ); + SetOutputBox(); + } else {//mpoint.size + printf("creaMaracasVisu::ShowNPoints (not match point) \n"); + } } + + //------------------------------------------------------------------------ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event) { @@ -481,22 +502,8 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event) //------------------------------------------------------------------------ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT -{ - // EED 2022-05-19 - //if (this->renderer==NULL) - if (GetViewShowNPoints()->renderer==NULL) - { - return; - } - - std::vector point = GetModelShowNPoints()->GetReferencePoint(); - if (point.size()==3) - { - InsertPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) ); - SetOutputBox(); - } else {//mpoint.size - printf("creaMaracasVisu::ShowNPoints (not match point) \n"); - } +{ + OnInsertPoint_(); } @@ -597,43 +604,36 @@ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT } // dialog box } - - //------------------------------------------------------------------------ - void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event) - { - int id=GetModelShowNPoints()->GetNearestPoint(); - if((id==-1) && (mtype==1)) - { - id=0; - AddPoint(0,0,0,""); - SetOutputBox(); - } - - if (id>=0) - { - GetModelShowNPoints()->SetPointId_mReferencePoint(id); - // EED 2022-05-19 - //RefreshPoint(id); - //renderer->GetRenderWindow()->Render(); - GetViewShowNPoints()->RefreshPoint(id); - GetViewShowNPoints()->Render(); - } // if id - SetOutputBox(); - } - //------------------------------------------------------------------------ -void WidgetShowNPoints::OnTrackPoint(wxCommandEvent& event) +void WidgetShowNPoints::OnSetPoint_() { - idTrack = -1; -// trackPointFlag = cbTrackPoint->GetValue(); - if ( cbTrackPoint->GetValue() == true ) + int id=GetModelShowNPoints()->GetNearestPoint(); + if((id==-1) && (mtype==1)) { - idTrack = GetModelShowNPoints()->IdInsidePoint(); - } // if trackPointFlag + id=0; + AddPoint(0,0,0,""); + SetOutputBox(); + } + if (id>=0) + { + GetModelShowNPoints()->SetPointId_mReferencePoint(id); + // EED 2022-05-19 + //RefreshPoint(id); + //renderer->GetRenderWindow()->Render(); + GetViewShowNPoints()->RefreshPoint(id); + GetViewShowNPoints()->Render(); + } // if id + SetOutputBox(); } //------------------------------------------------------------------------ -void WidgetShowNPoints::TrackPoint( ) +void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event) +{ + OnSetPoint_(); +} + +//------------------------------------------------------------------------ +void WidgetShowNPoints::TrackingPoint( ) { if ( cbTrackPoint->GetValue() == true ) { @@ -652,6 +652,29 @@ void WidgetShowNPoints::TrackPoint( ) } // if trackPointFlag } +//------------------------------------------------------------------------ +void WidgetShowNPoints::OnTrackPoint_tool() +{ + cbTrackPoint->SetValue( !cbTrackPoint->GetValue() ); + OnTrackPoint_(); +} + +//------------------------------------------------------------------------ +void WidgetShowNPoints::OnTrackPoint_() +{ + idTrack = -1; + if ( cbTrackPoint->GetValue() == true ) + { + idTrack = GetModelShowNPoints()->IdInsidePoint(); + } // if trackPointFlag +} + +//------------------------------------------------------------------------ +void WidgetShowNPoints::OnTrackPoint(wxCommandEvent& event) +{ + OnTrackPoint_(); +} + //------------------------------------------------------------------------ void WidgetShowNPoints::StopTrackPoint( ) { @@ -659,7 +682,6 @@ void WidgetShowNPoints::StopTrackPoint( ) idTrack=-1; } - //------------------------------------------------------------------------ void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event) { @@ -700,14 +722,20 @@ void WidgetShowNPoints::StopTrackPoint( ) } //------------------------------------------------------------------------ - void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event) - { - ErasePoint( GetModelShowNPoints()->IdInsidePoint() ); - SetOutputBox(); + void WidgetShowNPoints::OnErasePoint_() + { + ErasePoint( GetModelShowNPoints()->IdInsidePoint() ); + SetOutputBox(); // EED 2022-05-19 - //renderer->GetRenderWindow()->Render(); + //renderer->GetRenderWindow()->Render(); GetViewShowNPoints()->Render(); StopTrackPoint(); + } + +//------------------------------------------------------------------------ + void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event) + { + OnErasePoint_(); } //------------------------------------------------------------------------ @@ -727,18 +755,19 @@ void WidgetShowNPoints::StopTrackPoint( ) void WidgetShowNPoints::DeleteAllPoints() { // EED 2022-05-19 - //int id,size=lstActorsSphere.size(); + //int id,size=lstActorsSphere.size(); int id,size=GetViewShowNPoints()->lstActorsSphere.size(); - for (id=size-1;id>=0;id--) - { - ErasePoint(id); - } - SetOutputBox(); + for (id=size-1;id>=0;id--) + { + ErasePoint(id); + } + SetOutputBox(); // EED 2022-05-19 - //renderer->GetRenderWindow()->Render(); + //renderer->GetRenderWindow()->Render(); GetViewShowNPoints()->Render(); } + //------------------------------------------------------------------------ void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event) { @@ -865,7 +894,7 @@ void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event) } //------------------------------------------------------------------------ -void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event) +void WidgetShowNPoints::OnInsertCollectionAfter_() { mActualCollection++; InsertCollection(); @@ -873,6 +902,12 @@ void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event) StopTrackPoint(); } +//------------------------------------------------------------------------ +void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event) +{ + OnInsertCollectionAfter_(); +} + //------------------------------------------------------------------------ void WidgetShowNPoints::DeleteCollection_() { @@ -891,7 +926,7 @@ void WidgetShowNPoints::DeleteCollection_() } //------------------------------------------------------------------------ -void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event) +void WidgetShowNPoints::OnDeleteCollection_() { DeleteCollection_(); RefreshCollectionText(); @@ -899,6 +934,12 @@ void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event) StopTrackPoint(); } +//------------------------------------------------------------------------ +void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event) +{ + OnDeleteCollection_(); +} + //------------------------------------------------------------------------ void WidgetShowNPoints::OnBackCollection(wxCommandEvent &event) { @@ -1209,3 +1250,78 @@ std::vector WidgetShowNPoints::GetLstIndexs() return lstIndexs; } + +void WidgetShowNPoints::CreatePatch01() +{ + if ( (lstModelShowNPoints.size()==1) && (GetModelShowNPoints()->GetLstPointsSize()==4) ) + { + StopTrackPoint(); + double px,py,pz; + double dx,dy,dz,s; + std::vector lstX = GetModelShowNPoints()->GetLstPointsX(); + std::vector lstY = GetModelShowNPoints()->GetLstPointsY(); + std::vector lstZ = GetModelShowNPoints()->GetLstPointsZ(); + + // --- Group 0 --- + ErasePoint( 2 ); + ErasePoint( 2 ); + dx=lstX[1]-lstX[0]; + dy=lstY[1]-lstY[0]; + dz=lstZ[1]-lstZ[0]; + s=0.33333; + px = lstX[0] + dx*s; + py = lstY[0] + dy*s; + pz = lstZ[0] + dz*s; + InsertPoint(px ,py, pz,""); + s=s*2; + px = lstX[0] + dx*s; + py = lstY[0] + dy*s; + pz = lstZ[0] + dz*s; + InsertPoint(px ,py, pz,""); + + // --- Group 1 --- + OnInsertCollectionAfter_(); + px = (lstX[0]+lstX[3])/2; + py = (lstY[0]+lstY[3])/2; + pz = (lstZ[0]+lstZ[3])/2; + InsertPoint(px ,py, pz,""); + px = (lstX[1]+lstX[2])/2; + py = (lstY[1]+lstY[2])/2; + pz = (lstZ[1]+lstZ[2])/2; + InsertPoint(px ,py, pz,""); + px = (lstX[0]+lstX[1]+lstX[2]+lstX[3])/4; + py = (lstY[0]+lstY[1]+lstY[2]+lstY[3])/4; + pz = (lstZ[0]+lstZ[1]+lstZ[2]+lstZ[3])/4; + InsertPoint(px ,py, pz,""); + + + // --- Group 2 --- + OnInsertCollectionAfter_(); + px = lstX[3]; + py = lstY[3]; + pz = lstZ[3]; + InsertPoint(px ,py, pz,""); + px = lstX[2]; + py = lstY[2]; + pz = lstZ[2]; + InsertPoint(px ,py, pz,""); + dx=lstX[2]-lstX[3]; + dy=lstY[2]-lstY[3]; + dz=lstZ[2]-lstZ[3]; + s=0.33333; + px = lstX[3] + dx*s; + py = lstY[3] + dy*s; + pz = lstZ[3] + dz*s; + InsertPoint(px ,py, pz,""); + s=s*2; + px = lstX[3] + dx*s; + py = lstY[3] + dy*s; + pz = lstZ[3] + dz*s; + InsertPoint(px ,py, pz,""); + + + SetOutputBox(); + } else { + printf("EED WidgetShowNPoints::CreatePatch01 Warning patch not apply. Need juste one group with four points\n"); + } // if +} diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h index 6520d5f..75776ad 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h @@ -19,13 +19,17 @@ class WidgetShowNPoints : public wxPanel ~WidgetShowNPoints(); void OnAddPoint(wxCommandEvent &event); void OnInsertPoint(wxCommandEvent& event);//CFT + void OnSetPoint_(); void OnSetPoint(wxCommandEvent& event); void OnTrackPoint(wxCommandEvent& event); - void TrackPoint(); + void OnTrackPoint_(); + void OnTrackPoint_tool(); + void TrackingPoint(); void StopTrackPoint(); void DetectCollectionActive(); void OnRenamePoint(wxCommandEvent& event); + void OnErasePoint_(); void OnErasePoint(wxCommandEvent& event); void OnEraseLastPoint(wxCommandEvent &event); void OnDeleteAllPoints(wxCommandEvent &event); @@ -38,7 +42,9 @@ class WidgetShowNPoints : public wxPanel void InsertCollection(); void OnInsertCollectionBefore(wxCommandEvent &event); + void OnInsertCollectionAfter_(); void OnInsertCollectionAfter(wxCommandEvent &event); + void OnDeleteCollection_(); void OnDeleteCollection(wxCommandEvent &event); void DeleteCollection_(); void OnBackCollection(wxCommandEvent &event); @@ -63,6 +69,7 @@ class WidgetShowNPoints : public wxPanel void SetReferencePoint(std::vector point); 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(); @@ -76,6 +83,7 @@ class WidgetShowNPoints : public wxPanel double GetRadio(); double GetOpacity(); + void CreatePatch01(); std::vector GetLstPointsX(); std::vector GetLstPointsY(); -- 2.45.1