CigiBaseSymbolTextDef.cpp

Go to the documentation of this file.
00001 
00040 #define _EXPORT_CCL_
00041 
00042 
00043 #include "CigiBaseSymbolTextDef.h"
00044 #include "CigiExceptions.h"
00045 
00046 using namespace std;
00047 
00048 // ====================================================================
00049 // Construction/Destruction
00050 // ====================================================================
00051 
00052 // ================================================
00053 // CigiBaseEntityCtrl
00054 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00055 CigiBaseSymbolTextDef::CigiBaseSymbolTextDef(void)
00056 {
00057 }
00058 
00059 // ================================================
00060 // ~CigiBaseEntityCtrl
00061 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00062 CigiBaseSymbolTextDef::~CigiBaseSymbolTextDef(void)
00063 {
00064 }
00065 
00066 
00067 // ================================================
00068 // CigiBaseSymbolTextDef - Copy constructor
00069 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00070 CigiBaseSymbolTextDef::CigiBaseSymbolTextDef(const CigiBaseSymbolTextDef &BaseIn)
00071 {
00072    SymbolID = BaseIn.SymbolID;
00073    Alignment = BaseIn.Alignment;
00074    Orientation = BaseIn.Orientation;
00075    FontSize = BaseIn.FontSize;
00076    VariableDataSize = BaseIn.VariableDataSize;
00077    Text = BaseIn.Text;
00078 }
00079 
00080 // ================================================
00081 // Copy operator
00082 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00083 CigiBaseSymbolTextDef & CigiBaseSymbolTextDef::operator=(const CigiBaseSymbolTextDef &BaseIn)
00084 {
00085    SymbolID = BaseIn.SymbolID;
00086    Alignment = BaseIn.Alignment;
00087    Orientation = BaseIn.Orientation;
00088    FontSize = BaseIn.FontSize;
00089    VariableDataSize = BaseIn.VariableDataSize;
00090    Text = BaseIn.Text;
00091 
00092    return(*this);
00093 }
00094 
00095 
00096 // ====================================================================
00097 // Conversion Control
00098 // ====================================================================
00099 int CigiBaseSymbolTextDef::GetCnvt(CigiVersionID &CnvtVersion,
00100                                 CigiCnvtInfoType::Type &CnvtInfo)
00101 {
00102    if(CnvtVersion.GetCombinedCigiVersion() < 0x303)
00103    {
00104       CnvtInfo.ProcID = CigiProcessType::ProcNone;
00105       CnvtInfo.CnvtPacketID = 0;
00106    }
00107    else
00108    {
00109       CnvtInfo.ProcID = CigiProcessType::ProcStd;
00110       CnvtInfo.CnvtPacketID = CIGI_SYMBOL_TEXT_DEFINITION_PACKET_ID_V3_3;
00111    }
00112 
00113    return(CIGI_SUCCESS);
00114 }
00115 
00116 
00117 // ====================================================================
00118 // Accessors
00119 // ====================================================================
00120 
00121 
00122 // ================================================
00123 // SetAlignment
00124 // ================================================
00125 int CigiBaseSymbolTextDef::SetAlignment(const AlignmentGrp AlignmentIn, bool bndchk)
00126 {
00127 
00128 #ifndef CIGI_NO_BND_CHK
00129    if(bndchk && ((AlignmentIn < 0)||(AlignmentIn > 8)))
00130    {
00131 #ifndef CIGI_NO_EXCEPT
00132       throw CigiValueOutOfRangeException("Alignment", (int)AlignmentIn,0,8);
00133 #endif
00134       return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00135    }
00136 #endif
00137 
00138    Alignment = AlignmentIn;
00139 
00140    return(CIGI_SUCCESS);
00141 
00142 }
00143 
00144 // ================================================
00145 // SetOrientation
00146 // ================================================
00147 int CigiBaseSymbolTextDef::SetOrientation(const OrientationGrp OrientationIn, bool bndchk)
00148 {
00149 
00150 #ifndef CIGI_NO_BND_CHK
00151    if(bndchk && ((OrientationIn < 0)||(OrientationIn > 3)))
00152    {
00153 #ifndef CIGI_NO_EXCEPT
00154       throw CigiValueOutOfRangeException("Orientation", (int)OrientationIn,0,3);
00155 #endif
00156       return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00157    }
00158 #endif
00159 
00160    Orientation = OrientationIn;
00161 
00162    return(CIGI_SUCCESS);
00163 
00164 }
00165 
00166 // ================================================
00167 // SetFontSize
00168 // ================================================
00169 int CigiBaseSymbolTextDef::SetFontSize(const float FontSizeIn, bool bndchk)
00170 {
00171 
00172 #ifndef CIGI_NO_BND_CHK
00173    if(bndchk && (FontSize < 0.0))
00174    {
00175 #ifndef CIGI_NO_EXCEPT
00176       throw CigiValueOutOfRangeException("FontSize", (double)FontSizeIn,">=",0.0);
00177 #endif
00178       return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00179    }
00180 #endif
00181 
00182    FontSize = FontSizeIn;
00183 
00184    return(CIGI_SUCCESS);
00185 
00186 }
00187 
00188 // ================================================
00189 // SetText
00190 // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
00191 int CigiBaseSymbolTextDef::SetText(const std::string &TextIn, bool bndchk)
00192 {
00193 
00194    int TxtSz = TextIn.size();
00195 
00196 #ifndef CIGI_NO_BND_CHK
00197    if(bndchk && ((TxtSz < 0)||(TxtSz > MaxCharCnt)))
00198    {
00199 #ifndef CIGI_NO_EXCEPT
00200       throw CigiValueOutOfRangeException("TextSize", (int)TxtSz,1,MaxCharCnt);
00201 #endif
00202       return(CIGI_ERROR_VALUE_OUT_OF_RANGE);
00203    }
00204 #endif
00205 
00206 
00207    Text = TextIn;
00208 
00209    if(TxtSz > MaxCharCnt)
00210    {
00211       Text.resize(MaxCharCnt,0);
00212       TxtSz = MaxCharCnt;
00213    }
00214 
00215    int Term = 0;
00216 
00217    if(TxtSz < 4)
00218       Term = 4 - TxtSz;
00219    else
00220       Term = 8 - ((TxtSz - 4) % 8);
00221 
00222    VariableDataSize = TxtSz + Term;
00223 
00224    return(CIGI_SUCCESS);
00225 
00226 }
00227 
00228 

Generated on Wed Apr 29 08:59:57 2009 for CCL by  doxygen 1.4.7