MeVisLabToolboxReference
MeVisLab/Standard/Sources/ML/MLBase/mlStylePalette.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00005 
00010 //----------------------------------------------------------------------------------
00011 
00012 
00013 #ifndef __mlStylePalette_H
00014 #define __mlStylePalette_H
00015 
00016 
00017 
00018 // ML-includes
00019 
00020 #ifndef __mlModuleIncludes_H
00021 #include "mlModuleIncludes.h"
00022 #endif
00023 #ifndef __mlTreeNode_H
00024 #include "mlTreeNode.h"
00025 #endif
00026 
00027 // Local includes
00028 #ifndef __mlBaseInit_H
00029 #include "mlBaseInit.h"
00030 #endif
00031 
00032 
00033 
00034 ML_START_NAMESPACE
00035 
00036 
00038 
00039 #define MKT_DASH (static_cast<int>(StylePalette::mktDash))
00040 
00041 
00042 //----------------------------------------------------------------------------------
00043 // Base object class StylePalette
00044   
00047 //----------------------------------------------------------------------------------
00048 class MLBASEEXPORT StylePalette : public Base
00049 {
00050 public: 
00051 
00053   StylePalette ();
00054   StylePalette (MLssize_t numStyles);
00055   StylePalette (const StylePalette &palette);
00057   
00059   virtual ~StylePalette ();
00060 
00062   StylePalette &operator = (const StylePalette &palette);
00063 
00064   
00065   // --- Type definitions ---
00066 
00068   typedef enum { 
00069     lstNone = 0, 
00070     lstSolid, 
00071     lstDashed, 
00072     lstDotted, 
00073     lstNumLineStyles 
00074   } LineStyle;
00075   
00077   typedef enum { 
00078     mktNone = 0, 
00079     mktDot, 
00080     mktAsterisk, 
00081     mktCircle,
00082     mktSquare, 
00083     mktTriangle, 
00084     mktPlus, 
00085     mktCross,
00086     mktNumMarkerTypes,
00087     mktDash = -1                  
00088   } MarkerType;
00089 
00090 
00091   // --- Constants ---
00092 
00094   static const char *const lineStyleNames[lstNumLineStyles];
00095 
00097   static const char *const markerTypeNames[mktNumMarkerTypes];
00098 
00100   static const int defaultNumStyles;
00101 
00102   
00103   // --- Access methods ---
00104 
00106   MLssize_t getNumStyles () const { return _numStyles; }
00107   void setNumStyles (MLssize_t newNumStyles);
00109 
00111   Vector3 getColor (MLssize_t index) const;
00112   void getColor (MLssize_t index, float &r, float &g, float &b) const;
00113   void setColor (MLssize_t index, const Vector3 &color);
00114   void setColor (MLssize_t index, float r, float g, float b) { setColor(index, Vector3(r, g, b)); }
00116 
00118   LineStyle getLineStyle (MLssize_t index) const;
00119   void setLineStyle (MLssize_t index, LineStyle lst);
00120   int  getLineWidth (MLssize_t index) const;
00121   void setLineWidth (MLssize_t index, int lw);
00123 
00125   MarkerType getMarkerType (MLssize_t index) const;
00126   void setMarkerType (MLssize_t index, MarkerType mkt);
00127   int  getMarkerSize (MLssize_t index) const;
00128   void setMarkerSize (MLssize_t index, int ms);
00130 
00132   bool getAntiAlias (MLssize_t index) const;
00133   void setAntiAlias (MLssize_t index, bool aa);
00135 
00137   std::string getName (MLssize_t index) const;
00138   void setName (MLssize_t index, const std::string &n);
00140 
00142   MLssize_t getReservedEntries () const { return _reservedEntries; }
00143   void setReservedEntries (MLssize_t reserved);
00145 
00148   MLssize_t getAutoStyleIndex (MLssize_t n);
00149 
00151   void copyStylesFrom (const StylePalette &palette);
00152 
00154   void setColorDefaults ();
00155 
00157   void setMonoDefaults ();
00158 
00160   const char *getLineStyleName (LineStyle lst) const { 
00161     return lineStyleNames[static_cast<int>(lst)];
00162   }
00163 
00165   const char *getMarkerTypeName (MarkerType mkt) const { 
00166     return markerTypeNames[static_cast<int>(mkt)];
00167   }
00168 
00170   void dumpStyles ();
00171 
00173   bool getStyleIndexForName(const std::string curveTitle, std::vector<MLssize_t> &indices);
00174 
00175   // --- Persistence ---
00176 
00178   virtual void addStateToTree (TreeNode *parent) const;
00179   
00181   virtual void readStateFromTree (TreeNode *parent);
00182 
00184   ML_SET_ADDSTATE_VERSION(0);
00185 
00187   virtual StylePalette* clone() const { return new StylePalette(*this); };
00188   virtual StylePalette* deepCopy() const { return new StylePalette(*this); };
00189 protected:
00190 
00191   // --- Methods ---
00192 
00194   void clear ();
00195 
00197   void init (MLssize_t numStyles);
00198 
00199 
00200 private:
00201 
00202   // --- Data ---
00203 
00205   Vector3 *_colors;
00207   LineStyle *_lineStyles;
00209   int *_lineWidths;
00211   MarkerType *_markerTypes;
00213   int *_markerSizes;
00215   bool *_antiAlias;
00217   std::string *_names;
00218 
00220   MLssize_t _numStyles;
00221 
00223   MLssize_t _reservedEntries;
00224 
00225 
00226   // Runtime type system initialization
00227   ML_CLASS_HEADER(StylePalette)
00228 
00229 };
00230 
00231 
00232 ML_END_NAMESPACE
00233 
00234 
00235 #endif
00236 // __mlStylePalette_H