From 1b3060e78b445e19d51933556fb072cc90e30c99 Mon Sep 17 00:00:00 2001 From: corredor <> Date: Thu, 8 Apr 2010 13:32:37 +0000 Subject: [PATCH] Properties panel and black box text info --- .../bbsKernelEditorGraphic/GObjectModel.cxx | 28 +++++++ .../bbsKernelEditorGraphic/GObjectModel.h | 8 ++ .../bbsKernelEditorGraphic/GlobalConstants.h | 2 +- .../wxVtkSceneManager.cxx | 22 ++++- .../wxVtkSceneManager.h | 3 + .../vtkGBlackBoxView.cxx | 63 ++++++++++++++ .../bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h | 8 +- .../bbtkwxGUIEditorGraphicBBS.cxx | 9 ++ .../bbtkwxGUIEditorGraphicBBS.h | 4 + .../wxPropertiesPanel.cxx | 71 ++++++++++++++++ .../bbsWxGUIEditorGraphic/wxPropertiesPanel.h | 83 +++++++++++++++++++ 11 files changed, 295 insertions(+), 6 deletions(-) create mode 100644 lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxPropertiesPanel.cxx create mode 100644 lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxPropertiesPanel.h diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx index f6d8c4d..d2212d4 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx @@ -147,6 +147,34 @@ namespace bbtk //========================================================================= + std::string GObjectModel::getBBTKType() + { + return _bbtkType; + } + + //========================================================================= + + void GObjectModel::setBBTKType(std::string obtype) + { + _bbtkType = obtype; + } + + //========================================================================= + + std::string GObjectModel::getBBTKName() + { + return _bbtkName; + } + + //========================================================================= + + void GObjectModel::setBBTKName(std::string obname) + { + _bbtkName = obname; + } + + //========================================================================= + } // EO namespace bbtk // EOF diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h index b610386..eefd07c 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h @@ -82,7 +82,12 @@ namespace bbtk int getGObjectType(); void setGObjectType(int obtype); + + std::string getBBTKType(); + void setBBTKType(std::string obtype); + std::string getBBTKName(); + void setBBTKName(std::string obname); private: @@ -104,6 +109,9 @@ namespace bbtk int _state; int _gObjectType; + std::string _bbtkType; + std::string _bbtkName; + //Protected methods }; diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h index 2beacdb..4fb178e 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h @@ -59,7 +59,7 @@ namespace bbtk const int CREATING_CONTOUR=106; // Object dimensions - const double BOX_HEIGHT=0.1; + const double BOX_HEIGHT=0.15; const double BOX_WIDTH=1.0; const double PORT_HEIGHT=0.04; const double PORT_WIDTH=0.04; diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx index 3c79b61..005c52f 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx @@ -97,7 +97,15 @@ namespace bbtk getRenderer()->AddActor(_pointVtkActor); - + // Create a vector text + vtkVectorText* vecText = vtkVectorText::New(); + vecText->SetText("vtkVectorText"); + + vtkPolyDataMapper* txtMapper = vtkPolyDataMapper::New(); + txtMapper->SetInputConnection( vecText->GetOutputPort()); + vtkActor* txtActor = vtkActor::New(); + txtActor->SetMapper(txtMapper); + //getRenderer()->AddActor(txtActor); // ******* TO ERASE ******* ///////////////////// @@ -164,6 +172,15 @@ namespace bbtk _baseView->TransCoordScreenToWorld(xx,yy,zz); model->setInicPoint(xx,yy,zz); + int cantObjects = _objects.size(); + cantObjects++; + std::stringstream stream; + stream << "Object " << cantObjects; + std::string arraystring = stream.str(); + + model->setBBTKName(arraystring); + model->setBBTKType(boxName); + model->addObserver(view); model->addObserver(this); @@ -341,15 +358,12 @@ namespace bbtk if(command==INIT_CREATION_CONTOUR) { - std::cout<<"wxVtkSceneManager::update size:"<<_objects.size()<getGObjectType()<getGObjectType() == GBLACKBOX) { GPortModel* startInputPort=((GBlackBoxModel*)_objects[i])->getStartInputPort(); - std::cout<<"wxVtkSceneManager::update "< #include +#include +#include + //Includes std #include #include diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx index 5c36d4b..64d1cec 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx @@ -57,21 +57,29 @@ namespace bbtk { _objectActor->GetProperty()->SetLineWidth(1); _objectActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B); + _nameActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B); + _typeActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B); } else if(_model->getState()==HIGHLIGHTED) { _objectActor->GetProperty()->SetLineWidth(2); _objectActor->GetProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B); + _nameActor->GetProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B); + _typeActor->GetProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B); } else if(_model->getState()==DRAG) { _objectActor->GetProperty()->SetLineWidth(1.2); _objectActor->GetProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B); + _nameActor->GetProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B); + _typeActor->GetProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B); } else if(_model->getState()==SELECTED) { _objectActor->GetProperty()->SetLineWidth(2); _objectActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B); + _nameActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B); + _typeActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B); } double xInic, yInic,zInic,xFin, yFin,zFin; @@ -83,6 +91,12 @@ namespace bbtk _pts->SetPoint(2, xFin, yFin, 0 ); _pts->SetPoint(3, xFin, yInic, 0 ); + //----------- + + updatePositionTextActors(xInic, yInic,zInic); + + //----------- + _baseView->GetRenWin()->Render(); } @@ -90,6 +104,8 @@ namespace bbtk void vtkGBlackBoxView::createVtkObjects() //virtual { + + //------------ _pts = vtkPoints::New(); vtkCellArray *lines = vtkCellArray::New(); vtkPolyData *_pd = vtkPolyData::New(); @@ -122,10 +138,57 @@ namespace bbtk _objectActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B); + //------------ + + _vectorNameText = vtkVectorText::New(); + std::string temp = _model->getBBTKName(); + _vectorNameText->SetText(temp.c_str()); + + vtkPolyDataMapper* txtMapper = vtkPolyDataMapper::New(); + txtMapper->SetInputConnection( _vectorNameText->GetOutputPort()); + _nameActor = vtkActor::New(); + _nameActor->SetMapper(txtMapper); + + //------------ + + _vectorTypeText = vtkVectorText::New(); + temp = _model->getBBTKType(); + _vectorTypeText->SetText(temp.c_str()); + + txtMapper = vtkPolyDataMapper::New(); + txtMapper->SetInputConnection( _vectorTypeText->GetOutputPort()); + _typeActor = vtkActor::New(); + _typeActor->SetMapper(txtMapper); + + //------------ + + updatePositionTextActors( xInic, yInic, zInic); + _nameActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B); + _typeActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B); + + } + + //========================================================================= + + void vtkGBlackBoxView::addVtkActors()//virtual + { + _baseView->GetRenderer()->AddActor(_nameActor); + _baseView->GetRenderer()->AddActor(_typeActor); + + vtkGObjectView::addVtkActors(); } //========================================================================= + void vtkGBlackBoxView::updatePositionTextActors(double xInic, double yInic, double zInic) + { + _nameActor->SetPosition(xInic+0.04,yInic-0.05,zInic); + _nameActor->SetScale(0.03,0.02,1); + + _typeActor->SetPosition(xInic+0.04,yInic-0.1,zInic); + _typeActor->SetScale(0.03,0.02,1); + } + } // EO namespace bbtk diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h index 05a536a..2d5ce85 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h @@ -53,7 +53,7 @@ Version: $Revision$ #include "vtkPolyDataMapper.h" #include "vtkActor.h" - +#include "vtkVectorText.h" #include "vtkRenderer.h" #include "vtkCellArray.h" @@ -80,14 +80,20 @@ namespace bbtk //Private Attributes vtkPoints *_pts; + vtkActor* _nameActor; + vtkActor* _typeActor; + vtkVectorText* _vectorNameText; + vtkVectorText* _vectorTypeText; //Private Methods + void updatePositionTextActors(double xInic, double yInic, double zInic); protected: //Protected Attributes //Protected Methods + virtual void addVtkActors(); virtual void createVtkObjects(); virtual void update(int command); }; diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index 0f87071..6049911 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -67,6 +67,7 @@ namespace bbtk initTabPanelsManager(); initPackageBrowser(); initHelpHTMLBrowser(); + initPropertiesPanel(); CreateStatusBar(); _frameAUIMgr->Update(); @@ -148,6 +149,14 @@ namespace bbtk //================================================================ + void wxGUIEditorGraphicBBS::initPropertiesPanel() + { + _propertiesPanel = new wxPropertiesPanel(this); + _frameAUIMgr->AddPane(_propertiesPanel,wxAuiPaneInfo().Right().MinSize(200,200).CloseButton(false).Floatable(false)); + } + + //================================================================ + void wxGUIEditorGraphicBBS::DoRegeneratePackageDoc( const std::string& pack ) { std::string mess("Regenerating doc for package '"); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h index 4a62c66..483d2b4 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h @@ -45,6 +45,7 @@ //Includes same project #include "wxTabPanelsManager.h" +#include "wxPropertiesPanel.h" #include "wxart_new.xpm" //Includes creaMaracasVisu @@ -66,6 +67,7 @@ #include #include #include +#include //Includes std @@ -83,6 +85,7 @@ namespace bbtk void initTabPanelsManager(); void initPackageBrowser(); void initHelpHTMLBrowser(); + void initPropertiesPanel(); void RegenerateAll(); void DoRegeneratePackageDoc(const std::string& pack); @@ -98,6 +101,7 @@ namespace bbtk wxAuiNotebook *_notebook; WxGUIPackageBrowser2 *_pkgBrowser; WxGUIHtmlBrowser *_helpHtmlBrowser; + wxPropertiesPanel *_propertiesPanel; std::string _dataDir; diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxPropertiesPanel.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxPropertiesPanel.cxx new file mode 100644 index 0000000..0118e3b --- /dev/null +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxPropertiesPanel.cxx @@ -0,0 +1,71 @@ +/*========================================================================= +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::wxPropertiesPanel . +*/ + + +#include "wxPropertiesPanel.h" + + +namespace bbtk +{ + //========================================================================= + wxPropertiesPanel::wxPropertiesPanel() + { + _grid=NULL; + } + + //========================================================================= + wxPropertiesPanel::wxPropertiesPanel(wxWindow *parent):wxPanel(parent) + { + _grid = new wxGrid(this,wxID_ANY); + _grid->CreateGrid(15,2); + _grid->SetColLabelSize(0); + _grid->SetRowLabelSize(0); + + wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); + sizer->Add(_grid,0,wxEXPAND|wxALL,0); + SetSizer(sizer); + } + + //========================================================================= + wxPropertiesPanel::~wxPropertiesPanel() + { + + } + //========================================================================= + +} // EO namespace bbtk + +// EOF + diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxPropertiesPanel.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxPropertiesPanel.h new file mode 100644 index 0000000..147fe13 --- /dev/null +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxPropertiesPanel.h @@ -0,0 +1,83 @@ +/*========================================================================= +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::wxPropertiesPanel : abstract black-box interface. +*/ + +/** +* \class bbtk::wxPropertiesPanel +* \brief +*/ + +#ifndef __wxPropertiesPanel_h__ +#define __wxPropertiesPanel_h__ + +//Includes same project + +//Includes wxWidgets +#include +#include +#include +#include + +//Includes creaMaracasVisu + +//Includes std +#include + + + + +namespace bbtk +{ + + class wxPropertiesPanel : public wxPanel + { + public: + wxPropertiesPanel(); + wxPropertiesPanel(wxWindow *parent); + ~wxPropertiesPanel(); + + private: + wxGrid *_grid; + + protected: + + }; + + +} +// namespace bbtk +#endif + -- 2.45.1