wxTabPanelsManager.cxx

Go to the documentation of this file.
00001 /*=========================================================================
00002 Program:   bbtk
00003 Module:    $RCSfile: wxTabPanelsManager.cxx,v $
00004 Language:  C++
00005 Date:      $Date: 2012/05/25 12:55:15 $
00006 Version:   $Revision: 1.31 $
00007 =========================================================================*/
00008 
00009 /* ---------------------------------------------------------------------
00010 
00011 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
00012 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
00013 *
00014 *  This software is governed by the CeCILL-B license under French law and
00015 *  abiding by the rules of distribution of free software. You can  use,
00016 *  modify and/ or redistribute the software under the terms of the CeCILL-B
00017 *  license as circulated by CEA, CNRS and INRIA at the following URL
00018 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
00019 *  or in the file LICENSE.txt.
00020 *
00021 *  As a counterpart to the access to the source code and  rights to copy,
00022 *  modify and redistribute granted by the license, users are provided only
00023 *  with a limited warranty  and the software's author,  the holder of the
00024 *  economic rights,  and the successive licensors  have only  limited
00025 *  liability.
00026 *
00027 *  The fact that you are presently reading this means that you have had
00028 *  knowledge of the CeCILL-B license and that you accept its terms.
00029 * ------------------------------------------------------------------------ */
00030 
00037 #include "wxTabPanelsManager.h"
00038 
00039 namespace bbtk
00040 {
00041 
00042 
00043         //=========================================================================
00044         wxTabPanelsManager::wxTabPanelsManager(wxGUIEditorGraphicBBS *parent)
00045         {
00046                 _parent         = parent;
00047                 _lastId         = 0;
00048                 _notebook       = _parent->getAuiNotebook();
00049                 addNewTab();
00050                 _notebook->Connect(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED,wxAuiNotebookEventHandler(wxTabPanelsManager::OnTabChanged),0,this);
00051                 _notebook->Connect(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE,wxAuiNotebookEventHandler(wxTabPanelsManager::OnTabClose),0,this);
00052 
00053         }
00054 
00055         //=========================================================================
00056         wxTabPanelsManager::~wxTabPanelsManager()
00057         {
00058         }
00059 
00060         //=========================================================================
00061         void wxTabPanelsManager::addNewTab(wxString tabName)
00062         {
00063 printf("EED wxTabPanelsManager::addNewTab 0\n");
00064 
00065                 _lastId++;
00066                 wxGEditorTabPanel *newPanel         = new wxGEditorTabPanel(_notebook,_lastId);
00067                 newPanel->setPanelsManager(this);
00068                 _panels[_lastId]                    = newPanel;
00069                 _actual                             = newPanel;
00070 
00071                 _notebook->AddPage(newPanel, tabName  ,true);
00072 
00073 printf("EED wxTabPanelsManager::addNewTab 1\n");
00074         }
00075 
00076 
00077 
00078 
00079 
00080         //=========================================================================
00081         wxAuiNotebook* wxTabPanelsManager::getAuiNotebook()
00082         {
00083                 return _notebook;
00084         }
00085 
00086         //=========================================================================
00087         wxGEditorTabPanel* wxTabPanelsManager::getActualTabPanel()
00088         {
00089                 return _actual;
00090         }
00091 
00092         //=========================================================================
00093 
00094         void wxTabPanelsManager::displayBlackBoxInfo(std::string packageName, std::string boxName)
00095         {
00096                 _parent->displayBlackBoxInfo(packageName,boxName);
00097         }
00098 
00099         //=========================================================================
00100 
00101         void wxTabPanelsManager::updateStatusBar(std::string textStatus)
00102         {
00103                 _parent->updateStatusBar(textStatus);
00104         }
00105 
00106         //=========================================================================
00107 
00108         std::string wxTabPanelsManager::getActualDiagramBBS(bool wln)
00109         {
00110                 return _actual->getDiagramBBS(wln);
00111         }
00112 
00113         //=========================================================================
00114 
00115         std::string wxTabPanelsManager::getActualComplexBoxBBS()
00116         {
00117                 return _actual->saveComplexBoxBBS();
00118         }
00119 
00120         //=========================================================================
00121 
00122         void wxTabPanelsManager::editBlackBox(GBlackBoxModel *bbmodel)
00123         {
00124                 _parent->editBlackBox(bbmodel);
00125         }
00126 
00127         //=========================================================================
00128 
00129         void wxTabPanelsManager::deleteAllBoxesActualDiagram()
00130         {
00131                 _actual->deleteAllBoxes();
00132         }
00133 
00134         //=========================================================================
00135 
00136         void wxTabPanelsManager::centerViewActualDiagram()
00137         {
00138                 _actual->centerView();
00139         }
00140 
00141         //=========================================================================
00142 
00143         void wxTabPanelsManager::saveActualDiagram(std::string &content, const std::string &path) //DFCH
00144         {
00145                 _actual->saveDiagram(content, path);
00146         }
00147 
00148         //=========================================================================
00149 
00150         void wxTabPanelsManager::loadDiagram(ifstream &inputStream, const std::string &path) //DFCH
00151         {
00152                 _actual->loadDiagram(inputStream, path);
00153         }
00154 
00155         //=========================================================================
00156         void wxTabPanelsManager::saveTempandUpdate(const std::string &action) //FCY
00157         {
00158                 _parent->SaveTempActualDiagram(action);
00159         }
00160         //=========================================================================
00161         void wxTabPanelsManager::saveTempActualDiagram(const std::string &action) //FCY
00162         {
00163                 _actual->saveTempDiagram(action);
00164         }
00165         //=========================================================================
00166         void wxTabPanelsManager::loadTempDiagram(unsigned short un) //FCY
00167         {
00168                  _actual->loadTempDiagram(un);
00169         }
00170 
00171         //=========================================================================
00172         unsigned short wxTabPanelsManager::getUndoState( std::string &stun) //FCY
00173         {
00174                  return _actual->getUndoState(stun);
00175         }
00176                 //=========================================================================
00177         unsigned short wxTabPanelsManager::getRedoState(std::string &stre) //FCY
00178         {
00179                  return _actual->getRedoState(stre);
00180         }
00181         //=========================================================================
00182 
00183         bool wxTabPanelsManager::isActualDiagramComplexBox()
00184         {
00185                 return _actual->isComplexBox();
00186         }
00187 
00188         //=========================================================================
00189 
00190         void wxTabPanelsManager::setActualDiagramComplexBox(bool val)
00191         {
00192                 _actual->setComplexBox(val);
00193         }
00194 
00195         //=========================================================================
00196 
00197         void wxTabPanelsManager::addActualDiagramComplexInputPort(std::string portName)
00198         {
00199                 _actual->addComplexInputPort(portName);
00200         }
00201 
00202         //=========================================================================
00203 
00204         void wxTabPanelsManager::addActualDiagramComplexOutputPort(std::string portName)
00205         {
00206                 _actual->addComplexOutputPort(portName);
00207         }
00208 
00209         //=========================================================================
00210 
00211         void wxTabPanelsManager::copySelectedBBoxesToComplexDiagram()
00212         {
00213                 std::map<int,GObjectController*> mapSelected = _actual->getSelectedObjects();
00214                 addNewTab();
00215                 setActualDiagramComplexBox(true);
00216                 _actual->addObjects(mapSelected);
00217                 _parent->refreshGUIControls();
00218         }
00219 
00220         //=========================================================================
00221 
00222         int wxTabPanelsManager::getNumActualSelectedObjects()
00223         {
00224                 return _actual->getNumSelectedObjects();
00225         }
00226 
00227         //=========================================================================
00228 
00229         void wxTabPanelsManager::VerifyLastTabPanel()
00230         {
00231 printf("wxTabPanelsManager::VerifyActualTabPanel  %d \n", this->_notebook->GetPageCount() );
00232             if (this->_notebook->GetPageCount()==0)
00233             {
00234                 this->_actual=NULL;
00235             }
00236         }
00237 
00238         //=========================================================================
00239 
00240         void wxTabPanelsManager::OnTabChanged(wxAuiNotebookEvent& event)
00241         {
00242                 int index                   = event.GetSelection();
00243                 wxGEditorTabPanel* tab      = (wxGEditorTabPanel*)_notebook->GetPage(index);
00244                 int id                      = tab->getPanelId();
00245                 _actual                     = _panels[id];
00246                 _parent->refreshGUIControls();
00247 
00248         }
00249 
00250         //=========================================================================
00251 
00252         void wxTabPanelsManager::OnTabClose(wxAuiNotebookEvent& event)
00253         {
00254 
00255                 std::cout<<"RaC wxTabPanelsManager::OnTabClose Start... "<<_panels.size()<<std::endl;
00256                 int index = event.GetSelection();
00257 
00258                 if(_panels.size()>0)
00259                 {
00260                         wxGEditorTabPanel* tab      = (wxGEditorTabPanel*)_notebook->GetPage(index);
00261                         int id                      = tab->getPanelId();
00262                         tab->deleteAllBoxes();
00263                         _panels.erase(id);
00264 
00265                         _notebook->RemovePage(index);
00266 
00267                         std::cout<<"RaC wxTabPanelsManager::OnTabClose  IMPORTANT. The complete tab is not erased from memory... "<<std::endl;
00269                         // TO FIX . RaC May 2012 - IMPORTANT. The complete tab is not erased from memory.
00270                         // Only the objects are deleted and the tab is hidden
00271                         // Execution problems when a tab is deleted using delete or DeletePage
00272                         // delete tab;
00273 
00274                         map<int, wxGEditorTabPanel*>::iterator it = _panels.begin() ;
00275                         _actual=(*it).second;
00276 
00277                         std::cout<<"RaC wxTabPanelsManager::OnTabClose End..."<< std::endl;
00278                 }
00279         }
00280 
00281         //=========================================================================
00282     std::string wxTabPanelsManager::GetCbName()
00283         {
00284             return _actual->GetCbName();
00285         }
00286         
00287         //=========================================================================
00288         void wxTabPanelsManager::SetNameTabPanel(wxString tabpanelname)
00289         {
00290             int id          = _notebook->GetSelection();
00291             _notebook->SetPageText( id , tabpanelname );
00292         }
00293 
00294         std::string wxTabPanelsManager::GetNameTabPanel() 
00295         {
00296                  int id = _notebook->GetSelection();
00297                 return crea::wx2std(_notebook->GetPageText(id));
00298         }
00299 
00300         //=========================================================================
00301         //DFCH
00302         std::string wxTabPanelsManager::GetCurrentTabPanelPath( )
00303         {
00304                 int id          = _notebook->GetSelection();
00305                 wxGEditorTabPanel* auxPanel = (wxGEditorTabPanel*) _notebook->GetPage(id);
00306                 return( auxPanel->GetFullPath( ) );
00307             //return ( (wxGEditorTabPanel) _notebook->GetPage(id)->GetFullPath( ) );
00308         }
00309 
00310 
00311         //=========================================================================
00312     std::string wxTabPanelsManager::GetCbPackageName()
00313         {
00314             return _actual->GetCbPackageName();
00315         }
00316 
00317         //=========================================================================
00318     std::string wxTabPanelsManager::GetAuthor()
00319         {
00320             return _actual->GetAuthor();
00321         }
00322 
00323         //=========================================================================
00324     std::string wxTabPanelsManager::GetDescription()
00325         {
00326             return _actual->GetDescription();
00327         }
00328 
00329         //=========================================================================
00330     std::string wxTabPanelsManager::GetCategory()
00331         {
00332             return _actual->GetCategory();
00333         }
00334 
00335         //=========================================================================
00336     void wxTabPanelsManager::SetCbName(std::string cbName)
00337     {
00338         _actual->SetCbName( cbName );
00339     }
00340 
00341         //=========================================================================
00342     void wxTabPanelsManager::SetCbPackageName(std::string packagename)
00343     {
00344         _actual->SetCbPackageName( packagename );
00345     }
00346 
00347 
00348         //=========================================================================
00349     void wxTabPanelsManager::SetAuthor(std::string author)
00350     {
00351         _actual->SetAuthor( author );
00352     }
00353 
00354 
00355         //=========================================================================
00356     void wxTabPanelsManager::SetCategory(std::string category)
00357     {
00358         _actual->SetCategory( category );
00359     }
00360 
00361 
00362         //=========================================================================
00363     void wxTabPanelsManager::SetDescription(std::string description)
00364     {
00365         _actual->SetDescription( description );
00366     }
00367 
00368 
00369 
00370 
00371 
00372 
00373 
00374 
00375 
00376 
00377 }  // EO namespace bbtk
00378 
00379 // EOF
00380 

Generated on Thu May 31 15:12:19 2012 for bbtkGEditor by  doxygen 1.5.7.1