plot_collection.cpp
Go to the documentation of this file.
00001 /*
00002  *    This file is part of ACADO Toolkit.
00003  *
00004  *    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
00005  *    Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
00006  *    Milan Vukov, Rien Quirynen, KU Leuven.
00007  *    Developed within the Optimization in Engineering Center (OPTEC)
00008  *    under supervision of Moritz Diehl. All rights reserved.
00009  *
00010  *    ACADO Toolkit is free software; you can redistribute it and/or
00011  *    modify it under the terms of the GNU Lesser General Public
00012  *    License as published by the Free Software Foundation; either
00013  *    version 3 of the License, or (at your option) any later version.
00014  *
00015  *    ACADO Toolkit is distributed in the hope that it will be useful,
00016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  *    Lesser General Public License for more details.
00019  *
00020  *    You should have received a copy of the GNU Lesser General Public
00021  *    License along with ACADO Toolkit; if not, write to the Free Software
00022  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023  *
00024  */
00025 
00026 
00034 #include <acado/user_interaction/plot_collection.hpp>
00035 
00036 
00037 
00038 BEGIN_NAMESPACE_ACADO
00039 
00040 
00041 //
00042 // PUBLIC MEMBER FUNCTIONS:
00043 //
00044 
00045 
00046 PlotCollection::PlotCollection( )
00047 {
00048         first = 0;
00049         last  = 0;
00050 
00051         number = 0;
00052 }
00053 
00054 
00055 PlotCollection::PlotCollection( const PlotCollection& rhs )
00056 {
00057         first = 0;
00058         last  = 0;
00059 
00060         number = 0;
00061 
00062         /* if rhs logging list is not empty, add all logging windows... */
00063         PlotWindow* current = rhs.first;
00064 
00065         while ( current != 0 )
00066         {
00067                 addPlotWindow( *current );
00068                 current = current->getNext( );
00069         }
00070 }
00071 
00072 
00073 PlotCollection::~PlotCollection( )
00074 {
00075         clearAllWindows( );
00076 }
00077 
00078 
00079 PlotCollection& PlotCollection::operator=( const PlotCollection& rhs )
00080 {
00081         if ( this != &rhs )
00082         {
00083                 clearAllWindows( );
00084 
00085                 /* if rhs logging list is not empty, add all option items... */
00086                 PlotWindow* current = rhs.first;
00087 
00088                 while ( current != 0 )
00089                 {
00090                         addPlotWindow( *current );
00091                         current = current->getNext( );
00092                 }
00093         }
00094 
00095         return *this;
00096 }
00097 
00098 
00099 int PlotCollection::operator<<( PlotWindow& window
00100                                                                 )
00101 {
00102         return addPlotWindow( window );
00103 }
00104 
00105 
00106 int PlotCollection::addPlotWindow(      PlotWindow& window
00107                                                                         )
00108 {
00109         window.setAliasIdx( number );
00110 
00111         // create new window
00112         PlotWindow* newWindow = window.clone( );
00113 
00114         if ( number == 0 )
00115         {
00116                 first = newWindow;
00117                 last  = newWindow;
00118         }
00119         else
00120         {
00121                 if ( last->setNext( newWindow ) != SUCCESSFUL_RETURN )
00122                         return -ACADOERROR( RET_PLOT_COLLECTION_CORRUPTED );
00123                 last = newWindow;
00124         }
00125 
00126         ++number;
00127 
00128         return (number-1);
00129 }
00130 
00131 
00132 returnValue PlotCollection::clearAllWindows( )
00133 {
00134         PlotWindow* current = first;
00135         PlotWindow* tmp;
00136 
00137         /* deallocate all LogginRecords within list... */
00138         while ( current != 0 )
00139         {
00140                 tmp = current->getNext( );
00141                 delete current;
00142                 current = tmp;
00143         }
00144 
00145         /* ... and initialise an empty list. */
00146         first = 0;
00147         last  = 0;
00148         number = 0;
00149 
00150         return SUCCESSFUL_RETURN;
00151 }
00152 
00153 
00154 
00155 returnValue PlotCollection::enableNominalControls( )
00156 {
00157         PlotWindow* current = first;
00158 
00159         while ( current != 0 )
00160         {
00161                 current->enableNominalControls( );
00162                 current = current->getNext( );
00163         }
00164         
00165         return SUCCESSFUL_RETURN;
00166 }
00167 
00168 
00169 returnValue PlotCollection::disableNominalControls( )
00170 {
00171         PlotWindow* current = first;
00172 
00173         while ( current != 0 )
00174         {
00175                 current->disableNominalControls( );
00176                 current = current->getNext( );
00177         }
00178         
00179         return SUCCESSFUL_RETURN;
00180 }
00181 
00182 
00183 
00184 returnValue PlotCollection::enableNominalParameters( )
00185 {
00186         PlotWindow* current = first;
00187 
00188         while ( current != 0 )
00189         {
00190                 current->enableNominalParameters( );
00191                 current = current->getNext( );
00192         }
00193         
00194         return SUCCESSFUL_RETURN;
00195 }
00196 
00197 
00198 returnValue PlotCollection::disableNominalParameters( )
00199 {
00200         PlotWindow* current = first;
00201 
00202         while ( current != 0 )
00203         {
00204                 current->disableNominalParameters( );
00205                 current = current->getNext( );
00206         }
00207         
00208         return SUCCESSFUL_RETURN;
00209 }
00210 
00211 
00212 
00213 returnValue PlotCollection::enableNominalOutputs( )
00214 {
00215         PlotWindow* current = first;
00216 
00217         while ( current != 0 )
00218         {
00219                 current->enableNominalOutputs( );
00220                 current = current->getNext( );
00221         }
00222         
00223         return SUCCESSFUL_RETURN;
00224 }
00225 
00226 
00227 returnValue PlotCollection::disableNominalOutputs( )
00228 {
00229         PlotWindow* current = first;
00230 
00231         while ( current != 0 )
00232         {
00233                 current->disableNominalOutputs( );
00234                 current = current->getNext( );
00235         }
00236         
00237         return SUCCESSFUL_RETURN;
00238 }
00239 
00240 
00241 //
00242 // PROTECTED MEMBER FUNCTIONS:
00243 //
00244 
00245 
00246 
00247 
00248 CLOSE_NAMESPACE_ACADO
00249 
00250 
00251 /*
00252  *      end of file
00253  */


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Sat Jun 8 2019 19:38:42