From 0bd39f27f20b1717fc1fe799c5e663dfa0279884 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Fri, 24 Jun 2022 16:39:02 +0200 Subject: [PATCH] #3485 ShowNPionts for Multiple Groups --- bbtk/bbs/boxes/SliceImage-3DVisu.bbg | 22 ++++-- bbtk/bbs/boxes/SliceImage-3DVisu.bbs | 6 +- ...bcreaMaracasVisuManualContourModel_Box.cxx | 4 +- bbtk/src/bbmaracasvisuShowNPoints.cxx | 8 +- .../wxWindows/widgets/ModelShowNPoints.cxx | 3 +- .../wxWindows/widgets/WidgetShowNPoints.cxx | 74 ++++++++++++++++++- .../wxWindows/widgets/WidgetShowNPoints.h | 14 +++- 7 files changed, 116 insertions(+), 15 deletions(-) diff --git a/bbtk/bbs/boxes/SliceImage-3DVisu.bbg b/bbtk/bbs/boxes/SliceImage-3DVisu.bbg index a75cf0e..af66f84 100644 --- a/bbtk/bbs/boxes/SliceImage-3DVisu.bbg +++ b/bbtk/bbs/boxes/SliceImage-3DVisu.bbg @@ -60,7 +60,7 @@ COMPLEX_PORT transparenceBeforeAboveRange -386.966824:85.119355:-900.000000 FIN_COMPLEX_PORT -BOXES:47 +BOXES:48 BOX creaMaracasVisu:SliceImage:Box00 ISEXEC:FALSE @@ -449,7 +449,13 @@ ISEXEC:FALSE -375.478516:-89.335399:-900.000000 -342.158516:-91.835399:-900.000000 FIN_BOX -CONNECTIONS:74 +BOX +std:MagicBox:Box89 +ISEXEC:FALSE +-105.296409:65.122911:-900.000000 +-83.696409:62.622911:-900.000000 +FIN_BOX +CONNECTIONS:76 CONNECTION Box22:LookupTable:Box04:LookupTable NumberOfControlPoints:0 @@ -538,9 +544,6 @@ CONNECTION SliceDeep:SliceDeep:Box60:In1 NumberOfControlPoints:0 CONNECTION -SliceOpacity:SliceOpacity:Box04:Opacity -NumberOfControlPoints:0 -CONNECTION Render:Render:Box61:In NumberOfControlPoints:0 CONNECTION @@ -672,4 +675,13 @@ NumberOfControlPoints:0 CONNECTION Box32:Out:Box26:Transform NumberOfControlPoints:0 +CONNECTION +SliceOpacity:SliceOpacity:Box89:In +NumberOfControlPoints:0 +CONNECTION +Box89:Out:Box04:Opacity +NumberOfControlPoints:0 +CONNECTION +Box89:Out:Box26:Opacity +NumberOfControlPoints:0 APP_END diff --git a/bbtk/bbs/boxes/SliceImage-3DVisu.bbs b/bbtk/bbs/boxes/SliceImage-3DVisu.bbs index 1c9a7b9..1197692 100644 --- a/bbtk/bbs/boxes/SliceImage-3DVisu.bbs +++ b/bbtk/bbs/boxes/SliceImage-3DVisu.bbs @@ -165,6 +165,8 @@ new wx:OutputText Box87 new wx:LayoutLine Box88 +new std:MagicBox Box89 + connect Box22.LookupTable Box04.LookupTable connect Box32.Out Box04.Transform @@ -228,19 +230,21 @@ connect Box37.Out Box87.In connect Box86.Widget Box88.Widget1 connect Box87.Widget Box88.Widget2 connect Box32.Out Box26.Transform +connect Box89.Out Box04.Opacity +connect Box89.Out Box26.Opacity # Complex input ports input Direction Box40.In1 " " input ColorBorder Box62.In1 " " input Image Box38.In " " input SliceDeep Box60.In1 " " -input SliceOpacity Box04.Opacity " " input Render Box61.In " " input WindowColorLevel Box65.In1 " " input BorderActive Box83.In " " input Interpolation_mode Box78.In " " input TypeTransparence Box84.In " " input transparenceBeforeAboveRange Box85.In " " +input SliceOpacity Box89.In " " # Complex output ports output BoxChangeImageSlice Box04.BoxChange " " diff --git a/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx b/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx index e38abef..4cbce72 100644 --- a/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx +++ b/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx @@ -876,9 +876,9 @@ void ManualContourModel_Box::Process() } // for i // Step 1. All contours the same clockwise direction (Control Points) - if (bbGetInputDoubleContour()==1) + if ((bbGetInputDoubleContour()==1) && (bbGetInputOpenClose()==true)) { - ClockwisePoints( &lstInX , &lstInY , &lstInZ , &lstIndexsIn ); + ClockwisePoints( &lstInX , &lstInY , &lstInZ , &lstIndexsIn ); // wich is the plane base XY? XZ ZY ?????? // ShiftValues( &lstInX , &lstInY , &lstInZ , &lstIndexsIn ); } // DoubleContour size = lstIndexsIn.size(); diff --git a/bbtk/src/bbmaracasvisuShowNPoints.cxx b/bbtk/src/bbmaracasvisuShowNPoints.cxx index c60e495..3221c6d 100644 --- a/bbtk/src/bbmaracasvisuShowNPoints.cxx +++ b/bbtk/src/bbmaracasvisuShowNPoints.cxx @@ -104,18 +104,24 @@ void ShowNPoints::Process() { if (mwxwidget!=NULL) { - printf("EED ShowNPoints::Process point: %d %d %d\n", bbGetInputIn()[0], bbGetInputIn()[1], bbGetInputIn()[2] ); mwxwidget->SetRenderer( bbGetInputRenderer() ); mwxwidget->SetReferencePoint( bbGetInputIn() ); mwxwidget->SetImage( bbGetInputImage() ); mwxwidget->SetColour( bbGetInputColour() ); mwxwidget->SetOpacity( bbGetInputOpacity() ); mwxwidget->SetRadio( bbGetInputRadio() ); + + if ( mwxwidget->GetModelShowNPoints()->GetFirstTime()==false ) + { + mwxwidget->DetectCollectionActive(); + } + if ( mwxwidget->GetModelShowNPoints()->GetFirstTime()==true ) { mwxwidget->GetModelShowNPoints()->SetFirstTime(false); mwxwidget->SetInitLstPoints( bbGetInputInitLstPointsX() , bbGetInputInitLstPointsY() , bbGetInputInitLstPointsZ() , bbGetInputInitLstLabels() ); } + mwxwidget->TrackPoint(); bbSetOutputlstPointsX( mwxwidget->GetLstPointsX() ); bbSetOutputlstPointsY( mwxwidget->GetLstPointsY() ); bbSetOutputlstPointsZ( mwxwidget->GetLstPointsZ() ); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.cxx index feacc8d..c3c0672 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.cxx @@ -295,6 +295,7 @@ int ModelShowNPoints::IdInsidePoint() int id=-1; int i, size=(int)( lstPointsX.size() ); double spc[3]; + double radio2=(mradio+1)*(mradio+1); if(mimage ==NULL) { printf("WidgetShowNPoints::IdInsidePoint image not set\n"); @@ -306,7 +307,7 @@ int ModelShowNPoints::IdInsidePoint() double rx = spc[0]*(mReferencePoint[0] - lstPointsX [i]); double ry = spc[1]*(mReferencePoint[1] - lstPointsY [i]); double rz = spc[2]*(mReferencePoint[2] - lstPointsZ [i]); - if ( rx*rx + ry*ry + rz*rz <= mradio*mradio) + if ( rx*rx + ry*ry + rz*rz <= radio2) { id=i; } // if diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx index 47e7d41..a536c33 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx @@ -7,7 +7,6 @@ #include -#include #include #include #include @@ -118,7 +117,7 @@ wxButton *btnAddPoint = new wxButton( panel, -1, _T("Add Point")); wxButton *btnInsertPoint = new wxButton( panel, -1, _T("Insert Point"));//CFT wxButton *btnSetPositionPoint= new wxButton( panel, -1, _T("Set nearest point")); - wxCheckBox *chkBox = new wxCheckBox(panel, -1, _T("Track Point") ); + cbTrackPoint = new wxCheckBox(panel,-1, _T("Track Point") ); wxButton *btnRenamePoint = new wxButton( panel, -1, _T("Rename point")); wxButton *btnEraseLastPoint = new wxButton( panel, -1, _T("Erase Last point")); wxButton *btnErasePoint = new wxButton( panel, -1, _T("Erase point")); @@ -155,6 +154,7 @@ Connect(btnEraseLastPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnEraseLastPoint); Connect(btnErasePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint); Connect(btnDeleteAllPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints); + Connect(cbTrackPoint->GetId() , wxEVT_CHECKBOX , (wxObjectEventFunction) &WidgetShowNPoints::OnTrackPoint); wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1); @@ -162,7 +162,7 @@ sizer1->Add(textCtrl); sizer1->Add(btnAddPoint); sizer1->Add(btnInsertPoint);//CFT - sizer1->Add(chkBox); + sizer1->Add(cbTrackPoint); sizer1->Add(btnSetPositionPoint); sizer1->Add(btnRenamePoint); sizer1->Add(btnErasePoint); @@ -597,6 +597,7 @@ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT } // dialog box } + //------------------------------------------------------------------------ void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event) { @@ -619,7 +620,46 @@ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT } // if id SetOutputBox(); } - + +//------------------------------------------------------------------------ +void WidgetShowNPoints::OnTrackPoint(wxCommandEvent& event) +{ + idTrack = -1; +// trackPointFlag = cbTrackPoint->GetValue(); + if ( cbTrackPoint->GetValue() == true ) + { + idTrack = GetModelShowNPoints()->IdInsidePoint(); + } // if trackPointFlag +} + +//------------------------------------------------------------------------ +void WidgetShowNPoints::TrackPoint( ) +{ + if ( cbTrackPoint->GetValue() == true ) + { + int id = GetModelShowNPoints()->IdInsidePoint(); + if (id>=0) + { + idTrack=id; + } + + if (idTrack>=0) + { + GetModelShowNPoints()->SetPointId_mReferencePoint(idTrack); + GetViewShowNPoints()->RefreshPoint(idTrack); + GetViewShowNPoints()->Render(); + } // if id + } // if trackPointFlag +} + +//------------------------------------------------------------------------ +void WidgetShowNPoints::StopTrackPoint( ) +{ + cbTrackPoint->SetValue(false); + idTrack=-1; +} + + //------------------------------------------------------------------------ void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event) { @@ -667,6 +707,7 @@ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT // EED 2022-05-19 //renderer->GetRenderWindow()->Render(); GetViewShowNPoints()->Render(); + StopTrackPoint(); } //------------------------------------------------------------------------ @@ -679,6 +720,7 @@ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT ErasePoint( id ); GetViewShowNPoints()->Render(); SetOutputBox(); + StopTrackPoint(); } //------------------------------------------------------------------------ @@ -819,6 +861,7 @@ void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event) { InsertCollection(); RefreshColourCollection(); + StopTrackPoint(); } //------------------------------------------------------------------------ @@ -827,6 +870,7 @@ void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event) mActualCollection++; InsertCollection(); RefreshColourCollection(); + StopTrackPoint(); } //------------------------------------------------------------------------ @@ -852,6 +896,7 @@ void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event) DeleteCollection_(); RefreshCollectionText(); RefreshColourCollection(); + StopTrackPoint(); } //------------------------------------------------------------------------ @@ -864,6 +909,7 @@ void WidgetShowNPoints::OnBackCollection(wxCommandEvent &event) } //if <=0 RefreshCollectionText(); RefreshColourCollection(); + StopTrackPoint(); } //------------------------------------------------------------------------ @@ -876,6 +922,24 @@ void WidgetShowNPoints::OnNextCollection(wxCommandEvent &event) } //if <=0 RefreshCollectionText(); RefreshColourCollection(); + StopTrackPoint(); +} + +//------------------------------------------------------------------------ +void WidgetShowNPoints::DetectCollectionActive() +{ + int id; + int i,size=lstModelShowNPoints.size(); + for (i=0;iIdInsidePoint(); + if (id>=0) + { + mActualCollection=i; + } // if id>=0 + } // for i + RefreshCollectionText(); + RefreshColourCollection(); } //------------------------------------------------------------------------ @@ -959,6 +1023,7 @@ void WidgetShowNPoints::OnSaveCollections(wxCommandEvent &event) } // dialog box + StopTrackPoint(); } @@ -1030,6 +1095,7 @@ void WidgetShowNPoints::OnLoadCollections(wxCommandEvent &event) RefreshCollectionText(); RefreshColourCollection(); } // dialog box + StopTrackPoint(); } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h index 66fa2d1..6520d5f 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h @@ -9,6 +9,8 @@ #include #include #include +#include + class WidgetShowNPoints : public wxPanel { @@ -18,10 +20,16 @@ class WidgetShowNPoints : public wxPanel void OnAddPoint(wxCommandEvent &event); void OnInsertPoint(wxCommandEvent& event);//CFT void OnSetPoint(wxCommandEvent& event); + void OnTrackPoint(wxCommandEvent& event); + void TrackPoint(); + void StopTrackPoint(); + void DetectCollectionActive(); + void OnRenamePoint(wxCommandEvent& event); void OnErasePoint(wxCommandEvent& event); void OnEraseLastPoint(wxCommandEvent &event); - void OnDeleteAllPoints(wxCommandEvent &event); + void OnDeleteAllPoints(wxCommandEvent &event); + void OnSavePoints(wxCommandEvent &event); void OnLoadPoints(wxCommandEvent &event); @@ -93,6 +101,7 @@ class WidgetShowNPoints : public wxPanel //double mopacity; std::vector lstViewShowNPoints; + //NTU: For updating points wxStaticText * askPointLabel; wxTextCtrl * textCtrl; @@ -100,10 +109,13 @@ class WidgetShowNPoints : public wxPanel wxStaticText * txtNrPoints; wxSlider * sdrOpacity; wxSlider * sdrRadio; + wxCheckBox * cbTrackPoint; std::vector lstModelShowNPoints; int mtype; int mActualCollection; +// bool trackPointFlag; + int idTrack; }; -- 2.47.1