From: corredor <> Date: Mon, 29 Mar 2010 16:08:59 +0000 (+0000) Subject: Connection with BBTK and capturing black bbox descriptor X-Git-Tag: v1_0_0~117 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=c8402dc4438aae412055d54bacf221c1449a83d6;p=bbtkGEditor.git Connection with BBTK and capturing black bbox descriptor --- diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx index aa3675e..4fc3e68 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx @@ -42,9 +42,7 @@ namespace bbtk //========================================================================= GBlackBoxModel::GBlackBoxModel() - { - - + { } //========================================================================= @@ -53,7 +51,13 @@ namespace bbtk } //========================================================================= + void GBlackBoxModel::updateBlackBox(BlackBoxDescriptor::Pointer descriptor)//virtual + { + _desc=descriptor; + std::cout<<"RaC Box author:"<<_desc->GetAuthor()< + namespace bbtk { @@ -64,19 +65,19 @@ namespace bbtk GBlackBoxModel(); ~GBlackBoxModel(); - //Public methods - + //Public methods + virtual void updateBlackBox(BlackBoxDescriptor::Pointer descriptor); private: //Attributes - + BlackBoxDescriptor::Pointer _desc; //Private Methods protected: //Protected methods - + }; diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx index 47008da..bcfd60d 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx @@ -116,6 +116,11 @@ namespace bbtk //========================================================================= + void GObjectModel::updateBlackBox(BlackBoxDescriptor::Pointer descriptor)//virtual + { + } + + //========================================================================= } // EO namespace bbtk // EOF diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h index ed0a3e2..bdffa06 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h @@ -51,6 +51,8 @@ Version: $Revision$ //Includes std #include +#include + namespace bbtk { @@ -72,6 +74,7 @@ namespace bbtk void setState(int state); int getState(); virtual bool isPointInside(double x,double y, double z); + virtual void updateBlackBox(BlackBoxDescriptor::Pointer descriptor); private: diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx index 659856b..d9fbd6c 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx @@ -53,6 +53,7 @@ namespace bbtk configureBaseView(); + /* JUST TO TEST vtkConeSource *cone = vtkConeSource::New(); cone->SetResolution(10); @@ -95,7 +96,7 @@ namespace bbtk getRenderer()->AddActor(_pointVtkActor); - + */ ///////////////////// @@ -120,13 +121,14 @@ namespace bbtk void wxVtkSceneManager::configureBaseView() { - vtkInteractorStyleImage *temp = vtkInteractorStyleImage::New(); - _baseView->GetWxVTKRenderWindowInteractor()->SetInteractorStyle(temp); + vtkInteractorStyleImage *style = vtkInteractorStyleImage::New(); + _baseView->GetWxVTKRenderWindowInteractor()->SetInteractorStyle(style); //_baseView->GetRenderer()->SetActiveCamera(_baseView->GetCamera()); //_baseView->GetRenderer()->ResetCamera (); //_baseView->GetCamera()->SetParallelProjection(true); - _baseView->GetRenderer()->SetBackground(1,1,1); + _baseView->GetRenderer()->SetBackground(0.9,0.9,0.9); + _baseView->GetRenderer()->GradientBackgroundOff(); _baseView->Refresh(); } @@ -141,35 +143,37 @@ namespace bbtk vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type); GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type); + BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxName); + //Prepares the initial model - cout<<"RaC Size:"<<_baseView->GetRenWin()->GetSize()[1]<GetRenWin()->GetSize()[1]-y; double zz = 0; - _baseView->TransCoordScreenToWorld(xx,yy,zz); + model->setInicPoint(xx,yy,zz); + model->updateBlackBox(descriptor); + //Associates the view with the correspondent renderer and the model. //(NOTE: Refresh is only made by the view) - model->setInicPoint(xx,yy,zz); view->setModel(model); view->setBaseView(_baseView); view->initVtkObjects(); - //Refresh renderwindow with new objects - refreshRenderWindow(); - //Associates the controller with the correspondent model and view controller->setModelAndView(model,view); + + //Refresh renderwindow with new objects + refreshRenderWindow(); registerController((InteractorStyleMaracas*) controller); + } //========================================================================= void wxVtkSceneManager::registerController(InteractorStyleMaracas *param) { - cout<<"RaC wxVtkSceneManager::registerController param:"<GetInteractorStyleBaseView(); baseViewControlManager->AddInteractorStyleMaracas( param ); } @@ -197,7 +201,7 @@ namespace bbtk bool wxVtkSceneManager::OnMouseMove() { - cout<<"RaC wxVtkSceneManager::OnMouseMove "<isPointInside(X,Y)) { - _model->setState(HIGHLIGHTED); + _model->setState(HIGHLIGHTED); + } + } + if(state==HIGHLIGHTED) + { + if(!_view->isPointInside(X,Y)) + { + _model->setState(NOTHING_HAPPENS); } } diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectsMVCFactory.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectsMVCFactory.cxx index a03ae69..9a32bfe 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectsMVCFactory.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectsMVCFactory.cxx @@ -44,8 +44,14 @@ namespace bbtk GObjectsMVCFactory* GObjectsMVCFactory:: instance = NULL; GObjectsMVCFactory::GObjectsMVCFactory() - { - + { + _interpreter =Interpreter::New(); + _interpreter->SetCommandLine(true); + std::stringstream* buf = new std::stringstream; + *buf << "exec freeze_no_error" << std::endl; + *buf << "message max 0" << std::endl; + *buf << "include *" << std::endl; + _interpreter->InterpretBuffer(buf); } //========================================================================= @@ -55,7 +61,15 @@ namespace bbtk } //========================================================================= + BlackBoxDescriptor::Pointer GObjectsMVCFactory::getBlackBoxDescriptor(std::string packageName, std::string boxName) + { + Factory::Pointer factory = _interpreter->GetExecuter()->GetFactory(); + Package::Pointer k = factory->GetPackage(packageName); + std::map< std::string, BlackBoxDescriptor::Pointer> mapDesc = k->GetDescriptorMap(); + return mapDesc[boxName]; + } + //========================================================================= GObjectsMVCFactory* GObjectsMVCFactory :: getInstance() { if(instance == NULL){ diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectsMVCFactory.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectsMVCFactory.h index d02e18b..40bf577 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectsMVCFactory.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectsMVCFactory.h @@ -58,6 +58,11 @@ Version: $Revision$ //Includes std #include + +#include +#include +#include + namespace bbtk { @@ -73,14 +78,18 @@ namespace bbtk //Public methods static GObjectsMVCFactory* getInstance(); static void destroyInstance(); + BlackBoxDescriptor::Pointer getBlackBoxDescriptor(std::string packageName, std::string boxName); vtkGObjectView* createGObjectView(int type); GObjectController* createGObjectController(int type); GObjectModel* createGObjectModel(int type); + Interpreter::Pointer _interpreter; + private: //Attributes static GObjectsMVCFactory* instance; + //Private Methods diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx index 1dc1d76..684670c 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx @@ -54,6 +54,15 @@ namespace bbtk void vtkGBlackBoxView::refresh() { //paint(); + if(_model->getState()==HIGHLIGHTED) + { + _objectActor->GetProperty()->SetColor(0.0,0.2,0.5); + } + else + { + _objectActor->GetProperty()->SetColor(0.3,0.2,0.2); + } + _baseView->GetRenderer()->Render(); } //========================================================================= @@ -93,6 +102,8 @@ namespace bbtk _bboxMapper->SetInput(_pd); _objectActor->SetMapper(_bboxMapper); + _objectActor->GetProperty()->SetColor(0.3,0.2,0.2); + } //========================================================================= diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx index 7e4d139..5e322e1 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx @@ -64,7 +64,7 @@ namespace bbtk { _objectActor->GetProperty()->SetColor(1,0,0); } - + _baseView->GetRenderer()->Render(); //paint(); } diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index f2e6e08..2d93e2f 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -162,8 +162,7 @@ namespace bbtk break; case 15 : BlackBoxDescriptor* desc = _pkgBrowser->GetActualSelected(); - cout<<"RaC GetActualSelected desc:"<GetAuthor()<createGBlackBox(x,y,packageName, boxName); - cout<<"RaC DyD:"<