//=========================================================================
+ GBlackBoxModel* GPortModel::getParentBox()
+ {
+ return _parentBox;
+ }
+
+ //=========================================================================
+
} // EO namespace bbtk
// EOF
void registerInBox(GBlackBoxModel *blackBox,int portType, int pos);
void updatePortPosition();
int getPortType();
+ GBlackBoxModel* getParentBox();
virtual std::string getStatusText();
private:
//=========================================================================
+ std::string wxVtkSceneManager::getDiagramScript()
+ {
+ bool existsExec=false;
+
+ std::vector<std::string> packages;
+ std::vector<int> boxes;
+ std::vector<int> connections;
+ std::vector<int> execBoxes;
+
+ std::map<int, GObjectController*>::iterator it;
+
+ for(it = _controllers.begin(); it != _controllers.end(); ++it)
+ {
+ GObjectController *desc = it->second;
+ int type = desc->getGObjectType();
+
+ if(type==GBLACKBOX)
+ {
+ GBlackBoxModel *mod = (GBlackBoxModel*)desc->getModel();
+
+ std::string pkg = mod->getBBTKPackage();
+ bool existsPkg = false;
+ for(int t = 0;t<packages.size() && existsPkg == false;t++)
+ {
+ if(packages[t]==pkg)
+ {
+ existsPkg=true;
+ }
+ }
+ if(!existsPkg)
+ {
+ packages.push_back(pkg);
+ }
+
+
+ boxes.push_back(it->first);
+ if(mod->isExecutable())
+ {
+ execBoxes.push_back(it->first);
+ existsExec=true;
+ }
+ }
+ else if(type==GCONNECTOR)
+ {
+ connections.push_back(it->first);
+ }
+ }
+
+ std::string script = "";
+ script+="# BBTK GEditor Script\n";
+ script+="# ----------------------\n";
+ if(existsExec)
+ {
+ int i;
+ for(i = 0; i<packages.size();i++)
+ {
+ script+="load ";
+ script+=packages[i];
+ script+="\n";
+ }
+
+ for(i = 0; i<boxes.size();i++)
+ {
+ script+="new ";
+ int id = boxes[i];
+ GObjectController *control = _controllers[id];
+ GBlackBoxModel *model = (GBlackBoxModel*)control->getModel();
+
+ script+=model->getBBTKType();
+ script+=" ";
+ script+=model->getBBTKName();
+ script+="\n";
+ }
+
+ for(i = 0; i<connections.size();i++)
+ {
+ script+="connect ";
+ int id = connections[i];
+ GObjectController *control = _controllers[id];
+ GConnectorModel *model = (GConnectorModel*)control->getModel();
+
+ //Start Connection info
+ GPortModel *start = model->getStartPort();
+ script+=start->getParentBox()->getBBTKName();
+ script+=".";
+ script+=start->getBBTKName();
+
+ script+=" ";
+
+ //End Connection info
+ GPortModel *end = model->getEndPort();
+ script+=end->getParentBox()->getBBTKName();
+ script+=".";
+ script+=end->getBBTKName();
+
+ script+="\n";
+ }
+
+ for(i = 0; i<execBoxes.size();i++)
+ {
+ script+="exec ";
+ int id = execBoxes[i];
+ GObjectController *control = _controllers[id];
+ GBlackBoxModel *model = (GBlackBoxModel*)control->getModel();
+
+ script+=model->getBBTKName();
+ script+="\n";
+ }
+
+ }
+
+ return script;
+ }
+
+ //=========================================================================
+
} // EO namespace bbtk
// EOF
void displayBlackBoxInfo(std::string packageName, std::string boxName);
void updateStatusBar(std::string textStatus);
+ std::string getDiagramScript();
+
private:
wxToolBar *_toolbar = new wxToolBar(this, wxID_ANY);
//Adds a tool btn to the toolbar
- _toolbar->AddTool(wxID_NEW,_T("New"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New tab"), _T("Create a new panel tab"));
+ _toolbar->AddTool(1000,_T("New"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New tab"), _T("Create a new panel tab"));
+ _toolbar->AddTool(1001,_T("Execute"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("Execute actual diagram"), _T("Execute actual diagram"));
_toolbar->SetMargins( 2, 2 );
_toolbar->Realize();
SetToolBar(_toolbar);
// connect command event handlers
- Connect(wxID_NEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnToolLeftClick));
+ Connect(1000,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnToolLeftClick));
+ Connect(1001,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnToolLeftClick));
}
//=========================================================================
//=========================================================================
+ void wxGUIEditorGraphicBBS::executeActualDiagram()
+ {
+ std::string script = _tabsMgr->getActualDiagramScript();
+ cout<<"RaC wxGUIEditorGraphicBBS::executeActualDiagram SCRIPT"<<endl;
+ cout<<script<<endl;
+
+
+ std::string separator = ConfigurationFile::GetInstance().Get_file_separator ();
+ std::string dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
+ std::string filename = dir + separator + "tmp_bbtk.bbs";
+
+ ofstream tempFile;
+ tempFile.open(filename.c_str());
+ tempFile << script;
+ tempFile.close();
+
+ std::string command = "\"";
+
+ #ifdef WIN32
+ command += "\"";
+ #endif
+
+ //command += ConfigurationFile::GetInstance().Get_bin_path();
+ command +="C:/RaC/CREATIS/bbtkBIN/RelWithDebInfo//";
+
+ #ifdef MACOSX
+ command += separator + "bbi.app/Contents/MacOS/bbi\" ";
+ #else
+ command += separator + "bbi\" ";
+ #endif
+ command += "\""+filename + "\"";
+
+ #ifdef WIN32
+ command += "\"";
+ #endif
+
+ command += " & ";
+
+ printf ("RaC wxGUIEditorGraphicBBS::executeActualDiagram %s \n" , command.c_str() );
+ system( command.c_str() );
+ }
+
+ //=========================================================================
+
/*****************************************************
/* HANDLERS
/*****************************************************/
{
switch (event.GetId())
{
- case wxID_NEW :
- _tabsMgr->addNewTab();
- break;
+ case 1000 :
+ _tabsMgr->addNewTab();
+ break;
+
+ case 1001 :
+ executeActualDiagram();
+ break;
}
}
#include <wx/grid.h>
//Includes std
+#include <iostream>
+#include <fstream>
namespace bbtk
{
wxAuiNotebook* getAuiNotebook();
void displayBlackBoxInfo(std::string packageName, std::string boxName);
void updateStatusBar(std::string textStatus);
+ void executeActualDiagram();
void RegenerateAll();
void DoRegeneratePackageDoc(const std::string& pack);
//=========================================================================
+ std::string wxGEditorTabPanel::getDiagramScript()
+ {
+ return _sceneManager->getDiagramScript();
+ }
+
+ //=========================================================================
+
} // EO namespace bbtk
// EOF
void displayBlackBoxInfo(std::string packageName, std::string boxName);
void updateStatusBar(std::string textStatus);
+ std::string getDiagramScript();
private:
//=========================================================================
+ std::string wxTabPanelsManager::getActualDiagramScript()
+ {
+ return _actual->getDiagramScript();
+ }
+
+ //=========================================================================
+
} // EO namespace bbtk
void displayBlackBoxInfo(std::string packageName, std::string boxName);
void updateStatusBar(std::string textStatus);
+ std::string getActualDiagramScript();
private: