MaracasTools Class Reference

#include <MaracasTools.h>

Inheritance diagram for MaracasTools:

Inheritance graph
[legend]
Collaboration diagram for MaracasTools:

Collaboration graph
[legend]

List of all members.

Public Member Functions

wxFrame * GetToolbox (wxWindow *parent)
IParameter * GetParameter (std::string name)
void SetMPRWidget (wxManualSegmentation_MPRWidget *pWidget)
void OnSelectToolEvent (wxCommandEvent &event)

Static Public Member Functions

static MaracasToolsGetInstance ()

Protected Member Functions

 MaracasTools ()

Private Member Functions

int GetIndexForButton (int _wxbuttonid)
void SetIndexForButton (int _wxbuttonid)

Private Attributes

wxManualSegmentation_MPRWidgetwidget
std::vector< int > ids
FILE * logger
Framework * framework
IToolbox * toolbox
wxFrame * toolsFrame
wxFrame * optionsFrame
wxPanel * currentToolPanel

Static Private Attributes

static MaracasToolsINSTANCE = NULL


Detailed Description

Definition at line 45 of file MaracasTools.h.


Constructor & Destructor Documentation

MaracasTools::MaracasTools (  )  [protected]

Definition at line 47 of file MaracasTools.cpp.

References currentToolPanel, framework, logger, optionsFrame, and toolsFrame.

Referenced by GetInstance().

00047                           {
00048         framework = new Framework();
00049         if(( logger=freopen("ToolsLogger.txt","w",stdout)) == NULL){
00050                 exit(-1);
00051         }
00052         std::cout << "Framework Creado "<<std::endl;
00053         
00054         toolsFrame = NULL;
00055         optionsFrame = NULL;
00056         currentToolPanel = NULL;
00057 }

Here is the caller graph for this function:


Member Function Documentation

MaracasTools * MaracasTools::GetInstance (  )  [static]

Definition at line 36 of file MaracasTools.cpp.

References INSTANCE, and MaracasTools().

00036                                        {
00037         if (INSTANCE == NULL){
00038                 INSTANCE = new MaracasTools();
00039         }
00040         return INSTANCE;
00041 }

Here is the call graph for this function:

wxFrame * MaracasTools::GetToolbox ( wxWindow *  parent  ) 

Definition at line 63 of file MaracasTools.cpp.

References framework, wxToolsHandler::OnSelectToolEvent(), optionsFrame, SetIndexForButton(), toolbox, and toolsFrame.

00063                                                  {
00064         
00065         
00066         //1. Install ToolboxBundle
00067         //-----------------------------------------------------------------------------------------------
00068         std::cout << "Cargando Toolbox..." <<std::endl;
00069         Bundle* bundle = framework->InstallBundle("ToolboxBundle");
00070         bundle->Start(); 
00071         //-----------------------------------------------------------------------------------------------
00072 
00073         
00074         
00075         
00076         //2. Query the OSGi framework for the IToolbox service (should be delivered in 1).
00077         //-----------------------------------------------------------------------------------------------
00078         BundleContext* ctx = bundle->getBundleContext();
00079         const string interfaceName = "ToolboxService";
00080         ServiceReference* ref = ctx->GetServiceReference(interfaceName); 
00081         if (ref != NULL){
00082                 toolbox = (IToolbox*)ctx->GetService(ref);
00083                 toolbox->SetClient(this); // ACTIVATE THE CALLBACK: WHEN TOOLBOX NEES TO KNOW ANY PARAMETER
00084                                                                   // THE METHOD GetParameter ON THE CLIENT WILL BE CALLED.
00085         }
00086         //-----------------------------------------------------------------------------------------------
00087 
00088 
00089         
00090 
00091         //3.Install tools
00092         //TODO: Replace for discovery of bundles in the maracas' execute directory.
00093         //-----------------------------------------------------------------------------------------------
00094         Bundle* bundle1 = framework->InstallBundle("SimpleSegBundle");
00095         bundle1->Start();
00096 
00097         Bundle* bundle2 = framework->InstallBundle("FM3DBundle");
00098         bundle2->Start();
00099         //-----------------------------------------------------------------------------------------------
00100 
00101 
00102         //4.Build Floating bar
00103         //-----------------------------------------------------------------------------------------------
00104         //FRAME
00105         wxSize _size = wxSize(30,600);
00106         toolsFrame = new wxFrame(parent,-1,_T("Maracas Tools"),wxDefaultPosition,_size);//,wxCAPTION | wxMINIMIZE | wxSTAY_ON_TOP | wxFRAME_TOOL_WINDOW | wxRESIZE_BORDER | wxCLOSE_BOX);
00107 
00108         //SIZER
00109         wxBoxSizer *sizer= new wxBoxSizer(wxVERTICAL);
00110         
00111         //BUTTONS
00112         wxButton* button = NULL;
00113 
00114 
00115         int count = toolbox->GetToolsCount();
00116         
00117                 
00118         //Storyboard
00119         //4.1. MaracasTools asks IToolbox about registered ITools..
00120         //-----------------------------------------------------------------------------------------------
00121         int i=0;
00122 //      char* name = "";
00123         char name[255]="";
00124         for(i=0;i<count;i++){
00125 
00126                 string stName = toolbox->GetToolName(i);
00127                 sprintf(name,"%s",stName.c_str());
00128         
00129                 button = new wxButton(toolsFrame,-1,_T(name));
00130                 SetIndexForButton(button->GetId());
00131 
00132             sizer->Add( button,1, wxALL, 0);
00133                 toolsFrame->Connect(button->GetId(),wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &wxToolsHandler::OnSelectToolEvent,NULL,this);
00134         }
00135         //-----------------------------------------------------------------------------------------------
00136         
00137         
00138 
00139         //CONFIG FRAME
00140         //-----------------------------------------------------------------------------------------------
00141         toolsFrame->SetSize(25,600);
00142         toolsFrame->SetAutoLayout(true);
00143         toolsFrame->SetSizer(sizer);
00144         toolsFrame->Layout();
00145         
00146 
00147         //BUILD TOOLS OPTIONS FRAME
00148         //-----------------------------------------------------------------------------------------------
00149         wxSize optSize = wxSize(300,300);
00150         optionsFrame = new wxFrame(toolsFrame,-1,_T("Tool"),wxDefaultPosition,optSize);//,wxCAPTION | wxMINIMIZE |  wxSTAY_ON_TOP  | wxRESIZE_BORDER | wxCLOSE_BOX );
00151         
00152 
00153         return toolsFrame;
00154         
00155 }

