PropertyStandard.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) Jürgen Riegel          (juergen.riegel@web.de) 2002     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #ifndef APP_PROPERTYSTANDARD_H
00025 #define APP_PROPERTYSTANDARD_H
00026 
00027 // Std. configurations
00028 
00029 
00030 #include <string>
00031 #include <list>
00032 #include <vector>
00033 #include <boost/filesystem/path.hpp>
00034 
00035 #include "Property.h"
00036 #include "Material.h"
00037 
00038 namespace Base {
00039 class Writer;
00040 }
00041 
00042 
00043 namespace App
00044 {
00045 
00049 class AppExport PropertyInteger: public Property
00050 {
00051     TYPESYSTEM_HEADER();
00052 
00053 public:
00054     PropertyInteger();
00055     ~PropertyInteger();
00056 
00059     void setValue(long);
00060 
00063     long getValue(void) const;
00064     virtual const char* getEditorName(void) const { return "Gui::PropertyEditor::PropertyIntegerItem"; }
00065 
00066     virtual PyObject *getPyObject(void);
00067     virtual void setPyObject(PyObject *);
00068 
00069     virtual void Save (Base::Writer &writer) const;
00070     virtual void Restore(Base::XMLReader &reader);
00071 
00072     virtual Property *Copy(void) const;
00073     virtual void Paste(const Property &from);
00074 
00075     virtual unsigned int getMemSize (void) const{return sizeof(long);}
00076 
00077 protected:
00078     long _lValue;
00079 };
00080 
00084 class AppExport PropertyPath: public Property
00085 {
00086     TYPESYSTEM_HEADER();
00087 
00088 public:
00089   
00090     PropertyPath();
00091     ~PropertyPath();
00092 
00095     void setValue(const boost::filesystem::path &);
00096     
00099     void setValue(const char *);
00100 
00103     boost::filesystem::path getValue(void) const;
00104 
00105     virtual const char* getEditorName(void) const { return "Gui::PropertyEditor::PropertyPathItem"; }
00106     
00107     virtual PyObject *getPyObject(void);
00108     virtual void setPyObject(PyObject *);
00109     
00110     virtual void Save (Base::Writer &writer) const;
00111     virtual void Restore(Base::XMLReader &reader);
00112     
00113     virtual Property *Copy(void) const;
00114     virtual void Paste(const Property &from);
00115     
00116     virtual unsigned int getMemSize (void) const;
00117 
00118 protected:
00119     boost::filesystem::path _cValue;
00120 };
00121 
00134 class AppExport PropertyEnumeration: public PropertyInteger
00135 {
00136     TYPESYSTEM_HEADER();
00137 
00138 public:
00140     PropertyEnumeration();
00141     
00143     ~PropertyEnumeration();
00144 
00146 
00147 
00153     void setEnums(const char** plEnums);
00157     void setValue(const char* value);
00162     void setValue(long);
00164     bool isValue(const char* value) const;
00166     bool isPartOf(const char* value) const;
00168     const char* getValueAsString(void) const;
00170     std::vector<std::string> getEnumVector(void) const;
00172     void setEnumVector(const std::vector<std::string>&);
00174     const char** getEnums(void) const;
00176 
00177     virtual const char* getEditorName(void) const { return "Gui::PropertyEditor::PropertyEnumItem"; }
00178     
00179     virtual PyObject *getPyObject(void);
00180     virtual void setPyObject(PyObject *);
00181 
00182     virtual void Save (Base::Writer &writer) const;
00183     virtual void Restore(Base::XMLReader &reader);
00184 
00185 private:
00186     bool _CustomEnum;
00187     const char** _EnumArray;
00188 };
00189 
00196 class AppExport PropertyIntegerConstraint: public PropertyInteger
00197 {
00198     TYPESYSTEM_HEADER();
00199 
00200 public:
00202     PropertyIntegerConstraint();
00203     
00205     ~PropertyIntegerConstraint();
00206 
00208 
00209 
00210     struct Constraints {
00211         long LowerBound, UpperBound, StepSize;
00212     };
00221     void setConstraints(const Constraints* sConstraint);
00223     const Constraints*  getConstraints(void) const;
00225 
00226     virtual const char* getEditorName(void) const { return "Gui::PropertyEditor::PropertyIntegerConstraintItem"; }
00227     virtual void setPyObject(PyObject *);
00228 
00229 protected:
00230     const Constraints* _ConstStruct;
00231 };
00232 
00238 class AppExport PropertyPercent: public PropertyIntegerConstraint
00239 {
00240     TYPESYSTEM_HEADER();
00241 
00242 public:
00244     PropertyPercent();
00245     
00247     ~PropertyPercent();
00248 };
00249 
00253 class AppExport PropertyIntegerList: public PropertyLists
00254 {
00255     TYPESYSTEM_HEADER();
00256 
00257 public:
00263     PropertyIntegerList();
00264 
00269     ~PropertyIntegerList();
00270 
00271     virtual void setSize(int newSize);
00272     virtual int getSize(void) const;
00273 
00276     void setValue(long);
00277   
00279     long operator[] (const int idx) const {return _lValueList.operator[] (idx);} 
00280   
00281     void  set1Value (const int idx, long value){_lValueList.operator[] (idx) = value;}
00282     void setValues (const std::vector<long>& values);
00283 
00284     const std::vector<long> &getValues(void) const{return _lValueList;}
00285 
00286     virtual PyObject *getPyObject(void);
00287     virtual void setPyObject(PyObject *);
00288     
00289     virtual void Save (Base::Writer &writer) const;
00290     virtual void Restore(Base::XMLReader &reader);
00291     
00292     virtual Property *Copy(void) const;
00293     virtual void Paste(const Property &from);
00294     virtual unsigned int getMemSize (void) const;
00295 
00296 private:
00297     std::vector<long> _lValueList;
00298 };
00299 
00300 
00308 class AppExport PropertyFloat: public Property
00309 {
00310     TYPESYSTEM_HEADER();
00311 
00312 public:
00316     PropertyFloat(void);
00317 
00322     virtual ~PropertyFloat();
00323 
00324 
00325     void setValue(float lValue);
00326     float getValue(void) const;
00327     
00328     virtual const char* getEditorName(void) const { return "Gui::PropertyEditor::PropertyFloatItem"; }
00329     
00330     virtual PyObject *getPyObject(void);
00331     virtual void setPyObject(PyObject *);
00332     
00333     virtual void Save (Base::Writer &writer) const;
00334     virtual void Restore(Base::XMLReader &reader);
00335     
00336     virtual Property *Copy(void) const;
00337     virtual void Paste(const Property &from);
00338     
00339     virtual unsigned int getMemSize (void) const{return sizeof(float);}
00340     
00341 protected:
00342     float _dValue;
00343 };
00344 
00351 class AppExport PropertyFloatConstraint: public PropertyFloat
00352 {
00353     TYPESYSTEM_HEADER();
00354 
00355 public:
00356 
00360     PropertyFloatConstraint(void);
00361     
00366     virtual ~PropertyFloatConstraint();
00367     
00368 
00370 
00371 
00372     struct Constraints {
00373         float LowerBound, UpperBound, StepSize;
00374     };
00383     void setConstraints(const Constraints* sConstrain);
00385     const Constraints*  getConstraints(void) const;
00387 
00388     virtual const char* getEditorName(void) const
00389     { return "Gui::PropertyEditor::PropertyFloatConstraintItem"; }
00390 
00391     virtual void setPyObject(PyObject *);
00392 
00393 protected:
00394     const Constraints* _ConstStruct;
00395 };
00396 
00397 
00398 
00399 
00400 class AppExport PropertyFloatList: public PropertyLists
00401 {
00402     TYPESYSTEM_HEADER();
00403 
00404 public:
00405 
00410     PropertyFloatList();
00411     
00416     virtual ~PropertyFloatList();
00417     
00418     virtual void setSize(int newSize);
00419     virtual int getSize(void) const;
00420 
00423     void setValue(float);
00424     
00426     float operator[] (const int idx) const {return _lValueList.operator[] (idx);} 
00427     
00428     
00429     void set1Value (const int idx, float value){_lValueList.operator[] (idx) = value;}
00430     void setValues (const std::vector<float>& values);
00431     
00432     const std::vector<float> &getValues(void) const{return _lValueList;}
00433     
00434     virtual PyObject *getPyObject(void);
00435     virtual void setPyObject(PyObject *);
00436     
00437     virtual void Save (Base::Writer &writer) const;
00438     virtual void Restore(Base::XMLReader &reader);
00439     
00440     virtual void SaveDocFile (Base::Writer &writer) const;
00441     virtual void RestoreDocFile(Base::Reader &reader);
00442     
00443     virtual Property *Copy(void) const;
00444     virtual void Paste(const Property &from);
00445     virtual unsigned int getMemSize (void) const;
00446 
00447 private:
00448     std::vector<float> _lValueList;
00449 };
00450 
00451 
00455 class AppExport PropertyString: public Property
00456 {
00457     TYPESYSTEM_HEADER();
00458 
00459 public:
00460 
00465     PropertyString(void);
00466     
00471     virtual ~PropertyString();
00472 
00473 
00474     void setValue(const char* sString);
00475     void setValue(const std::string &sString);
00476     const char* getValue(void) const;
00477     bool isEmpty(void){return _cValue.empty();}
00478     
00479     virtual const char* getEditorName(void) const { return "Gui::PropertyEditor::PropertyStringItem"; }
00480     virtual PyObject *getPyObject(void);
00481     virtual void setPyObject(PyObject *);
00482     
00483     virtual void Save (Base::Writer &writer) const;
00484     virtual void Restore(Base::XMLReader &reader);
00485 
00486     virtual Property *Copy(void) const;
00487     virtual void Paste(const Property &from);
00488     virtual unsigned int getMemSize (void) const;
00489 
00490 private:
00491     std::string _cValue;
00492 };
00493 
00496 class AppExport PropertyFont : public PropertyString
00497 {
00498     TYPESYSTEM_HEADER();
00499 
00500 public:
00501     PropertyFont(void);
00502     virtual ~PropertyFont();
00503     virtual const char* getEditorName(void) const
00504     { return "Gui::PropertyEditor::PropertyFontItem"; }
00505 };
00506 
00507 class AppExport PropertyStringList: public PropertyLists
00508 {
00509     TYPESYSTEM_HEADER();
00510 
00511 public:
00512        
00517     PropertyStringList();
00518     
00523     ~PropertyStringList();
00524 
00525     virtual void setSize(int newSize);
00526     virtual int getSize(void) const;
00527     
00530     void setValue(const std::string&);
00531     void setValues(const std::vector<std::string>&);
00532     void setValues(const std::list<std::string>&);
00533     
00535     const std::string& operator[] (const int idx) const {return _lValueList.operator[] (idx);} 
00536     
00537     void  set1Value (const int idx, const std::string& value){_lValueList.operator[] (idx) = value;}
00538     
00539     const std::vector<std::string> &getValues(void) const{return _lValueList;}
00540     
00541     virtual const char* getEditorName(void) const { return "Gui::PropertyEditor::PropertyStringListItem"; }
00542     
00543     virtual PyObject *getPyObject(void);
00544     virtual void setPyObject(PyObject *);
00545     
00546     virtual void Save (Base::Writer &writer) const;
00547     virtual void Restore(Base::XMLReader &reader);
00548     
00549     virtual Property *Copy(void) const;
00550     virtual void Paste(const Property &from);
00551     
00552     virtual unsigned int getMemSize (void) const;
00553     
00554 
00555 private:
00556     std::vector<std::string> _lValueList;
00557 };
00558 
00562 class AppExport PropertyBool : public Property
00563 {
00564     TYPESYSTEM_HEADER();
00565 
00566 public:
00567 
00572     PropertyBool(void);
00573     
00578     virtual ~PropertyBool();
00579     
00580     void setValue(bool lValue);
00581     bool getValue(void) const;
00582     
00583     virtual const char* getEditorName(void) const { return "Gui::PropertyEditor::PropertyBoolItem"; }
00584     
00585     virtual PyObject *getPyObject(void);
00586     virtual void setPyObject(PyObject *);
00587     
00588     virtual void Save (Base::Writer &writer) const;
00589     virtual void Restore(Base::XMLReader &reader);
00590 
00591     virtual Property *Copy(void) const;
00592     virtual void Paste(const Property &from);
00593     
00594     virtual unsigned int getMemSize (void) const{return sizeof(bool);}
00595     
00596 private:
00597     bool _lValue;
00598 };
00599 
00600 
00604 class AppExport PropertyColor : public Property
00605 {
00606     TYPESYSTEM_HEADER();
00607 
00608 public:
00613     PropertyColor();
00614     
00619     ~PropertyColor();
00620 
00623     void setValue(const Color &col);
00624     void setValue(float r, float g, float b, float a=0.0f);
00625     void setValue(uint32_t rgba);
00626 
00629     const Color &getValue(void) const;
00630 
00631     virtual const char* getEditorName(void) const { return "Gui::PropertyEditor::PropertyColorItem"; }
00632     
00633     virtual PyObject *getPyObject(void);
00634     virtual void setPyObject(PyObject *);
00635     
00636     virtual void Save (Base::Writer &writer) const;
00637     virtual void Restore(Base::XMLReader &reader);
00638     
00639     virtual Property *Copy(void) const;
00640     virtual void Paste(const Property &from);
00641     
00642     virtual unsigned int getMemSize (void) const{return sizeof(Color);}
00643     
00644 
00645 private:
00646     Color _cCol;
00647 };
00648 
00649 class AppExport PropertyColorList: public PropertyLists
00650 {
00651     TYPESYSTEM_HEADER();
00652 
00653 public:
00654        
00659     PropertyColorList();
00660 
00665     ~PropertyColorList();
00666 
00667     virtual void setSize(int newSize);
00668     virtual int getSize(void) const;
00669     
00672     void setValue(const Color&);
00673   
00675     const Color& operator[] (const int idx) const {return _lValueList.operator[] (idx);} 
00676     
00677     void  set1Value (const int idx, const Color& value){_lValueList.operator[] (idx) = value;}
00678     
00679     void setValues (const std::vector<Color>& values);
00680     const std::vector<Color> &getValues(void) const{return _lValueList;}
00681     
00682     virtual PyObject *getPyObject(void);
00683     virtual void setPyObject(PyObject *);
00684     
00685     virtual void Save (Base::Writer &writer) const;
00686     virtual void Restore(Base::XMLReader &reader);
00687     
00688     virtual void SaveDocFile (Base::Writer &writer) const;
00689     virtual void RestoreDocFile(Base::Reader &reader);
00690     
00691     virtual Property *Copy(void) const;
00692     virtual void Paste(const Property &from);
00693     virtual unsigned int getMemSize (void) const;
00694     
00695 private:
00696     std::vector<Color> _lValueList;
00697 };
00698 
00702 class AppExport PropertyMaterial : public Property
00703 {
00704     TYPESYSTEM_HEADER();
00705 
00706 public:
00707       
00712     PropertyMaterial();
00713 
00718     ~PropertyMaterial();
00719     
00722     void setValue(const Material &mat);
00723     void setAmbientColor(const Color& col);
00724     void setDiffuseColor(const Color& col);
00725     void setSpecularColor(const Color& col);
00726     void setEmmisiveColor(const Color& col);
00727     void setShininess(float);
00728     void setTransparency(float);
00729     
00732     const Material &getValue(void) const;
00733 
00734     virtual PyObject *getPyObject(void);
00735     virtual void setPyObject(PyObject *);
00736     
00737     virtual void Save (Base::Writer &writer) const;
00738     virtual void Restore(Base::XMLReader &reader);
00739     
00740     virtual Property *Copy(void) const;
00741     virtual void Paste(const Property &from);
00742     
00743     virtual unsigned int getMemSize (void) const{return sizeof(_cMat);}
00744     
00745 private:
00746     Material _cMat;
00747 };
00748 
00749 
00750 
00751 } // namespace App
00752 
00753 #endif // APP_PROPERTYSTANDARD_H

Generated on Wed Nov 23 19:00:31 2011 for FreeCAD by  doxygen 1.6.1