| 1 | // created: 2014/04/11
|
---|
| 2 | // filename: UavMultiplex_impl.cpp
|
---|
| 3 | //
|
---|
| 4 | // author: Guillaume Sanahuja
|
---|
| 5 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 6 | //
|
---|
| 7 | // version: $Id: $
|
---|
| 8 | //
|
---|
| 9 | // purpose: Class defining uav multiplexing
|
---|
| 10 | //
|
---|
| 11 | //
|
---|
| 12 | /*********************************************************************/
|
---|
| 13 |
|
---|
| 14 | #include "UavMultiplex_impl.h"
|
---|
| 15 | #include "UavMultiplex.h"
|
---|
| 16 | #include <cvmatrix.h>
|
---|
| 17 | #include <FrameworkManager.h>
|
---|
| 18 | #include <TabWidget.h>
|
---|
| 19 | #include <Tab.h>
|
---|
| 20 | #include <GridLayout.h>
|
---|
| 21 | #include <ComboBox.h>
|
---|
| 22 | #include <GroupBox.h>
|
---|
| 23 | #include <sstream>
|
---|
| 24 |
|
---|
| 25 | using std::string;
|
---|
| 26 | using std::ostringstream;
|
---|
| 27 | using namespace flair::core;
|
---|
| 28 | using namespace flair::gui;
|
---|
| 29 | using namespace flair::filter;
|
---|
| 30 |
|
---|
| 31 | UavMultiplex_impl::UavMultiplex_impl(const FrameworkManager* parent,UavMultiplex* self,std::string name) {
|
---|
| 32 | input=new cvmatrix(self,7,1,floatType);
|
---|
| 33 | multiplexcombobox=NULL;
|
---|
| 34 | this->self=self;
|
---|
| 35 |
|
---|
| 36 | //station sol
|
---|
| 37 | main_tab=new Tab(parent->GetTabWidget(),name);
|
---|
| 38 | tabwidget=new TabWidget(main_tab->NewRow(),"UavMultiplex");
|
---|
| 39 | setup_tab=new Tab(tabwidget,"Setup");
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | UavMultiplex_impl::~UavMultiplex_impl(void)
|
---|
| 43 | {
|
---|
| 44 | delete main_tab;
|
---|
| 45 | if(multiplexcombobox!=NULL) free(multiplexcombobox);
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | void UavMultiplex_impl::SetMultiplexComboBox(string name,int index)
|
---|
| 49 | {
|
---|
| 50 | //we do not know motorcount at constructor time, so allocation is done here
|
---|
| 51 | if(multiplexcombobox==NULL)
|
---|
| 52 | {
|
---|
| 53 | multiplexcombobox=(ComboBox**)malloc(self->MotorsCount()*sizeof(ComboBox*));
|
---|
| 54 | for(int i=0;i<self->MotorsCount();i++) multiplexcombobox[i]=NULL;
|
---|
| 55 | groupbox=new GroupBox(setup_tab->NewRow(),"motor attribution");
|
---|
| 56 | }
|
---|
| 57 | if(index>self->MotorsCount())
|
---|
| 58 | {
|
---|
| 59 | self->Err("index out of bound %i/%i\n",index,self->MotorsCount());
|
---|
| 60 | return;
|
---|
| 61 | }
|
---|
| 62 | if(multiplexcombobox[index]!=NULL)
|
---|
| 63 | {
|
---|
| 64 | self->Err("index already setup\n");
|
---|
| 65 | return;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | multiplexcombobox[index]=new ComboBox(groupbox->At(index/4,index%4),name);
|
---|
| 69 |
|
---|
| 70 | for(int i=0;i<self->MotorsCount();i++)
|
---|
| 71 | {
|
---|
| 72 | ostringstream oss;
|
---|
| 73 | oss << i;
|
---|
| 74 | multiplexcombobox[index]->AddItem(oss.str());
|
---|
| 75 | }
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | int UavMultiplex_impl::MultiplexValue(int index) const
|
---|
| 79 | {
|
---|
| 80 | if(multiplexcombobox[index]!=NULL)
|
---|
| 81 | {
|
---|
| 82 | return multiplexcombobox[index]->CurrentIndex();
|
---|
| 83 | }
|
---|
| 84 | else
|
---|
| 85 | {
|
---|
| 86 | self->Err("multiplex not setup for motor %i\n",index);
|
---|
| 87 | return 0;
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | }
|
---|