Here is the call graph for this function:

IParameter* MaracasTools::GetParameter ( std::string  name  ) 

void MaracasTools::SetMPRWidget ( wxManualSegmentation_MPRWidget pWidget  )  [inline]

Definition at line 50 of file MaracasTools.h.

References widget.

00050 {widget = pWidget;}

void MaracasTools::OnSelectToolEvent ( wxCommandEvent &  event  )  [virtual]

Implements wxToolsHandler.

Definition at line 161 of file MaracasTools.cpp.

References currentToolPanel, GetIndexForButton(), optionsFrame, and toolbox.

00161                                                          {
00162 
00163 
00164         int id = event.GetId();
00165 
00166         int idx = GetIndexForButton(id);
00167         
00168         const string name = toolbox->GetToolName(idx);
00169 
00170         wxSizer* sizer = optionsFrame->GetSizer();
00171 
00172         if (sizer == NULL){
00173                 sizer= new wxBoxSizer(wxBOTH);
00174                 optionsFrame->SetSizer(sizer);
00175         }
00176 
00177 
00178         if (currentToolPanel != NULL){
00179                 //bool t = sizer->Remove(currentToolPanel);
00180                 currentToolPanel->Destroy();
00181         }
00182         
00183 
00184         currentToolPanel = toolbox->GetToolPanel(optionsFrame,idx);
00185         sizer->Add(currentToolPanel, 1, wxEXPAND, 0);
00186         sizer->Layout();
00187         
00188         optionsFrame->SetTitle(_T(name.c_str()));
00189         optionsFrame->Layout();
00190         optionsFrame->Show();
00191 
00192 
00193 }

Here is the call graph for this function:

int MaracasTools::GetIndexForButton ( int  _wxbuttonid  )  [private]

Definition at line 197 of file MaracasTools.cpp.

References ids.

Referenced by OnSelectToolEvent().

00197                                                   {
00198         
00199         for(int i=0; i < ids.size(); i++){
00200                 if (ids[i] == _wxbuttonid){
00201                         return i;
00202                 }
00203         }
00204         return -1; //NOT FOUND.
00205 }

Here is the caller graph for this function:

void MaracasTools::SetIndexForButton ( int  _wxbuttonid  )  [private]

Definition at line 208 of file MaracasTools.cpp.

References ids.

Referenced by GetToolbox().

00208                                                    {
00209         ids.push_back(_wxbuttonid);
00210         int size = ids.size();
00211 }

Here is the caller graph for this function:


Member Data Documentation

MaracasTools * MaracasTools::INSTANCE = NULL [static, private]

Definition at line 56 of file MaracasTools.h.

Referenced by GetInstance().

wxManualSegmentation_MPRWidget* MaracasTools::widget [private]

Definition at line 58 of file MaracasTools.h.

Referenced by SetMPRWidget().

std::vector<int> MaracasTools::ids [private]

Definition at line 60 of file MaracasTools.h.

Referenced by GetIndexForButton(), and SetIndexForButton().

FILE* MaracasTools::logger [private]

Definition at line 62 of file MaracasTools.h.

Referenced by MaracasTools().

Framework* MaracasTools::framework [private]

Definition at line 64 of file MaracasTools.h.

Referenced by GetToolbox(), and MaracasTools().

IToolbox* MaracasTools::toolbox [private]

Definition at line 65 of file MaracasTools.h.

Referenced by GetToolbox(), and OnSelectToolEvent().

wxFrame* MaracasTools::toolsFrame [private]

Definition at line 67 of file MaracasTools.h.

Referenced by GetToolbox(), and MaracasTools().

wxFrame* MaracasTools::optionsFrame [private]

Definition at line 68 of file MaracasTools.h.

Referenced by GetToolbox(), MaracasTools(), and OnSelectToolEvent().

wxPanel* MaracasTools::currentToolPanel [private]

Definition at line 69 of file MaracasTools.h.

Referenced by MaracasTools(), and OnSelectToolEvent().


The documentation for this class was generated from the following files:
Generated on Wed Jul 29 16:35:57 2009 for creaMaracasVisu_lib by  doxygen 1.5.3