namespace bbtk
{
- class GObjectModel //: public Observable
+ class GObjectModel : public Observable
{
public:
void Observable::notifyObservers()
{
- int i;
- for(i=0;i<_observers.size();i++)
+ if(_changed)
{
- _observers[i]->update();
- }
- _changed=false;
+ int i;
+
+ for(i=0;i<_observers.size();i++)
+ {
+ _observers[i]->update();
+ }
+ _changed=false;
+ }
}
//=========================================================================
//=========================================================================
+ void Observable::addObserver(Observer *observer)
+ {
+ _observers.push_back(observer);
+ }
+
} // EO namespace bbtk
// EOF
configureBaseView();
- /* JUST TO TEST
+ /*//JUST TO TEST
vtkConeSource *cone = vtkConeSource::New();
cone->SetResolution(10);
getRenderer()->AddActor(_pointVtkActor);
- */
-
+
+*/
/////////////////////
//getRenderer()->AddActor(act);
void wxVtkSceneManager::configureBaseView()
{
- vtkInteractorStyleImage *style = vtkInteractorStyleImage::New();
- _baseView->GetWxVTKRenderWindowInteractor()->SetInteractorStyle(style);
+ vtkInteractorStyleBaseView2D *interactorstylebaseview = vtkInteractorStyleBaseView2D::New();
+
+ _baseView->SetInteractorStyleBaseView(interactorstylebaseview);
+
+ wxVTKRenderWindowInteractor *iren = _baseView->GetWxVTKRenderWindowInteractor();
+ interactorstylebaseview->SetInteractor ( iren );
+ iren->SetInteractorStyle(interactorstylebaseview);
+ interactorstylebaseview->SetwxVtkBaseView(_baseView);
+
//_baseView->GetRenderer()->SetActiveCamera(_baseView->GetCamera());
//_baseView->GetRenderer()->ResetCamera ();
//_baseView->GetCamera()->SetParallelProjection(true);
double zz = 0;
_baseView->TransCoordScreenToWorld(xx,yy,zz);
model->setInicPoint(xx,yy,zz);
- //model->addObserver(view);
+ model->addObserver(view);
//Iterate and create the input ports
- std::map<std::string, BlackBoxInputDescriptor*> descriptorMap = descriptor->GetInputDescriptorMap();
- std::map<std::string, BlackBoxInputDescriptor*>::iterator it;
+ std::map<std::string, BlackBoxInputDescriptor*> descriptorInMap = descriptor->GetInputDescriptorMap();
+ std::map<std::string, BlackBoxInputDescriptor*>::iterator itInput;
//ERASE
cantTemp=0;
- for(it = descriptorMap.begin(); it != descriptorMap.end(); ++it)
+ for(itInput = descriptorInMap.begin(); itInput != descriptorInMap.end(); ++itInput)
{
- BlackBoxInputDescriptor *desc = it->second;
+ BlackBoxInputDescriptor *desc = itInput->second;
createGInputPort(desc,model);
//ERASE
}
+ //Iterate and create the output ports
+ std::map<std::string, BlackBoxOutputDescriptor*> descriptorOutMap = descriptor->GetOutputDescriptorMap();
+ std::map<std::string, BlackBoxOutputDescriptor*>::iterator itOutput;
+
+ //ERASE
+ cantTemp=0;
+
+ for(itOutput = descriptorOutMap.begin();itOutput != descriptorOutMap.end(); ++itOutput)
+ {
+ BlackBoxOutputDescriptor *desc = itOutput->second;
+ createGOutputPort(desc,model);
+
+ //ERASE
+ cantTemp+=2;
+ }
+
+
//Associates the view with the correspondent renderer and the model.
//(NOTE: Refresh is only made by the view)
view->setModel(model);
//Refresh renderwindow with new objects
refreshRenderWindow();
+ //Register the controller of the new object
registerController((InteractorStyleMaracas*) controller);
+ //Add the object to the objects list (only boxes and connectors)
+ objects.push_back(model);
+
}
//=========================================================================
- void wxVtkSceneManager::createGInputPort(BlackBoxInputDescriptor *desc,GBlackBoxModel *blackBox)
+ void wxVtkSceneManager::createGOutputPort(BlackBoxOutputDescriptor *desc,GBlackBoxModel *blackBox)
{
int type = GPORT;
GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
model->registerInBox(blackBox);
- blackBox->addInputPort(model);
-
+ blackBox->addOutputPort(model);
//Prepares the initial model
double xx = 0;
//Associates the controller with the correspondent model and view
controller->setModelAndView(model,view);
+
+ //Register the controller of the new object
+ registerController((InteractorStyleMaracas*) controller);
}
//=========================================================================
- void wxVtkSceneManager::createGOutputPort(BlackBoxOutputDescriptor *desc,GBlackBoxModel *blackBox)
+ void wxVtkSceneManager::createGInputPort(BlackBoxInputDescriptor *desc,GBlackBoxModel *blackBox)
{
int type = GPORT;
GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
model->registerInBox(blackBox);
- blackBox->addOutputPort(model);
+ blackBox->addInputPort(model);
+
+
+ //Prepares the initial model
+ double xx = 0;
+ double yy = 0;
+ double zz = 0;
+ blackBox->getInicPoint(xx,yy,zz);
+
+ xx--;
+ yy+=cantTemp;
+ model->setInicPoint(xx,yy,zz);
+
+ //Associates the view with the correspondent renderer and the model.
+ //(NOTE: Refresh is only made by the view)
+ view->setModel(model);
+ view->setBaseView(_baseView);
+ view->initVtkObjects();
+
+ //Associates the controller with the correspondent model and view
+ controller->setModelAndView(model,view);
+
+ //Register the controller of the new object
+ registerController((InteractorStyleMaracas*) controller);
}
//=========================================================================
//Includes creaMaracasVisu
#include <wxVtk3DBaseView.h>
#include <InteractorStyleMaracas.h>
+#include <vtkInteractorStyleBaseView2D.h>
//Includes vtk
#include <vtkRenderWindow.h>
int _id;
wxVtk3DBaseView *_baseView;
+ std::vector<GObjectModel*> objects;
+ std::vector<GObjectModel*> selectedObjects;
void refreshRenderWindow();
{
int X,Y;
wxVTKRenderWindowInteractor *_wxVTKiren;
- _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
+ _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
_wxVTKiren->GetEventPosition( X , Y );
int state = _model->getState();
{
int X,Y;
wxVTKRenderWindowInteractor *wxVTKiren;
- wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
+ wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
wxVTKiren->GetEventPosition(X,Y);
//MouseClickLeft(X,Y);
namespace bbtk
{
- class vtkGObjectView //: public Observer
+ class vtkGObjectView : public Observer
{
public:
double xInic, yInic,zInic,xFin, yFin,zFin;
_model->getInicPoint(xInic,yInic,zInic);
_model->getFinalPoint(xFin, yFin,zFin);
- cout<<"RaC ----------"<<endl;
- cout<<"RaC vtkGPortView::createVtkObjects() inic:"<<xInic<<" "<<yInic<<" "<<zInic<<endl;
- cout<<"RaC vtkGPortView::createVtkObjects() fin:"<<xFin<<" "<<yFin<<" "<<zFin<<endl;
_pts->SetPoint(0, xInic, yInic, 0 );
_pts->SetPoint(1, xInic, yFin, 0 );
//=========================================================================
void wxGUIEditorGraphicBBS::initHelpHTMLBrowser()
{
-
+ //TO FIX THE PATH OF BBTK BIN IN ORDER TO USE REGENERATE EXECUTABLES
+ //RegenerateAll();
_helpHtmlBrowser = new WxGUIHtmlBrowser(this,wxSize(200,0));
_frameAUIMgr->AddPane(_helpHtmlBrowser,wxAuiPaneInfo().Right().MinSize(200,200));
}
_frameAUIMgr->AddPane(_pkgBrowser,wxAuiPaneInfo().Left().MinSize(200,200).CloseButton(false));
}
+ //================================================================
+
+ void wxGUIEditorGraphicBBS::DoRegeneratePackageDoc( const std::string& pack )
+ {
+ std::string mess("Regenerating doc for package '");
+ if (pack!="-a"){
+ mess += pack + "'";
+ }
+ else
+ {
+ mess = "Regenerating doc for all packages";
+ }
+
+ mess += " ... please wait";
+
+ SetStatusText( std2wx(mess) );
+
+ //BBTK_BUSY_CURSOR;
+
+ std::string command;
+ #if defined(WIN32)
+ command = "\"";
+ #endif
+ command += ConfigurationFile::GetInstance().Get_bin_path();
+ command += ConfigurationFile::GetInstance().Get_file_separator();
+ command += "bbRegeneratePackageDoc";
+ #if defined(WIN32)
+ command += "\"";
+ #endif
+
+ command += " " + pack + " -q";
+ bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
+
+ if ( ! system ( command.c_str() ) )
+ {
+ SetStatusText( _T("Done !"));
+ /*
+ wxMessageBox(_T("Done !"),_T("Regenerate package '")
+ +std2wx(pack)+_T("' doc"),
+ wxOK | wxICON_INFORMATION);
+ */
+ }
+ else
+ {
+ SetStatusText( _T("Done !"));
+ wxString err(_T("An error occured while running '"));
+ err += bbtk::std2wx(command) + _T("'");
+ wxMessageBox(err,_T("Regenerate package doc"),wxOK | wxICON_ERROR);
+ }
+ }
+
+ //================================================================
+ void wxGUIEditorGraphicBBS::DoRegenerateBoxesLists()
+ {
+ SetStatusText( _T("Regenerating boxes lists ... please wait") );
+ //BBTK_BUSY_CURSOR ;
+
+ std::string command;
+ #if defined(WIN32)
+ command = "\"";
+ #endif
+ command += ConfigurationFile::GetInstance().Get_bin_path();
+ command += ConfigurationFile::GetInstance().Get_file_separator();
+ command += "bbRegenerateBoxesLists";
+
+ #if defined(WIN32)
+ command += "\"";
+ #endif
+ command += " -q";
+
+ bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
+
+ if ( ! system ( command.c_str() ) )
+ {
+ SetStatusText( _T("Done !"));
+ /*
+ wxMessageBox(_T("Done !"),_T("Regenerate boxes lists"),
+ wxOK | wxICON_INFORMATION);
+ */
+ }
+ else
+ {
+ SetStatusText( _T("Done !"));
+ wxString err(_T("An error occured while running '"));
+ err += bbtk::std2wx(command) + _T("'");
+ wxMessageBox(err,_T("Regenerate boxes lists"),wxOK | wxICON_ERROR);
+ }
+ }
+
+ //================================================================
+ void wxGUIEditorGraphicBBS::RegenerateAll()
+ {
+ DoRegeneratePackageDoc("-a");
+ DoRegenerateBoxesLists();
+ }
+
+ //================================================================
+
/*****************************************************
/* HANDLERS
/*****************************************************/
#include <bbtkWxGUIPackageBrowser2.h>
#include <bbtkWxGUIHtmlBrowser.h>
#include <bbtkBlackBoxDescriptor.h>
+#include <bbtkConfigurationFile.h>
//Includes vtk
void initPackageBrowser();
void initHelpHTMLBrowser();
+ void RegenerateAll();
+ void DoRegeneratePackageDoc(const std::string& pack);
+ void DoRegenerateBoxesLists();
+
void OnToolLeftClick(wxCommandEvent& event);
void OnExit(wxCommandEvent& event);