Salome HOME
PR: mergefrom_BSEC_br1_14Mar04
[modules/kernel.git] / src / Plot2d / Plot2d_CurveContainer.cxx
1 //  Copyright (C) 2003  CEA/DEN, EDF R&D
2 //
3 //
4 //
5 //  File   : Plot2d_CurveContainer.cxx
6 //  Author : Vadim SANDLER
7 //  Module : SALOME
8 //  $Header$
9
10 #include "Plot2d_CurveContainer.h"
11 using namespace std;
12
13 /*!
14   Constructor
15 */
16 Plot2d_CurveContainer::Plot2d_CurveContainer()
17 {
18   myCurves.setAutoDelete( false );
19 }
20 /*!
21   Destructor
22 */
23 Plot2d_CurveContainer::~Plot2d_CurveContainer()
24 {
25   
26 }
27 /*!
28   Adds curve if not exist yet in the container
29 */
30 void Plot2d_CurveContainer::addCurve( Plot2d_Curve* curve )
31 {
32   if ( myCurves.find( curve ) < 0 )
33     myCurves.append( curve );
34 }
35 /*!
36   Removes curve form the container ( and deletes it if <alsoDelete> is true )
37 */
38 void Plot2d_CurveContainer::removeCurve( const int index, bool alsoDelete )
39 {
40   Plot2d_Curve* curve = myCurves.take( index );
41   if ( curve && alsoDelete )
42     delete curve;
43 }
44 /*!
45   Clears container contents ( removes and deletes all curves )
46 */
47 void Plot2d_CurveContainer::clear( bool alsoDelete )
48 {
49   while( myCurves.count() > 0 ) {
50     Plot2d_Curve* curve = myCurves.take( 0 );
51     if ( curve && alsoDelete )
52       delete curve;
53   }
54 }
55 /*!
56   Gets nb of curves in container
57 */
58 int Plot2d_CurveContainer::count()
59 {
60   return myCurves.count();
61 }
62 /*!
63   Returns true if contains no curves
64 */
65 bool Plot2d_CurveContainer::isEmpty()
66 {
67   return myCurves.isEmpty();
68 }
69 /*!
70   Gets curve by index
71 */
72 Plot2d_Curve* Plot2d_CurveContainer::curve( const int index )
73 {
74   return myCurves.at( index );
75 }
76
77