1 /*=========================================================================
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
33 * \brief Class bbtk::WxInterfaceEditorGraphicBBS .
36 #include "bbtkwxGUIEditorGraphicBBS.h"
42 //=========================================================================
43 wxGUIEditorGraphicBBS::wxGUIEditorGraphicBBS(wxFrame *parent)
44 : wxFrame(parent, -1, _T("bbtkGEditor"),wxDefaultPosition, wxSize(1200,800))
46 _frameAUIMgr = new wxAuiManager(this);
49 //std::string datadir( crea::System::GetExecutablePath() );
50 std::string datadir (".");
51 cout<<"RaC //------------------"<<endl;
52 cout<<"RaC //TODO wxGUIEditorGraphicBBS constructor.Initialize datadir with crea::System::GetExecutablePath() ."<<endl;
53 cout<<"RaC //------------------"<<endl;
55 #ifdef LINUX /* assume this is OSX */
56 datadir=datadir+"/../share/creaContours";
59 #ifdef MACOSX /* assume this is OSX */
60 datadir=datadir+"/../../../../share/creaContours";
67 initTabPanelsManager();
69 initHelpHTMLBrowser();
70 initPropertiesPanel();
73 _frameAUIMgr->Update();
74 _actualPkgBrowserBoxName="";
75 _actualPkgBrowserPkgName="";
79 //=========================================================================
80 wxGUIEditorGraphicBBS::~wxGUIEditorGraphicBBS()
82 _frameAUIMgr->UnInit();
85 //=========================================================================
86 void wxGUIEditorGraphicBBS::initToolbar()
88 //std::string filename= _dataDir + "/data/icons/wxart_new.xpm";
89 wxBitmap bmp_new(new_xpm);
91 wxToolBar *_toolbar = new wxToolBar(this, wxID_ANY);
93 //Adds a tool btn to the toolbar
94 _toolbar->AddTool(wxID_NEW,_T("New"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New tab"), _T("Create a new panel tab"));
96 _toolbar->SetMargins( 2, 2 );
100 // connect command event handlers
101 Connect(wxID_NEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnToolLeftClick));
104 //=========================================================================
105 void wxGUIEditorGraphicBBS::initHelpHTMLBrowser()
107 //TO FIX THE PATH OF BBTK BIN IN ORDER TO USE REGENERATE EXECUTABLES
109 _helpHtmlBrowser = new WxGUIHtmlBrowser(this,wxSize(200,0));
110 _frameAUIMgr->AddPane(_helpHtmlBrowser,wxAuiPaneInfo().Right().MinSize(200,200));
113 //=========================================================================
114 void wxGUIEditorGraphicBBS::initMenu()
117 wxMenu *fileMenu = new wxMenu;
119 // the "About" item should be in the help menu
120 wxMenu *helpMenu = new wxMenu;
121 helpMenu->Append(wxID_ABOUT, _T("&About..."), _T("About"));
122 fileMenu->Append(wxID_EXIT, _T("E&xit"), _T("Exit"));
124 Connect(wxID_EXIT,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExit));
126 // now append the freshly created menu to the menu bar...
127 wxMenuBar *menuBar = new wxMenuBar();
128 menuBar->Append(fileMenu, _T("&File"));
129 menuBar->Append(helpMenu, _T("&Help"));
131 // attach this menu bar to the frame
135 //=========================================================================
136 void wxGUIEditorGraphicBBS::initTabPanelsManager()
138 _notebook = new wxAuiNotebook(this,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxAUI_NB_TOP|wxAUI_NB_TAB_MOVE|wxAUI_NB_CLOSE_ON_ACTIVE_TAB|wxAUI_NB_TAB_FIXED_WIDTH|wxAUI_NB_WINDOWLIST_BUTTON);
139 _tabsMgr = new wxTabPanelsManager(this);
140 _frameAUIMgr->AddPane(_notebook,wxAuiPaneInfo().CenterPane());
144 //=========================================================================
145 void wxGUIEditorGraphicBBS::initPackageBrowser()
147 _pkgBrowser = new WxGUIPackageBrowser2(this);
148 _pkgBrowser->IncludeAll();
149 _frameAUIMgr->AddPane(_pkgBrowser,wxAuiPaneInfo().Left().MinSize(200,200).CloseButton(false));
152 //================================================================
154 void wxGUIEditorGraphicBBS::initPropertiesPanel()
156 _propertiesPanel = new wxPropertiesPanel(this);
157 _frameAUIMgr->AddPane(_propertiesPanel,wxAuiPaneInfo().Right().MinSize(200,200).CloseButton(false).Floatable(false));
160 //================================================================
162 void wxGUIEditorGraphicBBS::DoRegeneratePackageDoc( const std::string& pack )
164 std::string mess("Regenerating doc for package '");
170 mess = "Regenerating doc for all packages";
173 mess += " ... please wait";
175 SetStatusText( std2wx(mess) );
183 command += ConfigurationFile::GetInstance().Get_bin_path();
184 command += ConfigurationFile::GetInstance().Get_file_separator();
185 command += "bbRegeneratePackageDoc";
190 command += " " + pack + " -q";
191 bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
193 if ( ! system ( command.c_str() ) )
195 SetStatusText( _T("Done !"));
197 wxMessageBox(_T("Done !"),_T("Regenerate package '")
198 +std2wx(pack)+_T("' doc"),
199 wxOK | wxICON_INFORMATION);
204 SetStatusText( _T("Done !"));
205 wxString err(_T("An error occured while running '"));
206 err += bbtk::std2wx(command) + _T("'");
207 wxMessageBox(err,_T("Regenerate package doc"),wxOK | wxICON_ERROR);
211 //================================================================
212 void wxGUIEditorGraphicBBS::DoRegenerateBoxesLists()
214 SetStatusText( _T("Regenerating boxes lists ... please wait") );
221 command += ConfigurationFile::GetInstance().Get_bin_path();
222 command += ConfigurationFile::GetInstance().Get_file_separator();
223 command += "bbRegenerateBoxesLists";
230 bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
232 if ( ! system ( command.c_str() ) )
234 SetStatusText( _T("Done !"));
236 wxMessageBox(_T("Done !"),_T("Regenerate boxes lists"),
237 wxOK | wxICON_INFORMATION);
242 SetStatusText( _T("Done !"));
243 wxString err(_T("An error occured while running '"));
244 err += bbtk::std2wx(command) + _T("'");
245 wxMessageBox(err,_T("Regenerate boxes lists"),wxOK | wxICON_ERROR);
249 //================================================================
250 void wxGUIEditorGraphicBBS::RegenerateAll()
252 DoRegeneratePackageDoc("-a");
253 DoRegenerateBoxesLists();
256 //================================================================
258 wxAuiNotebook* wxGUIEditorGraphicBBS::getAuiNotebook()
263 //================================================================
265 void wxGUIEditorGraphicBBS::displayBlackBoxInfo(std::string packageName, std::string boxName)
267 if(_actualPkgBrowserPkgName != packageName || _actualPkgBrowserBoxName != boxName )
269 _actualPkgBrowserPkgName = packageName;
270 _actualPkgBrowserBoxName = boxName;
272 BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxName);
273 _pkgBrowser->WxGUIBlackBoxListUserOnSelected(descriptor.get());
277 //=========================================================================
279 void wxGUIEditorGraphicBBS::updateStatusBar(std::string textStatus)
281 SetStatusText(_T(textStatus));
284 //=========================================================================
286 /*****************************************************
288 /*****************************************************/
290 void wxGUIEditorGraphicBBS::OnToolLeftClick(wxCommandEvent& event)
292 switch (event.GetId())
295 _tabsMgr->addNewTab();
300 void wxGUIEditorGraphicBBS::OnExit(wxCommandEvent& event)
306 } // EO namespace bbtk