Changeset 15 in flair-src for trunk/lib/FlairFilter/src/UavMultiplex_impl.cpp
- Timestamp:
- 04/08/16 15:40:57 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairFilter/src/UavMultiplex_impl.cpp
r10 r15 33 33 using namespace flair::filter; 34 34 35 UavMultiplex_impl::UavMultiplex_impl(const FrameworkManager* parent,UavMultiplex* self,std::string name) { 36 input=new cvmatrix(self,7,1,floatType); 37 multiplexcombobox=NULL; 38 this->self=self; 35 UavMultiplex_impl::UavMultiplex_impl(const FrameworkManager *parent, 36 UavMultiplex *self, std::string name) { 37 input = new cvmatrix(self, 7, 1, floatType); 38 multiplexcombobox = NULL; 39 this->self = self; 39 40 40 //station sol41 main_tab=new Tab(parent->GetTabWidget(),name);42 tabwidget=new TabWidget(main_tab->NewRow(),"UavMultiplex");43 setup_tab=new Tab(tabwidget,"Setup");41 // station sol 42 main_tab = new Tab(parent->GetTabWidget(), name); 43 tabwidget = new TabWidget(main_tab->NewRow(), "UavMultiplex"); 44 setup_tab = new Tab(tabwidget, "Setup"); 44 45 } 45 46 46 UavMultiplex_impl::~UavMultiplex_impl(void) 47 { 48 delete main_tab;49 if(multiplexcombobox!=NULL)free(multiplexcombobox);47 UavMultiplex_impl::~UavMultiplex_impl(void) { 48 delete main_tab; 49 if (multiplexcombobox != NULL) 50 free(multiplexcombobox); 50 51 } 51 52 52 void UavMultiplex_impl::SetMultiplexComboBox(string name,int index) 53 { 54 //we do not know motorcount at constructor time, so allocation is done here 55 if(multiplexcombobox==NULL) 56 { 57 multiplexcombobox=(ComboBox**)malloc(self->MotorsCount()*sizeof(ComboBox*)); 58 for(int i=0;i<self->MotorsCount();i++) multiplexcombobox[i]=NULL; 59 groupbox=new GroupBox(setup_tab->NewRow(),"motor attribution"); 60 } 61 if(index>self->MotorsCount()) 62 { 63 self->Err("index out of bound %i/%i\n",index,self->MotorsCount()); 64 return; 65 } 66 if(multiplexcombobox[index]!=NULL) 67 { 68 self->Err("index already setup\n"); 69 return; 70 } 53 void UavMultiplex_impl::SetMultiplexComboBox(string name, int index) { 54 // we do not know motorcount at constructor time, so allocation is done here 55 if (multiplexcombobox == NULL) { 56 multiplexcombobox = 57 (ComboBox **)malloc(self->MotorsCount() * sizeof(ComboBox *)); 58 for (int i = 0; i < self->MotorsCount(); i++) 59 multiplexcombobox[i] = NULL; 60 groupbox = new GroupBox(setup_tab->NewRow(), "motor attribution"); 61 } 62 if (index > self->MotorsCount()) { 63 self->Err("index out of bound %i/%i\n", index, self->MotorsCount()); 64 return; 65 } 66 if (multiplexcombobox[index] != NULL) { 67 self->Err("index already setup\n"); 68 return; 69 } 71 70 72 multiplexcombobox[index]=new ComboBox(groupbox->At(index/4,index%4),name); 71 multiplexcombobox[index] = 72 new ComboBox(groupbox->At(index / 4, index % 4), name); 73 73 74 for(int i=0;i<self->MotorsCount();i++) 75 { 76 ostringstream oss; 77 oss << i; 78 multiplexcombobox[index]->AddItem(oss.str()); 79 } 74 for (int i = 0; i < self->MotorsCount(); i++) { 75 ostringstream oss; 76 oss << i; 77 multiplexcombobox[index]->AddItem(oss.str()); 78 } 80 79 } 81 80 82 int UavMultiplex_impl::MultiplexValue(int index) const 83 { 84 if(multiplexcombobox[index]!=NULL) 85 { 86 return multiplexcombobox[index]->CurrentIndex(); 87 } 88 else 89 { 90 self->Err("multiplex not setup for motor %i\n",index); 91 return 0; 92 } 93 81 int UavMultiplex_impl::MultiplexValue(int index) const { 82 if (multiplexcombobox[index] != NULL) { 83 return multiplexcombobox[index]->CurrentIndex(); 84 } else { 85 self->Err("multiplex not setup for motor %i\n", index); 86 return 0; 87 } 94 88 }
Note:
See TracChangeset
for help on using the changeset viewer.