Changeset 476 in PSPA


Ignore:
Timestamp:
Jan 6, 2014, 4:17:29 PM (10 years ago)
Author:
garnier
Message:

Impleméntation en partie de setFirstElement

Location:
Interface_Web/trunk/pspaWT/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/sources/controler/include/sectionToExecute.h

    r474 r476  
    5858   If needed, it will change the last element of the previous section
    5959   */
    60   void setFirstElement(std::string);
     60  void setFirstElement(int);
    6161 
    6262  private :
  • Interface_Web/trunk/pspaWT/sources/controler/src/sectionToExecute.cc

    r474 r476  
    6565
    6666
    67 void sectionToExecute::setFirstElement(std::string name) {
    68 // Possible cases :
     67void sectionToExecute::setFirstElement(int index) {
     68// This will set the beginning of this section to the element with the given name
     69 
     70  // Possible cases :
     71  //
     72  // | section 1 | section 2 | section 3   |  section 4 | section 5 |
     73  // |  a b c d  |  e f g h  |  i j k l    |  m n o p   |  q r  | Before (example)
    6974
    70   // | section 1 | section 2 |
    71   // |  a b c d  |  e f g h  |  i X j k l  |  m n o p  | Before : X is in the 3rd sectionToExcute
    72   // |  a b c d e f g h i | X j k l  ||  m n o p  | Case 1 : X move in the 2nd
    73   // |  a b c d  |  e f g h  |  i  |  X j k l m n o p  | Case 2 : X move in the 4nd
    74 
    75   // Case 1 : Have to change X and
     75  // Moved in a previous section :
     76  // |  a b c d  |  e f      |  _g_ h i j k l  |  m n o p |  q r  |  Case 1 : move beginning of section 3 to "g"
     77  // |  a b c    |           |  _d_ e f g h i j k l  |  m n o p  |  q r  |  Case 2 : move beginning of section 3 to "d" => section 2 will be removed !
     78  // => all elements from "d"/"g" to "l" will be moved in the 3rd section
     79 
     80  // Moved in the same section :
     81  // |  a b c d  |  e f g h i j  | _k_ l  |  m n o p   |  q r  | Case 3 : move beginning of section 3 to "k"
     82  // => all elements from "i"(begin of 3rd section) to before "k" will be moved in the 2nd (3-1) section
     83 
     84  // Moved in a next section :
     85  // |  a b c d  |  e f g h i j k l m |  _n_ | o p  |  q r  | Case 4 : move beginning of section 3 to "n"
     86  // |  a b c d  |  e f g h i j k l m  n o p  |  _q_ |   | r  | Case 5 : move beginning of section 3 to "q" => remove section 4 !
     87  // => all elements from "i"(begin of 3rd section) to before "n"/"q" will be moved in the 2nd (3-1) section
     88  // => "n"/"q" element is set to be alone in 3rd section
    7689 
    7790  std::vector <sectionToExecute*> sectVect = sector_->getSectionsToExecute();
    78   sectionToExecute* previousSection = NULL;
     91  unsigned int sectionNumber = 0;
     92  int newBeginSectionNumber = 0;
     93  unsigned long indexOfNewBeginSectionNumber = 0;
     94 
     95  // get this section number
     96  // get the section number of the new begin element
     97  unsigned int n = 0;
     98  bool newFound = false;
    7999
    80100  for (unsigned int a=0; a< sectVect.size(); a++) {
    81101    if (sectVect[a] == this) {
    82       if (a >= 1) {
    83         previousSection = sectVect[a-1];
     102      sectionNumber = a;
     103    }
     104    n += sectVect[a]->getElements().size();
     105    if ((n >index ) && (!newFound)) {
     106      newBeginSectionNumber = a;
     107      indexOfNewBeginSectionNumber = index - (n-sectVect[a]->getElements().size());
     108      newFound = true;
     109    }
     110  }
     111 
     112  if (!newFound ) {
     113    return;  // Impossible to find this index
     114  }
     115 
     116  // Moved in a previous section
     117  if ( newBeginSectionNumber < sectionNumber ) {
     118    for (int a = sectionNumber-1 ; a >= newBeginSectionNumber; a--) {
     119      std::vector< abstractElement* > elemsVect = sectVect[a]->getElements();
     120      long stop = 0;
     121      if (a == newBeginSectionNumber) {
     122        stop = indexOfNewBeginSectionNumber;
     123      }
     124      for (long elemIndex = elemsVect.size(); elemIndex > stop; elemIndex--) {
     125        insertAtFirst(elemsVect.back());
     126        elemsVect.pop_back();
     127
     128        // remove elements
     129        sectVect[a]->removeLastElement();
    84130      }
    85131    }
     132   
     133    // Moved in the same section :
     134  } else if ( newBeginSectionNumber == sectionNumber ) {
     135   
     136   
     137    // Moved in a next section :
     138  } else if ( newBeginSectionNumber > sectionNumber ) {
     139   
     140   
    86141  }
    87   if (previousSection == NULL) {
    88     return;
     142 
     143  // Suppress the empty sections
     144  for (unsigned int a=0; a< sectVect.size(); a++) {
     145    if (sectVect[a]->getElements().size() == 0  ) {
     146      sector_->clearSectionToExecute(a);
     147    }
    89148  }
    90   // FIXME : NOt finished !! 02/2014
    91149}
  • Interface_Web/trunk/pspaWT/sources/controler/src/sector.cc

    r474 r476  
    128128  const abstractSoftware* soft = sectionToExecute_.at(a)->getSoftware();
    129129  if ( soft != NULL ) delete soft;
     130  delete sectionToExecute_[a];
    130131  sectionToExecute_.erase (sectionToExecute_.begin()+a);
    131132}
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_sectionToExecute.h

    r474 r476  
    3636    }
    3737   
    38     void setFirstElementCurrentSelection(Wt::WString);
    39     void setLastElementCurrentSelection(Wt::WString);
    40     void setSoftwareElementCurrentSelection(Wt::WString);
     38    void setFirstElementCurrentSelection_deprecated(Wt::WString);
     39    void setLastElementCurrentSelection_deprecated(Wt::WString);
     40    void setSoftwareElementCurrentSelection_deprecated(Wt::WString);
    4141   
    4242    inline void setWarnings(Wt::WString warn){
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_sectionToExecute.cc

    r474 r476  
    9999
    100100
    101 void GWt_sectionToExecute::setFirstElementCurrentSelection(Wt::WString txt){
     101void GWt_sectionToExecute::setFirstElementCurrentSelection_deprecated(Wt::WString txt){
    102102    for (int a=0; a< firstElement_->count(); a++) {
    103103        if (firstElement_->itemText(a) == txt) {
     
    108108}
    109109
    110 void GWt_sectionToExecute::setLastElementCurrentSelection(Wt::WString txt){
     110void GWt_sectionToExecute::setLastElementCurrentSelection_deprecated(Wt::WString txt){
    111111    for (int a=0; a< lastElement_->count(); a++) {
    112112        if (lastElement_->itemText(a) == txt) {
     
    117117}
    118118
    119 void GWt_sectionToExecute::setSoftwareElementCurrentSelection(Wt::WString txt){
     119void GWt_sectionToExecute::setSoftwareElementCurrentSelection_deprecated(Wt::WString txt){
    120120  for (int a=0; a< softElement_->count(); a++) {
    121121    if (softElement_->itemText(a) == txt) {
     
    151151void GWt_sectionToExecute::changeFirstElement()
    152152{
    153   section_->setFirstElement(firstElement_->currentText().toUTF8());
     153  if (!section_) return;
     154  if (!UIsector_) return;
     155
     156  section_->setFirstElement(firstElement_->currentIndex());
    154157  UIsector_->getExecuteWidget()->displayFromControler();
     158  UIsector_->getBeamLineWidget()->buildBeamLineWidget();
    155159}
Note: See TracChangeset for help on using the changeset viewer.