From d43eaee96a8c31023bae53055512ef35fd4e67c9 Mon Sep 17 00:00:00 2001 From: corredor <> Date: Wed, 28 Apr 2010 14:30:50 +0000 Subject: [PATCH] Setting values in a blackbox and almost setting values in the scene properties --- .../wxVtkSceneManager.cxx | 62 +++++-- .../wxVtkSceneManager.h | 1 + .../GBlackBoxController.cxx | 19 --- .../GBlackBoxController.h | 1 - .../bbtkwxGUIEditorGraphicBBS.cxx | 8 + .../bbtkwxGUIEditorGraphicBBS.h | 4 + .../bbsWxGUIEditorGraphic/wxEditionDialog.cxx | 159 ++++++++++++++++++ .../bbsWxGUIEditorGraphic/wxEditionDialog.h | 97 +++++++++++ .../wxGEditorTabPanel.cxx | 7 + .../bbsWxGUIEditorGraphic/wxGEditorTabPanel.h | 1 + .../wxTabPanelsManager.cxx | 7 + .../wxTabPanelsManager.h | 2 +- 12 files changed, 331 insertions(+), 37 deletions(-) create mode 100644 lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxEditionDialog.cxx create mode 100644 lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxEditionDialog.h diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx index 8107b8e..7419d39 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx @@ -440,22 +440,7 @@ namespace bbtk cont->SetActive(true); } } - else if(command == EDIT_BLACKBOX) - { - GObjectController* cont = _controllers[idController]; - - for (int i=0; i<_selectedObjects.size(); i++) - { - int id = _selectedObjects[i]; - GObjectController* cont = _controllers[id]; - cont->getView()->setState(NOTHING_HAPPENS); - } - _selectedObjects.clear(); - - GBlackBoxModel *bbmodel = (GBlackBoxModel*)cont->getModel(); - _parent->editBlackBox(bbmodel); - - } + } } @@ -590,6 +575,51 @@ namespace bbtk //========================================================================= + bool wxVtkSceneManager::OnLeftDClick() + { + int X,Y; + wxVTKRenderWindowInteractor *wxVTKiren; + wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren->GetEventPosition(X,Y); + + std::map::iterator it; + + bool clickOnObject = false; + + for(it = _controllers.begin(); it != _controllers.end() && clickOnObject==false; ++it) + { + GObjectController *cont = it->second; + int type = cont->getGObjectType(); + + if(cont->getView()->isPointInside(X,Y)) + { + if(type==GBLACKBOX) + { + for (int i=0; i<_selectedObjects.size(); i++) + { + int id = _selectedObjects[i]; + GObjectController* control = _controllers[id]; + control->getView()->setState(NOTHING_HAPPENS); + } + _selectedObjects.clear(); + + GBlackBoxModel *bbmodel = (GBlackBoxModel*)cont->getModel(); + _parent->editBlackBox(bbmodel); + } + clickOnObject = true; + } + } + + if(clickOnObject==false) + { + _parent->editDiagramParameters(this); + } + + return true; + } + + //========================================================================= + bool wxVtkSceneManager::OnChar() { char keyCode = _vtkInteractorStyleBaseView->GetInteractor()-> GetKeyCode(); diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h index 7efbe00..a189fff 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h @@ -108,6 +108,7 @@ namespace bbtk virtual bool OnLeftButtonDown(); virtual bool OnLeftButtonUp(); virtual bool OnRightButtonUp(); + virtual bool OnLeftDClick(); virtual void update(int idController,int command); diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx index 6409275..cfdaa31 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx @@ -131,26 +131,7 @@ namespace bbtk } //========================================================================= - - bool GBlackBoxController::OnLeftDClick() - { - int X,Y; - wxVTKRenderWindowInteractor *wxVTKiren; - wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); - wxVTKiren->GetEventPosition(X,Y); - - int state = _view->getState(); - //Evaluate new state - if(_view->isPointInside(X,Y)) - { - _model->notifyObservers(getId(),EDIT_BLACKBOX); - } - return true; - } - - //========================================================================= - bool GBlackBoxController::OnRightButtonUp() { GBlackBoxModel *bbmodel = (GBlackBoxModel*)_model; diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.h index d5e3445..1fc734e 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.h @@ -81,7 +81,6 @@ namespace bbtk virtual bool OnLeftButtonDown(); virtual bool OnLeftButtonUp(); virtual bool OnMiddleButtonDown(); - virtual bool OnLeftDClick(); virtual bool OnRightButtonUp(); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index 816e884..696214c 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -286,6 +286,14 @@ namespace bbtk //========================================================================= + void wxGUIEditorGraphicBBS::editDiagramParameters(wxVtkSceneManager* scene) + { + wxEditionDialog* dialog = new wxEditionDialog(this,scene); + dialog->Show(); + } + + //========================================================================= + void wxGUIEditorGraphicBBS::updateStatusBar(std::string textStatus) { SetStatusText(_T(textStatus)); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h index e31d873..d81251d 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h @@ -47,6 +47,7 @@ #include "wxTabPanelsManager.h" #include "wxPropertiesPanel.h" #include "wxEditionDialog.h" +#include "wxVtkSceneManager.h" #include "C:\RaC\CREATIS\bbtkGEditor\data\icons\wxart_new.xpm" //Includes creaMaracasVisu @@ -77,6 +78,8 @@ namespace bbtk { class wxTabPanelsManager; + + class wxVtkSceneManager; class wxGUIEditorGraphicBBS : public wxFrame { @@ -97,6 +100,7 @@ namespace bbtk void executeActualDiagram(); void editBlackBox(GBlackBoxModel *bbmodel); + void editDiagramParameters(wxVtkSceneManager* scene); void RegenerateAll(); void DoRegeneratePackageDoc(const std::string& pack); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxEditionDialog.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxEditionDialog.cxx new file mode 100644 index 0000000..66a8fb0 --- /dev/null +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxEditionDialog.cxx @@ -0,0 +1,159 @@ +/*========================================================================= +Program: bbtk +Module: $RCSfile$ +Language: C++ +Date: $Date$ +Version: $Revision$ +=========================================================================*/ + +/* --------------------------------------------------------------------- + +* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) +* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux +* +* 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. +* ------------------------------------------------------------------------ */ + +/** +* \file +* \brief Class bbtk::wxEditionDialog . +*/ + + +#include "wxEditionDialog.h" + + +namespace bbtk +{ + //========================================================================= + + wxEditionDialog::wxEditionDialog(wxGUIEditorGraphicBBS *parent,GBlackBoxModel *model):wxDialog(parent,wxID_ANY,"", wxDefaultPosition, wxSize(480, 640)) + { + _model=model; + std::string title = "BlackBox Editing - Name:"; + title+=_model->getBBTKName(); + title+=" Type:"; + title+=_model->getBBTKType(); + SetTitle(wxT(title)); + + constructBlackBoxEditionDialog(); + } + + //========================================================================= + + wxEditionDialog::wxEditionDialog(wxGUIEditorGraphicBBS *parent,wxVtkSceneManager* scene):wxDialog(parent, wxID_ANY, "", wxDefaultPosition, wxSize(300, 300)) + { + + } + + //========================================================================= + + wxEditionDialog::~wxEditionDialog() + { + + } + + //========================================================================= + + void wxEditionDialog::constructBlackBoxEditionDialog() + { + wxBoxSizer *sizerDialog = new wxBoxSizer(wxVERTICAL); + + wxStaticText *text = new wxStaticText(this, -1, wxT("Input Ports")); + + std::vector lstInputs = _model->getInputPorts(); + wxGridSizer *sizer = new wxGridSizer(lstInputs.size(),3,5,5); + for(int i = 0;igetBBTKName()),wxDefaultPosition,wxSize(100,30)); + wxStaticText *lblType = new wxStaticText(this, -1, wxT(port->getBBTKType()),wxDefaultPosition,wxSize(150,30)); + wxTextCtrl *txtValue = new wxTextCtrl(this, -1, wxT(""),wxDefaultPosition,wxSize(50,15)); + + if(port->getValue()!="") + { + txtValue->SetLabel(wxT(port->getValue())); + } + + if(port->isConnected()) + { + std::string connected = "--Port Connected--"; + txtValue->SetLabel(wxT(connected)); + txtValue->SetEditable(false); + } + + _lstNames.push_back(lblName); + _lstTypes.push_back(lblType); + _lstValues.push_back(txtValue); + + sizer->Add(lblName,0,wxEXPAND,5); + sizer->Add(lblType,0,wxCENTRE|wxEXPAND,5); + sizer->Add(txtValue,0,wxEXPAND,5); + + } + + wxBoxSizer *buts = new wxBoxSizer(wxHORIZONTAL); + wxButton *okButton = new wxButton(this, 1003, wxT("Ok"),wxDefaultPosition, wxSize(70, 30)); + wxButton *closeButton = new wxButton(this, 1004, wxT("Close"), wxDefaultPosition, wxSize(70, 30)); + + // connect command event handlers + Connect(1003,wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxEditionDialog::onClickOk)); + Connect(1004,wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxEditionDialog::onClickClose)); + + buts->Add(okButton,0,wxCENTRE|wxEXPAND,5); + buts->Add(closeButton,0,wxCENTRE|wxEXPAND,5); + + sizerDialog->Add(text,0,wxALIGN_TOP,10); + sizerDialog->AddSpacer(5); + sizerDialog->Add(sizer,0,wxALIGN_CENTER,10); + sizerDialog->Add(buts,0,wxALIGN_CENTER | wxTOP | wxBOTTOM,10); + + SetSizer(sizerDialog); + + Centre(); + ShowModal(); + Destroy(); + + } + + //========================================================================= + + void wxEditionDialog::onClickOk(wxCommandEvent& event) + { + + for(int i=0;i<_lstValues.size();i++) + { + std::string text = _lstValues[i]->GetLabelText(); + _model->setValueToInputPort(i,text); + } + + Close(true); + } + + //========================================================================= + + void wxEditionDialog::onClickClose(wxCommandEvent& event) + { + Close(true); + } + + //========================================================================= + +} // EO namespace bbtk + +// EOF + diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxEditionDialog.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxEditionDialog.h new file mode 100644 index 0000000..95dc0ad --- /dev/null +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxEditionDialog.h @@ -0,0 +1,97 @@ +/*========================================================================= +Program: bbtk +Module: $RCSfile$ +Language: C++ +Date: $Date$ +Version: $Revision$ +=========================================================================*/ + +/* --------------------------------------------------------------------- + +* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) +* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux +* +* 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. +* ------------------------------------------------------------------------ */ + + + +/** +* \file +* \brief Class bbtk::wxEditionDialog : abstract black-box interface. +*/ + +/** +* \class bbtk::wxEditionDialog +* \brief +*/ + +#ifndef __wxEditionDialog_h__ +#define __wxEditionDialog_h__ + +//Includes same project +#include "bbtkwxGUIEditorGraphicBBS.h" +#include "GPortModel.h" +#include "wxVtkSceneManager.h" + +//Includes wxWidgets +#include +#include + +//Includes creaMaracasVisu + +//Includes std +#include + + + + +namespace bbtk +{ + + class wxGUIEditorGraphicBBS; + + class wxVtkSceneManager; + + class wxEditionDialog : public wxDialog + { + public: + wxEditionDialog(wxGUIEditorGraphicBBS *parent,wxVtkSceneManager* scene); + wxEditionDialog(wxGUIEditorGraphicBBS *parent,GBlackBoxModel *model); + ~wxEditionDialog(); + + void constructBlackBoxEditionDialog(); + void onClickOk(wxCommandEvent& event); + void onClickClose(wxCommandEvent& event); + + private: + wxAuiManager *_dialogAUIMgr; + wxPanel *_panel; + std::vector _lstValues; + std::vector _lstTypes; + std::vector _lstNames; + GBlackBoxModel *_model; + + protected: + + }; + + +} +// namespace bbtk +#endif + diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx index 5995ea2..fc8b048 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx @@ -133,6 +133,13 @@ namespace bbtk } //========================================================================= + + void wxGEditorTabPanel::editDiagramParameters(wxVtkSceneManager* scene) + { + _panelsManager->editDiagramParameters(scene); + } + + //========================================================================= } // EO namespace bbtk diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h index 184714c..6d6c39a 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h @@ -83,6 +83,7 @@ namespace bbtk void updateStatusBar(std::string textStatus); std::string getDiagramScript(); void editBlackBox(GBlackBoxModel *bbmodel); + void editDiagramParameters(wxVtkSceneManager* scene); private: diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx index 6410671..1e9061e 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx @@ -110,6 +110,13 @@ namespace bbtk //========================================================================= + void wxTabPanelsManager::editDiagramParameters(wxVtkSceneManager* scene) + { + _parent->editDiagramParameters(scene); + } + + //========================================================================= + } // EO namespace bbtk diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h index 0b168a6..556a504 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h @@ -76,7 +76,7 @@ namespace bbtk void updateStatusBar(std::string textStatus); std::string getActualDiagramScript(); void editBlackBox(GBlackBoxModel *bbmodel); - + void editDiagramParameters(wxVtkSceneManager* scene); private: -- 2.45.1