Ignore:
Timestamp:
04/08/16 15:40:57 (8 years ago)
Author:
Bayard Gildas
Message:

sources reformatted with flair-format-dir script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairFilter/src/UavMultiplex_impl.cpp

    r10 r15  
    3333using namespace flair::filter;
    3434
    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;
     35UavMultiplex_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;
    3940
    40     //station sol
    41     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");
    4445}
    4546
    46 UavMultiplex_impl::~UavMultiplex_impl(void)
    47 {
    48     delete main_tab;
    49     if(multiplexcombobox!=NULL) free(multiplexcombobox);
     47UavMultiplex_impl::~UavMultiplex_impl(void) {
     48  delete main_tab;
     49  if (multiplexcombobox != NULL)
     50    free(multiplexcombobox);
    5051}
    5152
    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     }
     53void 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  }
    7170
    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);
    7373
    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  }
    8079}
    8180
    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 
     81int 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  }
    9488}
Note: See TracChangeset for help on using the changeset viewer.