-# ---------------------------------------------------------------------
-#
-# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
-# pour la Sant�)
-# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
-# Previous Authors : Laurent Guigues, Jean-Pierre Roux
-# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
-#
-# This software is governed by the CeCILL-B license under French law and
-# abiding by the rules of distribution of free software. You can use,
-# modify and/ or redistribute the software under the terms of the CeCILL-B
-# license as circulated by CEA, CNRS and INRIA at the following URL
-# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-# or in the file LICENSE.txt.
-#
-# As a counterpart to the access to the source code and rights to copy,
-# modify and redistribute granted by the license, users are provided only
-# with a limited warranty and the software's author, the holder of the
-# economic rights, and the successive licensors have only limited
-# liability.
-#
-# The fact that you are presently reading this means that you have had
-# knowledge of the CeCILL-B license and that you accept its terms.
-# ------------------------------------------------------------------------ */
+# ----------------------------------
+# - BBTKGEditor v 1.5 BBS BlackBox Script
+# - /Users/davila/Creatis/C11/creatools_source/creaMaracasVisu/bbtk/bbs/appli/exampleShowNPoints.bbs
+# ----------------------------------
-description "Show N Points"
-author "info-dev@creatis.insa-lyon.fr"
-category "demo"
+# BBTK GEditor Script
+# ----------------------
-// To show how easy it is to add smthing
-// =====================================
-
-load vtk
-include wxvtk
-load std
-load itk
+include std
+include itkvtk
include vtk
+include creaMaracasVisu
include wx
-load itkvtk
-load creaMaracasVisu
+author "info-dev@creatis.insa-lyon.fr"
+description "Show N Points"
+category "demo"
+new vtk:LoadHola reader
-# Use new box (choose the way you want to select images)
-# -----------------------------------------------------
+new creaMaracasVisu:ViewerNV viewer
+ set viewer.nTypeView "5 1 2 0"
-#load creaImageIO
-#new ImageReader chooser
+new creaMaracasVisu:ShowNPoints showNpoints
+ set showNpoints.Radio "10"
-# Concatenate all the supposed-to-be consistent 2D images into a single vtkImageData
-# WARNING : File names alphabetical order is suposed to be meaningful ...
+new wx:LayoutSplit main
+ set main.Orientation "H"
-#new ConcatImages reader
-# connect chooser.Out reader.In
+connect reader.Out viewer.In
+connect reader.Out showNpoints.Image
-# Here loads hola.mhd
-# -------------------------
+connect viewer.Renderer1 showNpoints.Renderer
-include vtk/boxes/bbLoadHola
-new LoadHola reader
+connect viewer.Point showNpoints.In
-# uncomment next lines to have a file selector
-# ---------------------------------------------
-/*
-new FileSelector openFileDialog
- set openFileDialog.Wildcard "(*.mhd)|*.mhd"
-new MetaImageReader reader
- connect openFileDialog.Out reader.In
-*/
+connect viewer.BoxChange showNpoints.BoxExecute
-# uncomment next lines to use Gimmick
-# -----------------------------------
-/*
-load creaImageIO
-new Gimmick reader
-*/
+connect showNpoints.Widget main.Widget1
-new ViewerNV viewer
- connect reader.Out viewer.In
- set viewer.nTypeView "5 1 2 0"
+connect viewer.Widget main.Widget2
-new ShowNPoints showNpoints
- connect reader.Out showNpoints.Image
- connect viewer.Renderer1 showNpoints.Renderer
- connect viewer.Point showNpoints.In
- connect viewer.BoxChange showNpoints.BoxExecute
- set showNpoints.Radio 10
-new LayoutSplit main
- set main.Orientation H
- connect showNpoints.Widget main.Widget1
- connect viewer.Widget main.Widget2
+# Complex input ports
exec main
-
#include <wx/sizer.h>
#include <wx/filedlg.h>
#include <wx/msgdlg.h>
+#include <wx/notebook.h>
#include "WidgetShowNPoints.h"
WidgetShowNPoints::WidgetShowNPoints(wxWindow *parent, int type)
: wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
{
+ printf("EED WidgetShowNPoints::WidgetShowNPoints Start \n");
// EED 2022-05-19
// mmodelShowNPoints = new ModelShowNPoints();
- mActualLstPoints=0;
- ModelShowNPoints* modelShowNPoints = new ModelShowNPoints();
- lstModelShowNPoints.push_back( modelShowNPoints );
- lstViewShowNPoints.push_back( new ViewShowNPoints( modelShowNPoints ) );
-
+ mActualCollection= 0;
+ ModelShowNPoints* modelShowNPoints = new ModelShowNPoints();
+ lstModelShowNPoints.push_back( modelShowNPoints );
+ lstViewShowNPoints.push_back( new ViewShowNPoints( modelShowNPoints ) );
mtype = type;
SetType(mtype);
- wxPanel *panel = this;
- wxSizer *sizer = NULL;
+ wxPanel* panelParent = this;
+ wxSizer* sizer = NULL;
+ wxSizer* MNPsizer = NULL;
+
+ wxNotebook* bookSetPoints = NULL;
+ wxNotebook* bookGroupManager = NULL;
+ wxPanel* panel = NULL;
+ wxPanel* panel2 = NULL;
+
+
+
+
+ bookSetPoints = new wxNotebook(panelParent,
+ -1,
+ wxDefaultPosition,
+ wxDefaultSize,
+ wxNB_TOP );
+ panel = new wxPanel(bookSetPoints);
- if ((mtype==0) || (mtype==3))
+
+ // Group Manager
+ if (mtype==4)
+ {
+ bookGroupManager = new wxNotebook(panelParent, //bbGetWxParent(),
+ -1,
+ wxDefaultPosition,
+ wxDefaultSize,
+ wxNB_TOP );
+ panel2 = new wxPanel(bookGroupManager);
+ txtNrCollections = new wxStaticText(panel2,-1, _T("1 / 1 "));
+ wxButton *btnBackCollection = new wxButton( panel2, -1, _T("<"));
+ wxButton *btnNextCollection = new wxButton( panel2, -1, _T(">"));
+ wxButton *btnInsertCollectionBefore = new wxButton( panel2, -1, _T("Insert Before"));
+ wxButton *btnInsertCollectionAfter = new wxButton( panel2, -1, _T("Insert After"));
+ wxButton *btnDeleteCollection = new wxButton( panel2, -1, _T("Delete"));
+
+ Connect(btnInsertCollectionBefore->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionBefore);
+ Connect(btnInsertCollectionAfter->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionAfter);
+ Connect(btnDeleteCollection->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteCollection);
+ Connect(btnBackCollection->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnBackCollection);
+ Connect(btnNextCollection->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnNextCollection);
+
+ wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
+ wxFlexGridSizer *sizer2 = new wxFlexGridSizer(2);
+
+ sizer2->Add( btnBackCollection );
+ sizer2->Add( btnNextCollection );
+
+ sizer1->Add( txtNrCollections );
+ sizer1->Add( sizer2 );
+ sizer1->Add( btnInsertCollectionBefore );
+ sizer1->Add( btnInsertCollectionAfter );
+ sizer1->Add( btnDeleteCollection );
+ MNPsizer = sizer1;
+ panel2->SetSizer( MNPsizer );
+ panel2->SetAutoLayout(true);
+ panel2->Layout();
+ bookGroupManager->AddPage(panel2 , _T("Collection") );
+ } // if mtype 4
+
+ if ( (mtype==0) || (mtype==3) || (mtype==4) )
{
// Widget interface
askPointLabel = new wxStaticText(panel, -1, _T("Point label :")); // JPR
wxButton *btnDeleteAllPoints = new wxButton( panel, -1, _T("Delete all points"));
wxButton *btnSavePoints = NULL;
wxButton *btnLoadPoints = NULL;
- if (mtype==0)
+ if ( (mtype==0) || (mtype==4) )
{
btnSavePoints = new wxButton( panel, -1, _T("Save points"));
btnLoadPoints = new wxButton( panel, -1, _T("Load points"));
- }
+ } // if mtype
txtNrPoints = new wxStaticText(panel,-1, _T(" "));
//NTU: Sliders for opacity and radio change
- wxStaticText* txOpacity = new wxStaticText(this, -1, wxString(_T(" Points Opacity ")));
- sdrOpacity = new wxSlider(this, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
- wxStaticText* txRadio = new wxStaticText(this, -1, wxString(_T(" Points Radius ")));
- sdrRadio = new wxSlider(this, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
-
- wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
- // sizer1->Add(new wxStaticText(panel,-1,_T(" ")));
+ wxStaticText* txOpacity = new wxStaticText(panel, -1, wxString(_T(" Points Opacity ")));
+ sdrOpacity = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
+ wxStaticText* txRadio = new wxStaticText(panel, -1, wxString(_T(" Points Radius ")));
+ sdrRadio = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
Connect(btnAddPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint);
Connect(btnInsertPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnInsertPoint);//CFT
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);
- if (mtype==0)
+ if ((mtype==0) || (mtype==4) )
{
- Connect(btnSavePoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints);
- Connect(btnLoadPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints);
+ Connect(btnSavePoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints);
+ Connect(btnLoadPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints);
}
//NTU: Slider events
Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
+ wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
sizer1->Add(askPointLabel); // JPR
sizer1->Add(textCtrl);
sizer1->Add(btnAddPoint);
sizer1->Add(sdrOpacity,1,wxGROW );
sizer1->Add(txRadio);
sizer1->Add(sdrRadio,1,wxGROW );
- if (mtype==0)
+ if ((mtype==0) || (mtype==4) )
{
sizer1->Add(btnSavePoints);
sizer1->Add(btnLoadPoints);
txtNrPoints = new wxStaticText(panel,-1, _T(" "));
//NTU: Sliders for opacity and radio change
- wxStaticText* txOpacity = new wxStaticText(this, -1, wxString(_T(" Points Opacity ")));
- sdrOpacity = new wxSlider(this, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
- wxStaticText* txRadio = new wxStaticText(this, -1, wxString(_T(" Points Radio ")));
- sdrRadio = new wxSlider(this, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
- wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
+ wxStaticText* txOpacity = new wxStaticText(panel, -1, wxString(_T(" Points Opacity ")));
+ sdrOpacity = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
+ wxStaticText* txRadio = new wxStaticText(panel, -1, wxString(_T(" Points Radio ")));
+ sdrRadio = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
Connect(btnSetPositionPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
+ wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
sizer1->Add(btnSetPositionPoint);
sizer1->Add(txtNrPoints);
sizer1->Add(txOpacity);
wxButton *btnDeleteAllPoints = new wxButton(panel, -1, _T(" Delete All "));
wxStaticText *spacer = new wxStaticText(panel, -1, _T("\n")); // JPR
textCtrl = new wxTextCtrl(panel, -1);
- wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
Connect(btnAddPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnAddPoint);
Connect(btnDeleteAllPoints->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteAllPoints);
- sizer1->Add(askPointLabel);
+ wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
+ sizer1->Add(askPointLabel);
sizer1->Add(btnAddPoint);
sizer1->Add(btnDeleteAllPoints);
sizer1->Add(spacer);
sizer1->Add(textCtrl);
- sdrOpacity = new wxSlider();
- sdrRadio = new wxSlider();
- txtNrPoints = new wxStaticText(panel, -1, _T("\n\n\n"));
- sizer = sizer1;
+ // sdrOpacity = new wxSlider();
+ // sdrRadio = new wxSlider();
+ txtNrPoints = new wxStaticText(panel, -1, _T("\n\n\n"));
+ sizer = sizer1;
} // bbGetInputType 2
- if (sizer!=NULL)
- {
- panel->SetSizer(sizer);
- panel->SetAutoLayout(true);
- panel->Layout();
- } // if sizer
+
+ panel->SetSizer(sizer);
+ panel->SetAutoLayout(true);
+ panel->Layout();
+ bookSetPoints->AddPage(panel , _T("Set Points") );
+
+ if ((mtype >= 0) && (mtype <= 3) )
+ {
+ if (sizer!=NULL)
+ {
+ wxFlexGridSizer *sizerParent = new wxFlexGridSizer(1);
+ sizerParent->Add( bookSetPoints );
+ panelParent->SetSizer( sizerParent );
+ panelParent->SetAutoLayout(true);
+ panelParent->Layout();
+ } // if sizer
+ } // if mtype 0 1 2 3
+
+ if (mtype == 4)
+ {
+ if ((sizer!=NULL) && (MNPsizer!=NULL))
+ {
+ wxFlexGridSizer *sizerG = new wxFlexGridSizer(2);
+ sizerG->Add(bookGroupManager);
+ sizerG->Add(bookSetPoints);
+ panelParent->SetSizer(sizerG);
+ panelParent->SetAutoLayout(true);
+ panelParent->Layout();
+ } // if sizer
+ } // if mtype 4
}
//------------------------------------------------------------------------
{
// EED 2022-05-19
// return mmodelShowNPoints;
- return lstModelShowNPoints[ mActualLstPoints ];
+ return lstModelShowNPoints[ mActualCollection ];
}
// EED 2022-05-19
//------------------------------------------------------------------------
ViewShowNPoints* WidgetShowNPoints::GetViewShowNPoints()
{
- return lstViewShowNPoints[ mActualLstPoints ];
+ return lstViewShowNPoints[ mActualCollection ];
}
return;
}
int i,sizeX,sizeY,sizeZ,sizeLabels;
- sizeX=(int)initLstPointsX.size();
- sizeY=(int)initLstPointsY.size();
- sizeZ=(int)initLstPointsZ.size();
- sizeLabels=(int)initLstLabels.size();
+ sizeX = (int)initLstPointsX.size();
+ sizeY = (int)initLstPointsY.size();
+ sizeZ = (int)initLstPointsZ.size();
+ sizeLabels = (int)initLstLabels.size();
int x,y,z;
std::string label;
if ( (sizeX==sizeY) && (sizeX==sizeZ) )
{
return sdrOpacity->GetValue()/100;
}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::InsertCollection()
+{
+ ModelShowNPoints* model = new ModelShowNPoints();
+ ViewShowNPoints* view = new ViewShowNPoints( model );
+ model->SetImage( lstModelShowNPoints[0]->GetImage() );
+ view->mopacity = lstViewShowNPoints[0]->mopacity;
+ view->renderer = lstViewShowNPoints[0]->renderer;
+ lstModelShowNPoints.insert( lstModelShowNPoints.begin()+mActualCollection , model );
+ lstViewShowNPoints.insert( lstViewShowNPoints.begin()+mActualCollection , view );
+ RefreshCollectionText();
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event)
+{
+ InsertCollection();
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event)
+{
+ mActualCollection++;
+ InsertCollection();
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event)
+{
+ if ( lstModelShowNPoints.size()>=1 )
+ {
+ DeleteAllPoints(); // Actual Collection
+ lstModelShowNPoints.erase( lstModelShowNPoints.begin()+mActualCollection );
+ mActualCollection--;
+ }
+ RefreshCollectionText();
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnBackCollection(wxCommandEvent &event)
+{
+ mActualCollection--;
+ if ( mActualCollection <0 )
+ {
+ mActualCollection=0;
+ } //if <=0
+ RefreshCollectionText();
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnNextCollection(wxCommandEvent &event)
+{
+ mActualCollection++;
+ if ( mActualCollection >=lstModelShowNPoints.size() )
+ {
+ mActualCollection = lstModelShowNPoints.size()-1;
+ } //if <=0
+ RefreshCollectionText();
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::RefreshCollectionText()
+{
+ wxString strTmp;
+ strTmp.Printf(_T("%d / %d "), (int)mActualCollection+1, (int)lstModelShowNPoints.size() );
+ txtNrCollections->SetLabel( strTmp );
+ SetOutputBox();
+}