source: flair-src/trunk/lib/FlairFilter/src/UavMultiplex_impl.cpp@ 7

Last change on this file since 7 was 7, checked in by Sanahuja Guillaume, 6 years ago

filter and meta

File size: 2.3 KB
Line 
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
25using std::string;
26using std::ostringstream;
27using namespace flair::core;
28using namespace flair::gui;
29using namespace flair::filter;
30
31UavMultiplex_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
42UavMultiplex_impl::~UavMultiplex_impl(void)
43{
44 delete main_tab;
45 if(multiplexcombobox!=NULL) free(multiplexcombobox);
46}
47
48void 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
78int 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}
Note: See TracBrowser for help on using the repository browser.