From e5a27bdba2e0cbc6a918a4fe9cbb0cc57ed85dc1 Mon Sep 17 00:00:00 2001 From: davila <> Date: Sat, 9 Oct 2010 09:01:46 +0000 Subject: [PATCH] *** empty log message *** --- .../bbsWxGUIEditorGraphic/InterpreterBBS.cxx | 115 +++++----- .../bbtkwxGUIEditorGraphicBBS.cxx | 89 ++++---- .../bbtkwxGUIEditorGraphicBBS.h | 1 + .../wxGEditorTabPanel.cxx | 74 ++++++- .../bbsWxGUIEditorGraphic/wxGEditorTabPanel.h | 18 +- .../wxTabPanelsManager.cxx | 85 ++++++- .../wxTabPanelsManager.h | 19 +- .../wxVtkSceneManager.cxx | 207 ++++++++++++++++-- .../bbsWxGUIEditorGraphic/wxVtkSceneManager.h | 24 +- 9 files changed, 496 insertions(+), 136 deletions(-) diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/InterpreterBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/InterpreterBBS.cxx index c905626..9604f18 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/InterpreterBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/InterpreterBBS.cxx @@ -1,4 +1,4 @@ -/*========================================================================= +/*========================================================================= Program: bbtk Module: $RCSfile$ Language: C++ @@ -11,26 +11,26 @@ 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 +* 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. +* 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::InterpreterBBS +* \file +* \brief Class bbtk::InterpreterBBS */ @@ -53,14 +53,14 @@ namespace bbtk } //========================================================================= - - + + //========================================================================= InterpreterBBS::InterpreterBBS( wxVtkSceneManager* sceneManager, Factory::Pointer factory ) - { + { _factory = factory; _sceneManager = sceneManager; - + _xGeneral = -100; _yGeneral = 100; _zGeneral = 900; // ????? @@ -71,34 +71,34 @@ printf("EED InterpreterBBS::createGBlackBox 900-450\n"); _countOutputs = 0; bbtk::InterpreterVirtual::Init(); - + } //========================================================================= - + //========================================================================= InterpreterBBS::~InterpreterBBS() { } //========================================================================= - - + + //========================================================================= /// Creates a new black box in current complex box void InterpreterBBS::commandNew( const std::string& boxType, const std::string& boxName) // virtual { - _yGeneral = _yGeneral - 30; + _yGeneral = _yGeneral - 30; std::string packagename = _factory->GetPackageNameOfaBlackBox(boxType); int idBox = _sceneManager->createGBlackBox( 0,0, packagename ,boxType); _countBoxes++; double px = _xGeneral + (_countBoxes%2)*100; double py = _yGeneral; - - _sceneManager->configGBlackBox(idBox, px,py,_zGeneral,boxName, false , px+100, py-10 , _zGeneral ); + + _sceneManager->configGBlackBox(idBox, px,py,_zGeneral,boxName, false , px+100, py-10 , _zGeneral ); } //========================================================================= - + //========================================================================= /// Connects the output boxOutput to the input boxInput void InterpreterBBS::commandConnection (const std::string &boxfrom, @@ -109,98 +109,99 @@ printf("EED InterpreterBBS::createGBlackBox 900-450\n"); _sceneManager->configGConnetion( boxfrom,output,boxto,input); } //========================================================================= - - + + //========================================================================= void InterpreterBBS::commandInput(const std::string &name,const std::string &box,const std::string &input,const std::string &help) { double xIn = -100+50+_countInputs*50; - double yIn = 100; - double zIn = 900; + double yIn = 100; + double zIn = 900; _sceneManager->configGComBoxInputOutputPort(true,name,xIn,yIn,zIn); _sceneManager->configGConnetion( name,name,box,input); _countInputs++; - - printf("EED InterpreterBBS::commandInput what to do with help information ..???? \n "); + + printf("EED InterpreterBBS::commandInput what to do with help information ..???? \n "); } //========================================================================= - + //========================================================================= void InterpreterBBS::commandOutput(const std::string &name,const std::string &box,const std::string &output,const std::string &help) { - _yGeneral = _yGeneral - 30; + _yGeneral = _yGeneral - 30; double xIn = -100+_countOutputs*30; - double yIn = _yGeneral; - double zIn = 900; + double yIn = _yGeneral; + double zIn = 900; _sceneManager->configGComBoxInputOutputPort(false,name,xIn,yIn,zIn); _sceneManager->configGConnetion( box,output,name,name); _countOutputs++; - - printf("EED InterpreterBBS::commandInput what to do with help information ..???? \n "); + + printf("EED InterpreterBBS::commandInput what to do with help information ..???? \n "); } //========================================================================= - - + + //========================================================================= /// sets the input of the box with the value void InterpreterBBS::commandSet(const std::string &box,const std::string &input,const std::string &value) // virtual { GBlackBoxModel *bbMod = (GBlackBoxModel *)_sceneManager->findGBox(box); - bbMod->setValueToInput(input,"\""+value+"\""); + bbMod->setValueToInput(input,"\""+value+"\""); } //========================================================================= - - //========================================================================= + + //========================================================================= void InterpreterBBS::commandDefine(const std::string &name,const std::string &pack,const std::string &scriptfilename) // virtual { _sceneManager->setComplexBox(true); - + _sceneManager->SetCbName(name); + _sceneManager->SetCbPackageName(pack); } //========================================================================= - + //========================================================================= void InterpreterBBS::commandEndDefine() // virtual { } //========================================================================= - - + + //========================================================================= - void InterpreterBBS::commandExec(const std::string &word) // virtual + void InterpreterBBS::commandExec(const std::string &word) // virtual { GBlackBoxModel *bbMod = (GBlackBoxModel *)_sceneManager->findGBox(word); - bbMod->setExecutable(true); + bbMod->setExecutable(true); } //========================================================================= - + //========================================================================= - void InterpreterBBS::commandAuthor(const std::string &author) // virtual + void InterpreterBBS::commandAuthor(const std::string &author) // virtual { - printf("EED InterpreterBBS::commandAuthor Warning !!!!! method not implemented.. \n"); + _sceneManager->SetAuthor(author); } //========================================================================= - + //========================================================================= void InterpreterBBS::commandCategory(const std::string &categorytype) // virtual { - printf("EED InterpreterBBS::commandCategory Warning !!!!! method not implemented.. \n"); + _sceneManager->SetCategory(categorytype); } //========================================================================= - + //========================================================================= void InterpreterBBS::commandDescription(const std::string &description) // virtual { - printf("EED InterpreterBBS::commandDescription Warning !!!!! method not implemented.. \n"); + _sceneManager->SetDescription(description); } //========================================================================= - - - - - + + + + + } // EO namespace bbtk // EOF diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index 4a9ec05..7addacf 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -428,7 +428,7 @@ namespace bbtk wxString fileName = openFileDialog->GetPath( ); - _tabsMgr->addNewTab(); + _tabsMgr->addNewTab( openFileDialog->GetFilename() ); bbtk::InterpreterBBS::Pointer I = bbtk::InterpreterBBS::New( this->_tabsMgr->getActualTabPanel()->getSceneManager() , _pkgBrowser->GetFactory()); @@ -451,7 +451,7 @@ namespace bbtk std::string content=""; // writing file header content += "# ----------------------------------\n"; - content += "# - BBTKGEditor v 1.1 BBS BlackBox Script\n"; + content += "# - BBTKGEditor v 1.2 BBS BlackBox Script\n"; content += "# - "; content += filename; content += "\n"; @@ -475,50 +475,54 @@ namespace bbtk } - //========================================================================= + void wxGUIEditorGraphicBBS::AskComplexBoxConfiguration() + { + std::string cbName = _tabsMgr->GetCbName(); + std::string paName = _tabsMgr->GetCbPackageName(); - void wxGUIEditorGraphicBBS::SaveActualComplexBox(std::string filename) - { wxTextEntryDialog *cbNameDialog = new wxTextEntryDialog(this,wxT("Complex Box name")); - cbNameDialog->SetValue(_T("BBBBoxName")); - std::string cbName=""; + wxTextEntryDialog *paNameDialog = new wxTextEntryDialog(this,wxT("Package name")); + + cbNameDialog->SetValue( wxString(cbName.c_str(),wxConvUTF8) ); + paNameDialog->SetValue( wxString(paName.c_str(),wxConvUTF8) ); + if (cbNameDialog->ShowModal() == wxID_OK) { wxString complexboxname = cbNameDialog->GetValue(); cbName=(const char*) (complexboxname.mb_str()); } - wxTextEntryDialog *paNameDialog = new wxTextEntryDialog(this,wxT("Package name")); - paNameDialog->SetValue(_T("PPPPackageName")); - std::string paName=""; + if (paNameDialog->ShowModal() == wxID_OK) { wxString packagename = paNameDialog->GetValue(); paName=(const char*) (packagename.mb_str()); } - if( (!cbName.empty()) || (!paName.empty()) ) - { + _tabsMgr->SetCbName(cbName); + _tabsMgr->SetCbPackageName(paName); + } - ofstream file; - file.open( filename.c_str() ); - - std::string content=""; - - // writing file header - content += "# ----------------------------------\n"; - content += "# - BBTKGEditor v 1.1 BBS BlackBox Script (Complex Box)\n"; - content += "# - "; - content += filename; - content += "\n"; - content += "# ----------------------------------\n"; - content += "\n"; - content += _tabsMgr->getActualComplexBoxBBS(cbName,paName); - file << content; - file.close(); - } + //========================================================================= + void wxGUIEditorGraphicBBS::SaveActualComplexBox(std::string filename) + { + ofstream file; + file.open( filename.c_str() ); + + std::string content=""; + // writing file header + content += "# ----------------------------------\n"; + content += "# - BBTKGEditor v 1.2 BBS BlackBox Script (Complex Box)\n"; + content += "# - "; + content += filename; + content += "\n"; + content += "# ----------------------------------\n"; + content += "\n"; + content += _tabsMgr->getActualComplexBoxBBS(); + file << content; + file.close(); } //========================================================================= @@ -543,7 +547,7 @@ namespace bbtk // writing file header content += "# ----------------------------------\n"; - content += "# - BBTKGEditor v 1.1 BBG BlackBox Diagram file\n"; + content += "# - BBTKGEditor v 1.2 BBG BlackBox Diagram file\n"; content += "# - "; content += filename; @@ -565,17 +569,21 @@ namespace bbtk wxFileDialog * saveFileDialog = new wxFileDialog(this,wxT("Save actual diagram"),wxEmptyString,wxT("NewDiagram"),wxT("*.bbg"),wxSAVE|wxOVERWRITE_PROMPT); if (saveFileDialog->ShowModal() == wxID_OK) { - wxString fileName = saveFileDialog->GetPath(); - std::string filename = (const char*) (fileName.mb_str()); - std::string filenamebbs = filename; - filenamebbs[filename.length()-1]='s'; + _tabsMgr->SetNameTabPanel( saveFileDialog->GetFilename() ); + + wxString pathfileName = saveFileDialog->GetPath(); + std::string pathfilename = (const char*) (pathfileName.mb_str()); + std::string pathfilenamebbs = pathfilename; + pathfilenamebbs[pathfilenamebbs.length()-1]='s'; - SaveActualDiagram( filename ); if (_tabsMgr->isActualDiagramComplexBox()==false) { - SaveActualBBS(filenamebbs); + SaveActualDiagram( pathfilename ); + SaveActualBBS(pathfilenamebbs); } else { - SaveActualComplexBox(filenamebbs); + AskComplexBoxConfiguration(); + SaveActualDiagram( pathfilename ); + SaveActualComplexBox(pathfilenamebbs); } //if isActualDiagramComplexBox } // if saveFileDialog } @@ -643,9 +651,10 @@ namespace bbtk { wxString fileName = openFileDialog->GetPath(); ifstream inputStream; -//EED inputStream.open(fileName.c_str()); - inputStream.open( (const char*) (fileName.mb_str()) ); - _tabsMgr->addNewTab(); + std::string fName=(const char*) (fileName.mb_str()); + inputStream.open( fName.c_str() ); + _tabsMgr->addNewTab( openFileDialog->GetFilename() ); + _tabsMgr->loadDiagram(inputStream); inputStream.close(); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h index c93405f..3a0b440 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h @@ -129,6 +129,7 @@ namespace bbtk void refreshGUIControls(); void SaveActualBBS(std::string filename); + void AskComplexBoxConfiguration(); void SaveActualComplexBox(std::string filename); void SaveActualDiagram(std::string filename); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx index 41602b8..1576f1e 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx @@ -135,9 +135,9 @@ printf ("EED %p ~wxGEditorTabPanel()\n" , this ); //========================================================================= - std::string wxGEditorTabPanel::saveComplexBoxBBS(std::string cbName, std::string paName,std::string cbAuthor,std::string cbCategory,std::string cbDescription) + std::string wxGEditorTabPanel::saveComplexBoxBBS() { - return _sceneManager->saveComplexBoxBBS(cbName,paName,cbAuthor,cbCategory,cbDescription); + return _sceneManager->saveComplexBoxBBS(); } //========================================================================= @@ -239,6 +239,76 @@ printf ("EED %p ~wxGEditorTabPanel()\n" , this ); return _sceneManager; } + //========================================================================= + std::string wxGEditorTabPanel::GetCbName() + { + return _sceneManager->GetCbName(); + } + + + //========================================================================= + std::string wxGEditorTabPanel::GetCbPackageName() + { + return _sceneManager->GetCbPackageName(); + } + + //========================================================================= + std::string wxGEditorTabPanel::GetAuthor() + { + return _sceneManager->GetAuthor(); + } + + //========================================================================= + std::string wxGEditorTabPanel::GetDescription() + { + return _sceneManager->GetDescription(); + } + + //========================================================================= + std::string wxGEditorTabPanel::GetCategory() + { + return _sceneManager->GetCategory(); + } + + //========================================================================= + void wxGEditorTabPanel::SetCbName(std::string cbName) + { + _sceneManager->SetCbName( cbName ); + } + + //========================================================================= + void wxGEditorTabPanel::SetCbPackageName(std::string packagename) + { + _sceneManager->SetCbPackageName( packagename ); + } + + + //========================================================================= + void wxGEditorTabPanel::SetAuthor(std::string author) + { + _sceneManager->SetAuthor( author ); + } + + + //========================================================================= + void wxGEditorTabPanel::SetCategory(std::string category) + { + _sceneManager->SetCategory( category ); + } + + + //========================================================================= + void wxGEditorTabPanel::SetDescription(std::string description) + { + _sceneManager->SetDescription( description ); + } + + + + + + + } // EO namespace bbtk diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h index 8330969..2ccf32d 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h @@ -95,7 +95,7 @@ namespace bbtk // Saves the actual BBS as complex box // RaC TOFIX It must be included the package of the complex box - std::string saveComplexBoxBBS(std::string cbName,std::string paName,std::string cbAuthor="",std::string cbCategory="",std::string cbDescription=""); + std::string saveComplexBoxBBS(); // Shows the dialog to edit black box parameters void editBlackBox(GBlackBoxModel *bbmodel); @@ -135,8 +135,22 @@ namespace bbtk // Receives the string from a drag and drop source as for example the BBTK Package Browser virtual bool OnDropText(wxCoord x, wxCoord y, const wxString& data); - wxVtkSceneManager* getSceneManager(); + + + void SetCbName(std::string cbName); + void SetCbPackageName(std::string packagename); + void SetAuthor(std::string author); + void SetCategory(std::string category); + void SetDescription(std::string description); + std::string GetCbName(); + std::string GetCbPackageName(); + std::string GetAuthor(); + std::string GetDescription(); + std::string GetCategory(); + + + //========================================================================= private: diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx index 2f1e1ba..0c5b96b 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx @@ -57,14 +57,14 @@ namespace bbtk } //========================================================================= - void wxTabPanelsManager::addNewTab() + void wxTabPanelsManager::addNewTab(wxString tabName) { _lastId++; wxGEditorTabPanel *newPanel = new wxGEditorTabPanel(_notebook,_lastId); newPanel->setPanelsManager(this); _panels[_lastId] = newPanel; _actual = newPanel; - _notebook->AddPage(newPanel,_T("Diagram"),true); + _notebook->AddPage(newPanel, tabName ,true); } //========================================================================= @@ -102,9 +102,9 @@ namespace bbtk //========================================================================= - std::string wxTabPanelsManager::getActualComplexBoxBBS(std::string cbName, std::string paName,std::string cbAuthor,std::string cbCategory,std::string cbDescription) + std::string wxTabPanelsManager::getActualComplexBoxBBS() { - return _actual->saveComplexBoxBBS(cbName,paName,cbAuthor,cbCategory,cbDescription); + return _actual->saveComplexBoxBBS(); } //========================================================================= @@ -203,7 +203,6 @@ printf("wxTabPanelsManager::VerifyActualTabPanel %d \n", this->_notebook->GetPa void wxTabPanelsManager::OnTabChanged(wxAuiNotebookEvent& event) { -printf("wxTabPanelsManager::OnTabChanged \n"); int index = event.GetSelection(); wxGEditorTabPanel* tab = (wxGEditorTabPanel*)_notebook->GetPage(index); int id = tab->getPanelId(); @@ -212,6 +211,82 @@ printf("wxTabPanelsManager::OnTabChanged \n"); } //========================================================================= + std::string wxTabPanelsManager::GetCbName() + { + return _actual->GetCbName(); + } + + void wxTabPanelsManager::SetNameTabPanel(wxString tabpanelname) + { + int id = _notebook->GetSelection(); + _notebook->SetPageText( id , tabpanelname ); + } + + + + //========================================================================= + std::string wxTabPanelsManager::GetCbPackageName() + { + return _actual->GetCbPackageName(); + } + + //========================================================================= + std::string wxTabPanelsManager::GetAuthor() + { + return _actual->GetAuthor(); + } + + //========================================================================= + std::string wxTabPanelsManager::GetDescription() + { + return _actual->GetDescription(); + } + + //========================================================================= + std::string wxTabPanelsManager::GetCategory() + { + return _actual->GetCategory(); + } + + //========================================================================= + void wxTabPanelsManager::SetCbName(std::string cbName) + { + _actual->SetCbName( cbName ); + } + + //========================================================================= + void wxTabPanelsManager::SetCbPackageName(std::string packagename) + { + _actual->SetCbPackageName( packagename ); + } + + + //========================================================================= + void wxTabPanelsManager::SetAuthor(std::string author) + { + _actual->SetAuthor( author ); + } + + + //========================================================================= + void wxTabPanelsManager::SetCategory(std::string category) + { + _actual->SetCategory( category ); + } + + + //========================================================================= + void wxTabPanelsManager::SetDescription(std::string description) + { + _actual->SetDescription( description ); + } + + + + + + + diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h index 028a144..7247d2a 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h @@ -71,7 +71,7 @@ namespace bbtk wxTabPanelsManager(wxGUIEditorGraphicBBS *parent); ~wxTabPanelsManager(); - void addNewTab(); + void addNewTab(wxString tabName=_T("")); wxAuiNotebook* getAuiNotebook(); wxGEditorTabPanel* getActualTabPanel(); @@ -79,7 +79,7 @@ namespace bbtk void updateStatusBar(std::string textStatus); std::string getActualDiagramBBS(bool wln=false); - std::string getActualComplexBoxBBS(std::string cbName,std::string paName,std::string cbAuthor="",std::string cbCategory="",std::string cbDescription=""); + std::string getActualComplexBoxBBS(); void editBlackBox(GBlackBoxModel *bbmodel); void deleteAllBoxesActualDiagram(); @@ -96,6 +96,21 @@ namespace bbtk void OnTabChanged(wxAuiNotebookEvent& event); void VerifyLastTabPanel(); + void SetCbName(std::string cbName); + void SetCbPackageName(std::string packagename); + void SetAuthor(std::string author); + void SetCategory(std::string category); + void SetDescription(std::string description); + std::string GetCbName(); + std::string GetCbPackageName(); + std::string GetAuthor(); + std::string GetDescription(); + std::string GetCategory(); + + void SetNameTabPanel(wxString tabpanelname); + + + private: // Private Attributes diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx index cf08b26..1c13d7d 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx @@ -47,6 +47,12 @@ namespace bbtk //========================================================================= wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView,int idManager) { + _cbName = "ComplexBoxName"; + _cbPackageName = "PackageName"; + _Author = "Author ??"; + _Category = ""; + _Description = "Description ??"; + _parent = parent; _numBoxes = 0; _idManager = idManager; @@ -1253,6 +1259,28 @@ printf("EED wxVtkSceneManager::createGComplexBoxOutputPort 900-450\n"); script+=LineNumber(wln,lnNmbr); script+="\n"; + +//ups2 + + script+=LineNumber(wln,lnNmbr); + script+="author \""; + script+=_Author; + script+="\"\n"; + + script+=LineNumber(wln,lnNmbr); + script+="description \""; + script+=_Description; + script+="\"\n"; + + script+=LineNumber(wln,lnNmbr); + script+="category \""; + script+=_Category; + script+="\"\n"; + + script+=LineNumber(wln,lnNmbr); + script+="\n"; + + // script+="include std\n"; // JPR for(i = 0; i < (int)boxes.size();i++) @@ -1339,9 +1367,8 @@ printf("EED wxVtkSceneManager::createGComplexBoxOutputPort 900-450\n"); //========================================================================= - std::string wxVtkSceneManager::saveComplexBoxBBS(std::string cbName,std::string paName,std::string cbAuthor,std::string cbCategory,std::string cbDescription) + std::string wxVtkSceneManager::saveComplexBoxBBS() { - std::vector packages; std::vector boxes; std::vector connections; @@ -1398,21 +1425,28 @@ printf("EED wxVtkSceneManager::createGComplexBoxOutputPort 900-450\n"); } script+="\n"; + // Definition of a complex box script+="define "; - script+=cbName+" "+paName; + script+=_cbName+" "+_cbPackageName; script+="\n"; script+="\n"; - script+="author \" "; - script+=cbAuthor; + script+="author \""; + script+=_Author; script+="\"\n"; - script+="description \" "; - script+=cbDescription; + script+="description \""; + script+=_Description; script+="\"\n"; script+="\n"; + script+="category \""; + script+=_Category; + script+="\"\n"; + script+="\n"; + + // Create boxes for(i = 0; i<(int)boxes.size();i++) { @@ -1589,11 +1623,32 @@ printf("EED wxVtkSceneManager::createGComplexBoxOutputPort 900-450\n"); { char buffer [50]; + content+="CATEGORY:"; + content+=GetCategory(); + content+="\n"; + + content+="DESCRIPTION:"; + content+=GetDescription(); + content+="\n"; + + content+="AUTHOR:"; + content+=GetAuthor(); + content+="\n"; + + //Print info IF COMPLEX BOX content+="COMPLEXBOX:"; if(_isComplexBox) { content+="TRUE\n"; +//ups1 + content+="COMPLEXBOXNAME:"; + content+=GetCbName(); + content+="\n"; + + content+="PACKAGENAME:"; + content+=GetCbPackageName(); + content+="\n"; //Print info complex input ports std::vector inputs = getComplexInputPorts(); @@ -1667,7 +1722,7 @@ printf("EED wxVtkSceneManager::createGComplexBoxOutputPort 900-450\n"); void wxVtkSceneManager::loadDiagram(ifstream &inputStream) { - std::string version; + std::string version=""; std::string line=""; char delims[] = ":"; char *result = NULL; @@ -1682,9 +1737,15 @@ printf("EED wxVtkSceneManager::createGComplexBoxOutputPort 900-450\n"); if (line=="# - BBTKGEditor v 1.0 BBG BlackBox Diagram file") { version=line.substr(18,3); - printf("EED wxVtkSceneManager::loadDiagram version=%s\n",version.c_str()); } - + if (line=="# - BBTKGEditor v 1.1 BBG BlackBox Diagram file") + { + version=line.substr(18,3); + } + if (line=="# - BBTKGEditor v 1.2 BBG BlackBox Diagram file") + { + version=line.substr(18,3); + } } else if(line=="APP_START") { @@ -1693,14 +1754,40 @@ printf("EED wxVtkSceneManager::createGComplexBoxOutputPort 900-450\n"); } } + printf("EED wxVtkSceneManager::loadDiagram version=%s\n",version.c_str()); + if(start) { + if ((version!="1.0") && (version!="1.1")) + { + getline(inputStream,line);//CATEGORY: + char categoryTmp[30]; + strcpy( categoryTmp, line.c_str() ); + result = strtok( categoryTmp, delims ); + result = strtok( NULL, delims ); + SetCategory(result); + + getline(inputStream,line);//DESCRIPTION: + char descriptionTmp[1024]; + strcpy( descriptionTmp, line.c_str() ); + result = strtok( descriptionTmp, delims ); + result = strtok( NULL, delims ); + SetDescription(result); + + getline(inputStream,line);//AUTHOR: + char authorTmp[255]; + strcpy( authorTmp, line.c_str() ); + result = strtok( authorTmp, delims ); + result = strtok( NULL, delims ); + SetAuthor(result); + } + //---------- getline(inputStream,line);//COMPLEX_BOX:TRUE|FALSE - char complex[30]; - strcpy( complex, line.c_str() ); - result = strtok( complex, delims ); + char complexTmp[30]; + strcpy( complexTmp, line.c_str() ); + result = strtok( complexTmp, delims ); result = strtok( NULL, delims ); std::string isComplexBox(result); @@ -1708,6 +1795,24 @@ printf("EED wxVtkSceneManager::createGComplexBoxOutputPort 900-450\n"); { _isComplexBox=true; + if ((version!="1.0") && (version!="1.1")) + { + getline(inputStream,line);//COMPLEXNAME: + char complexboxnameTmp[255]; + strcpy( complexboxnameTmp, line.c_str() ); + result = strtok( complexboxnameTmp, delims ); + result = strtok( NULL, delims ); + SetCbName(result); + + getline(inputStream,line);//PACKAGENAME: + char packagenameTmp[255]; + strcpy( packagenameTmp, line.c_str() ); + result = strtok( packagenameTmp, delims ); + result = strtok( NULL, delims ); + SetCbPackageName(result); + } + + //----------------------- //- COMPLEX INPUT PORTS //----------------------- @@ -2428,31 +2533,91 @@ printf("EED wxVtkSceneManager::createGComplexBoxOutputPort 900-450\n"); //========================================================================= - void wxVtkSceneManager::SetComplexBoxName(std::string cbName) + void wxVtkSceneManager::SetCbName(std::string cbName) + { + _cbName=cbName; + if (_cbName=="") + { + _cbName=""; + } + } + + //========================================================================= + std::string wxVtkSceneManager::GetCbName() + { + return _cbName; + } + + //========================================================================= + void wxVtkSceneManager::SetCbPackageName(std::string packagename) { - _complexBoxName=cbName; + _cbPackageName=packagename; + if (_cbPackageName=="") + { + _cbPackageName=""; + } } //========================================================================= - std::string wxVtkSceneManager::GetComplexBoxName() + std::string wxVtkSceneManager::GetCbPackageName() { - return _complexBoxName; + return _cbPackageName; } + //========================================================================= + void wxVtkSceneManager::SetAuthor(std::string author) + { + _Author=author; + if (_Author=="") + { + _Author=""; + } + } //========================================================================= - void wxVtkSceneManager::SetPackageName(std::string paName) + std::string wxVtkSceneManager::GetAuthor() { - _packageName=paName; + return _Author; } //========================================================================= - std::string wxVtkSceneManager::GetPackageName() + void wxVtkSceneManager::SetCategory(std::string category) { - return _packageName; + _Category=category; + if (_Category=="") + { + _Category=""; + } } //========================================================================= + std::string wxVtkSceneManager::GetCategory() + { + return _Category; + } + + //========================================================================= + void wxVtkSceneManager::SetDescription(std::string description) + { + _Description=description; + if (_Description=="") + { + _Description=""; + } + } + + //========================================================================= + std::string wxVtkSceneManager::GetDescription() + { + return _Description; + } + + //========================================================================= + + + + + } // EO namespace bbtk diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h index 8924e50..e44720c 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h @@ -166,7 +166,7 @@ namespace bbtk std::string getDiagramBBS(bool wln=false); //Returns a string with the BBS script of the complex box. - std::string saveComplexBoxBBS(std::string cbName,std::string paName,std::string cbAuthor="",std::string cbCategory="",std::string cbDescription=""); + std::string saveComplexBoxBBS(); //Delete the object in the list of controllers with the id given by parameter. void deleteObject(int id); @@ -190,15 +190,25 @@ namespace bbtk std::string findANewNameForABox(); //------- - void SetComplexBoxName(std::string cbName); - void SetPackageName(std::string paName); - std::string GetComplexBoxName(); - std::string GetPackageName(); + void SetCbName(std::string cbNane); + void SetCbPackageName(std::string packagename); + void SetAuthor(std::string author); + void SetCategory(std::string category); + void SetDescription(std::string description); + + std::string GetCbName(); + std::string GetCbPackageName(); + std::string GetAuthor(); + std::string GetCategory(); + std::string GetDescription(); private: - std::string _complexBoxName; - std::string _packageName; + std::string _cbName; + std::string _cbPackageName; + std::string _Author; + std::string _Category; + std::string _Description; //wxPanel that uses the manager wxGEditorTabPanel *_parent; -- 2.45.1