VR-Forces 4.0.4 Class Documentation
include/symbolMapper/symbolDesc.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002 ** Copyright (c) 2005 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 *******************************************************************************/
00005 /*******************************************************************************
00006 ** $RCSfile: symbolDesc.h,v $ $Revision: 1.21 $ $State: Exp $
00007 *******************************************************************************/
00008 
00011 
00012 #ifndef SYMBOLDESC_H
00013 #define SYMBOLDESC_H
00014 
00015 #include "symbolMapper/descriptor.h"
00016 #include "symbology/symbol.h"
00017 
00018 #include <QtCore/QString>
00019 #include <QtGui/QColor>
00020 
00021 class DtSymbol;
00022 class DtSymbolDrawer;
00023 class DtEntityMapperKey;
00024 
00040 #include "symbolMapper/symbolMapperDefines.h"
00041 class DT_DLL_symbolMapper DtSymbolDescriptor : public DtDescriptor
00042 {
00043 
00044 public:
00045 
00047    DtSymbolDescriptor():
00048       DtDescriptor(),
00049       myTransparencyLevel(0),
00050       myColor(QRgb(0)),
00051       myOptionalColorParameter(0),
00052       myWriteOut(true),
00053       myOptionalData(false)
00054    {
00055       myKeyword = "symbol-map";
00056    };
00057 
00059    virtual ~DtSymbolDescriptor()
00060    {
00061    };
00062 
00064    DtSymbolDescriptor(const DtSymbolDescriptor& orig):
00065       DtDescriptor(orig),
00066       myColor(orig.myColor),
00067       myWriteOut(orig.myWriteOut),
00068       myTransparencyLevel(orig.myTransparencyLevel),
00069       myOptionalColorParameter(orig.myOptionalColorParameter),
00070       myOptionalData(orig.myOptionalData)
00071    {
00072    };
00073 
00075    virtual DtSymbolDescriptor& operator=(const DtSymbolDescriptor& rhs)
00076    {
00077       if (this == &rhs)
00078          return *this;
00079 
00080       DtDescriptor::operator=(rhs);
00081 
00082       myColor = rhs.myColor;
00083       myWriteOut = rhs.myWriteOut;
00084       myTransparencyLevel = rhs.myTransparencyLevel;
00085       myOptionalColorParameter = rhs.myOptionalColorParameter;
00086       myOptionalData = rhs.myOptionalData;
00087 
00088       return *this;
00089    };
00090 
00092    virtual bool operator==(const DtSymbolDescriptor& rhs) const
00093    {
00094       if (DtDescriptor::operator==(rhs))
00095       {
00096          return ((myColor == rhs.myColor) &&
00097                  (myWriteOut == rhs.myWriteOut) &&
00098                  (myTransparencyLevel == rhs.myTransparencyLevel) &&
00099                  (myOptionalColorParameter == rhs.myOptionalColorParameter) &&
00100                  (myOptionalData == rhs.myOptionalData));
00101       }
00102 
00103       return false;
00104    }
00105 
00106    virtual bool operator!=(const DtSymbolDescriptor& rhs) const
00107    {
00108       return !(*this == rhs);
00109    }
00110 
00113    virtual QString secondaryInfo() const
00114    {
00115       return "";
00116    }
00117 
00118    virtual DtSymbol* createSymbol(DtSymbolDrawer& drawer, const DtEntityMapperKey& key) const = 0;
00119 
00120    void setColor(const QColor& color);
00121    const QColor& color() const;
00122 
00123    void setTransparencyLevel(int);
00124    int transparencyLevel() const;
00125 
00126    void setOptionalColorParameter(int);
00127    int optionalColorParameter() const;
00128 
00129    void setWriteOut(bool);
00130    bool writeOut() const;
00131 
00132    virtual DtSymbolDescriptor* clone() = 0;
00133 
00134    virtual QString descriptorInformation() const
00135    {
00136       QString s;
00137 
00138       if (myOptionalData)
00139       {
00140          s += "(list ";
00141          s += QString::number(myColor.red());
00142          s += " ";
00143          s += QString::number(myColor.green());
00144          s += " ";
00145          s += QString::number(myColor.blue());
00146          s += " ";
00147          s += QString::number(myTransparencyLevel);
00148          s += " ";
00149          s += QString::number(myOptionalColorParameter);
00150          s += ")";
00151       }
00152 
00153       return s;
00154    }
00155 
00156 protected:
00157    virtual void setupOptionSymbolInformation(DtSymbol* mainSymbol) const;
00158 
00159 protected:
00160    QColor  myColor;
00161    int     myTransparencyLevel;
00162    int     myOptionalColorParameter;
00163    bool    myOptionalData;
00164    bool    myWriteOut;
00165 };
00166 
00167 inline void DtSymbolDescriptor::setColor(const QColor& color)
00168 {
00169    myOptionalData = true;
00170    myColor = color;
00171 }
00172 
00173 inline const QColor& DtSymbolDescriptor::color() const
00174 {
00175    return myColor;
00176 }
00177 
00178 inline void DtSymbolDescriptor::setTransparencyLevel(int i)
00179 {
00180    myOptionalData = true;
00181    myTransparencyLevel = i;
00182 }
00183 
00184 inline int DtSymbolDescriptor::transparencyLevel() const
00185 {
00186    return myTransparencyLevel;
00187 }
00188 
00189 inline void DtSymbolDescriptor::setOptionalColorParameter(int i)
00190 {
00191    myOptionalData = true;
00192    myOptionalColorParameter = i;
00193 }
00194 
00195 inline int DtSymbolDescriptor::optionalColorParameter() const
00196 {
00197    return myOptionalColorParameter;
00198 }
00199 
00200 inline void DtSymbolDescriptor::setupOptionSymbolInformation(DtSymbol* mainSymbol) const
00201 {
00202    mainSymbol->setTransparencyLevel(myTransparencyLevel);
00203 
00204    if ((myColor.rgb() & RGB_MASK) != 0)
00205    {
00206       mainSymbol->setColor(myColor);
00207    }
00208 }
00209 
00210 inline void DtSymbolDescriptor::setWriteOut(bool b)
00211 {
00212    myWriteOut = b;
00213 }
00214 
00215 inline bool DtSymbolDescriptor::writeOut() const
00216 {
00217    return myWriteOut;
00218 }
00219 
00220 #endif

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)