00001
00023 #ifndef INC_RVC_CADELEMENT_H
00024 #define INC_RVC_CADELEMENT_H
00025
00026 #ifndef INC_MI32_RVCCAD_H
00027 #include <mi32/rvccad.h>
00028 #endif
00029
00030 #ifndef INC_MI32_POLYLINE_H
00031 #include <mi32/polyline.h>
00032 #endif
00033
00034 #ifndef INC_MI32_SCRNUNIT_H
00035 #include <mi32/scrnunit.h>
00036 #endif
00037
00038 #ifndef INC_RVC_STYLETYPE_H
00039 #include <rvc/styletype.h>
00040 #endif
00041
00042 #include <utility>
00043
00044 #ifndef GENERATING_DOXYGEN_OUTPUT
00045
00046 class LABELFRAMEPARMS;
00047 struct LINESTYLE;
00048 class PLANECONIC;
00049 struct POINTSTYLE;
00050 struct POLYSTYLE;
00051 class SUBREGION2D;
00052 struct TEXTSTYLE;
00053 class TRANS2D_AFFINE;
00054 namespace RVC {
00055 class STYLE;
00056 }
00057 #endif
00058
00059 namespace RVC {
00060
00063 class CADELEMENT {
00064 public:
00065
00067 enum TYPE {
00068 TYPE_Insert = 0,
00069 TYPE_Point = 1,
00070 TYPE_Circle = 2,
00071 TYPE_Arc = 3,
00072 TYPE_ArcChord = 4,
00073 TYPE_Text = 5,
00074 TYPE_Line = 7,
00075 TYPE_RotationBox = 8,
00076 TYPE_Polygon = 9,
00077 TYPE_Mesh = 10,
00078 TYPE_Ellipse = 11,
00079 TYPE_EllipticalArc = 12,
00080 TYPE_ArcWedge = 14,
00081 TYPE_EllipticalArcWedge = 15,
00082 TYPE_EllipticalArcChord = 16,
00083 TYPE_MultiLine = 17,
00084 TYPE_MultiPoint = 18,
00085 TYPE_MultiPolygon = 19,
00086 TYPE_LAST
00087 };
00088
00089 #ifndef GENERATING_DOXYGEN_OUTPUT
00090 class BOX;
00091 class DRAW;
00092 class INSERT;
00093 class MESH;
00094 #endif
00095
00097 CADELEMENT (
00098 );
00099
00101 CADELEMENT (
00102 const CADELEMENT& rhs
00103 );
00104
00106 ~CADELEMENT (
00107 );
00108
00110 CADELEMENT& operator= (
00111 const CADELEMENT& rhs
00112 );
00113
00115 void Clear (
00116 );
00117
00120 double ComputeDistanceFrom (
00121 const DPOINT2D& point
00122 ) const;
00123
00127 bool ComputeExtents (
00128 DRECT3D& Extents,
00129 const RVC::STYLE* StyleObj = 0
00130 ) const;
00131
00134 bool ComputeInsertBorder (
00135 const CAD& CadObj,
00136 POLYLINE& Border
00137 ) const;
00138
00141 bool ComputeInsertExtents (
00142 const CAD& CadObj,
00143 DRECT3D& Extents
00144 ) const;
00145
00147 void ConvertForward (
00148 const TRANS2D_AFFINE& taf
00149 );
00150
00152 ERRVALUE ConvertForward (
00153 const TRANS2D_MAPGEN& tmg
00154 );
00155
00157 ERRVALUE ConvertForwardDense (
00158 const TRANS2D_MAPGEN& tmg
00159 );
00160
00162 void ConvertForward (
00163 const TRANS3D& t3d
00164 );
00165
00167 void ConvertInverse (
00168 const TRANS2D_AFFINE& taf
00169 );
00170
00172 ERRVALUE ConvertInverse (
00173 const TRANS2D_MAPGEN& tmg
00174 );
00175
00177 ERRVALUE ConvertInverseDense (
00178 const TRANS2D_MAPGEN& tmg
00179 );
00180
00182 void ConvertInverse (
00183 const TRANS3D& t3d
00184 );
00185
00191 ERRVALUE DrawElement (
00192 DRAW& Draw,
00193 const TRANS2D_AFFINE& BlockToCAD,
00194 double MinChordDist = 0.0,
00195 DIMENSION dim = DIMENSION_2D
00196 );
00197
00200 ELEMTYPE GetApproximateElementType (
00201 ) const;
00202
00205 bool GetBox (
00206 BOX& Box
00207 ) const;
00208
00211 INT32 GetDatabaseIndex (
00212 ) const;
00213
00216 TYPE GetElementType (
00217 ) const;
00218
00220 static TEXTID GetElementTypeTextID (
00221 TYPE CadType
00222 );
00223
00226 bool GetElementStyle (
00227 TEXTSTYLE& textstyle
00228 ) const;
00229
00232 bool GetElementStyle (
00233 POINTSTYLE& pointstyle
00234 ) const;
00235
00238 bool GetElementStyle (
00239 LINESTYLE& linestyle
00240 ) const;
00241
00244 bool GetElementStyle (
00245 POLYSTYLE& polystyle
00246 ) const;
00247
00250 bool GetGMLElement (
00251 MISTRING& GMLElement,
00252 const MILIST<std::pair<MISTRING, MISTRING> >& AttribList
00253 );
00254
00257 bool GetInsert (
00258 INSERT& Insert
00259 ) const;
00260
00263 bool GetLabelFrameParms (
00264 LABELFRAMEPARMS& FrameParms
00265 ) const;
00266
00269 bool GetLines (
00270 POLYLINELIST& PolyLineList
00271 ) const;
00272
00275 bool GetMesh (
00276 MESH& Mesh
00277 ) const;
00278
00281 bool GetPlaneConic (
00282 PLANECONIC& Conic
00283 ) const;
00284
00287 bool GetPoints (
00288 POLYLINE& PointArray
00289 ) const;
00290
00293 bool GetRegion (
00294 REGION2D& Region,
00295 bool Validate = false
00296 ) const;
00297
00300 bool GetSubRegion (
00301 SUBREGION2D& SubRegion,
00302 bool Validate = false
00303 ) const;
00304
00307 bool GetTextElement (
00308 POLYLINELIST& PolyLineList,
00309 MISTRING& text,
00310 TEXTSTYLE& style,
00311 LABELFRAMEPARMS* FrameParms = 0
00312 ) const;
00313
00315 SCREENUNIT GetWidthUnits (
00316 ) const;
00317
00319 double GetZValue (
00320 ) const;
00321
00324 bool IsBaselineFit (
00325 ) const;
00326
00329 bool IsBaselineSplineFit (
00330 ) const;
00331
00334 bool IsClipUnderSet (
00335 ) const;
00336
00339 bool IsInsertion (
00340 ) const;
00341
00344 bool IsLine (
00345 ) const;
00346
00349 bool IsPlaneConic (
00350 ) const;
00351
00354 bool IsPoint (
00355 ) const;
00356
00359 bool IsPointInside (
00360 const DPOINT2D& pt
00361 ) const;
00362
00365 bool IsPolygon (
00366 ) const;
00367
00370 bool IsText (
00371 ) const;
00372
00375 bool IsValid (
00376 ) const;
00377
00379 void SetBox (
00380 const BOX& Box
00381 );
00382
00384 void SetBaselineFit (
00385 bool value
00386 );
00387
00389 void SetBaselineSplineFit (
00390 bool value
00391 );
00392
00394 void SetClipUnder (
00395 bool value
00396 );
00397
00399 void SetDatabaseIndex (
00400 INT32 index
00401 );
00402
00405 bool SetElementFromGML (
00406 const MISTRING& GMLElement,
00407 MILIST<std::pair<MISTRING, MISTRING> >& AttribList
00408 );
00409
00411 void SetElementStyle (
00412 const TEXTSTYLE& textstyle
00413 );
00414
00416 void SetElementStyle (
00417 const POINTSTYLE& pointstyle
00418 );
00419
00421 void SetElementStyle (
00422 const LINESTYLE& linestyle
00423 );
00424
00426 void SetElementStyle (
00427 const POLYSTYLE& polystyle
00428 );
00429
00431 void SetInsert (
00432 const INSERT& Insert
00433 );
00434
00436 void SetLines (
00437 const POLYLINELIST& PolyLineList,
00438 DIMENSION dim = DIMENSION_2D
00439 );
00440
00442 void SetMesh (
00443 const MESH& Mesh
00444 );
00445
00447 void SetPlaneConic (
00448 const PLANECONIC& Conic
00449 );
00450
00452 void SetPoint (
00453 const DPOINT3D& point,
00454 DIMENSION dim = DIMENSION_2D
00455 );
00456
00458 void SetPoints (
00459 const POLYLINE& PointArray,
00460 DIMENSION dim = DIMENSION_2D
00461 );
00462
00464 void SetPolyLine (
00465 const POLYLINE& PolyLine,
00466 DIMENSION dim = DIMENSION_2D
00467 );
00468
00470 void SetRegion (
00471 const REGION2D& Region,
00472 DIMENSION dim = DIMENSION_2D
00473 );
00474
00476 void SetSubRegion (
00477 const SUBREGION2D& SubRegion,
00478 DIMENSION dim = DIMENSION_2D
00479 );
00480
00482 void SetTextElement (
00483 const POLYLINELIST& PolyLineList,
00484 const MISTRING& text,
00485 const TEXTSTYLE& style,
00486 const LABELFRAMEPARMS* FrameParms = 0,
00487 DIMENSION dim = DIMENSION_2D
00488 );
00489
00491 void SetWidthUnits (
00492 SCREENUNIT WidthUnits
00493 );
00494
00496 void SetZValue (
00497 double zvalue
00498 );
00499
00503 bool TestElement (
00504 const REGION2D& Region,
00505 TESTCRITERIA TestMode
00506 ) const;
00507
00508 private:
00509 #ifndef GENERATING_DOXYGEN_OUTPUT
00510 CADELEMHDR m_ElemHdr;
00511 CADELEMOPT m_ElemOpt;
00512 CADELEMDATA m_ElemData;
00513 POLYLINE m_Points;
00514 MISTRING m_String;
00515 SIMPLE_ARRAY<INT32> m_IsleList;
00516 SIMPLE_ARRAY<CADSUBPOLY> m_SubPolyList;
00517
00518 void ClearGeometric ();
00519 void ComputeStringExtents (DRECT3D& Extents, const RVC::STYLE* StyleObj = 0) const;
00520 void GeneratePointsFromBox (POLYLINE& PolyLine) const;
00521 void GetPolyLineList (POLYLINELIST& PolyLineList) const;
00522 void SetPolyLineList (const POLYLINELIST& PolyLineList);
00523 void TranslatePatterns (const SIMPLE_ARRAY<INT32> PattTrans[RVC::PATTERNTYPE_NumTypes]);
00524
00525 class GMLSAX;
00526 friend class GMLSAX;
00527 friend class CAD;
00528 #endif
00529 };
00530
00531 #ifndef GENERATING_DOXYGEN_OUTPUT
00532 DEFINE_ENUM_OP_INCREMENT(CADELEMENT::TYPE)
00533 #endif
00534
00535
00537 class CADELEMENT::BOX {
00538 public:
00540 BOX () : m_Rotation(0.0) {}
00541
00543 BOX (const BOX& rhs) : m_rect(rhs.m_rect), m_Rotation(rhs.m_Rotation) {}
00544
00546 BOX& operator= (
00547 const BOX& rhs
00548 ) {
00549 if (this != &rhs) {
00550 m_rect = rhs.m_rect;
00551 m_Rotation = rhs.m_Rotation;
00552 }
00553 return (*this);
00554 }
00555
00557 void Clear (
00558 ) {
00559 m_rect.SetInvalid();
00560 m_Rotation = 0.0;
00561 return;
00562 }
00563
00564
00565 void GeneratePoints (
00566 POLYLINE& PolyLine,
00567 DIMENSION dim
00568 ) const;
00569
00572 const DRECT3D& GetBoxExtents (
00573 ) const { return (m_rect); }
00574
00577 double GetRotation (
00578 ) const { return (m_Rotation); }
00579
00581 void SetBoxExtents (
00582 const DRECT3D& rect
00583 ) { m_rect = rect; }
00584
00586 void SetRotation (
00587 double Rotation
00588 ) { m_Rotation = Rotation; }
00589
00590 private:
00591 #ifndef GENERATING_DOXYGEN_OUTPUT
00592 DRECT3D m_rect;
00593 double m_Rotation;
00594 #endif
00595 };
00596
00597
00599 class CADELEMENT::DRAW {
00600 public:
00601 DRAW () {}
00602 virtual ~DRAW () {}
00603
00606 int DrawElement (
00607 const CADELEMENT& Element,
00608 const TRANS2D_AFFINE& BtoC
00609 ) { return (v_DrawElement(Element, BtoC)); }
00610
00612 ERRVALUE DrawLines (
00613 const CADELEMENT& Element,
00614 const POLYLINELIST& LineList
00615 ) { return (v_DrawLines(Element, LineList)); }
00616
00618 ERRVALUE DrawPoints (
00619 const CADELEMENT& Element,
00620 const POLYLINE& Points
00621 ) { return (v_DrawPoints(Element, Points)); }
00622
00624 ERRVALUE DrawText (
00625 const CADELEMENT& Element,
00626 const MISTRING& string,
00627 const POLYLINELIST& LineList
00628 ) { return (v_DrawText(Element, string, LineList)); }
00629
00632 ERRVALUE DrawSubRegion (
00633 const CADELEMENT& Element,
00634 const SUBREGION2D& SubRegion
00635 ) { return (v_DrawSubRegion(Element, SubRegion)); }
00636
00637 private:
00638
00639 #ifdef WIN32
00640 #pragma warning (push)
00641 #pragma warning (disable:4100) // Unreferenced formal parameter
00642 #endif
00643 virtual int v_DrawElement (const CADELEMENT& Element, const TRANS2D_AFFINE& BtoC) { return (0); }
00644 virtual ERRVALUE v_DrawLines (const CADELEMENT& Element, const POLYLINELIST& LineList) { return (0); }
00645 virtual ERRVALUE v_DrawPoints (const CADELEMENT& Element, const POLYLINE& Points) { return (0); }
00646 virtual ERRVALUE v_DrawText (const CADELEMENT& Element, const MISTRING& string, const POLYLINELIST& LineList) { return (0); }
00647 virtual ERRVALUE v_DrawSubRegion (const CADELEMENT& Element, const SUBREGION2D& SubRegion) { return (0); }
00648 #ifdef WIN32
00649 #pragma warning (pop)
00650 #endif
00651 };
00652
00653
00654
00656 class CADELEMENT::INSERT {
00657 public:
00659 INSERT (
00660 ) :
00661 m_InsertPt(0.0,0.0,0.0),
00662 m_BlockNum(-1),
00663 m_rotate(0.0),
00664 m_xscale(1.0),
00665 m_yscale(1.0),
00666 m_zscale(1.0),
00667 m_numlins(1),
00668 m_numcols(1),
00669 m_linspace(0.0),
00670 m_colspace(0.0)
00671 {}
00672
00674 void Clear (
00675 ) {
00676 m_InsertPt.x = m_InsertPt.y = m_InsertPt.z = m_linspace = m_colspace = m_rotate = 0.0;
00677 m_BlockNum = -1;
00678 m_xscale = m_yscale = m_zscale = 1.0;
00679 m_numlins = m_numcols = 1;
00680 return;
00681 }
00682
00685 INT32 GetBlockNum (
00686 ) const { return (m_BlockNum); }
00687
00691 double GetColumnSpace (
00692 ) const { return (m_colspace); }
00693
00696 const DPOINT3D& GetInsertPoint (
00697 ) const { return (m_InsertPt); }
00698
00702 double GetLineSpace (
00703 ) const { return (m_linspace); }
00704
00707 INT32 GetNumColumns (
00708 ) const { return (m_numcols); }
00709
00712 INT32 GetNumLines (
00713 ) const { return (m_numlins); }
00714
00717 double GetRotation (
00718 ) const { return (m_rotate); }
00719
00722 double GetXScale (
00723 ) const { return (m_xscale); }
00724
00727 double GetYScale (
00728 ) const { return (m_yscale); }
00729
00732 double GetZScale (
00733 ) const { return (m_zscale); }
00734
00736 void SetBlockNum (
00737 INT32 BlockNum
00738 ) { m_BlockNum = BlockNum; }
00739
00742 void SetColumnSpace (
00743 double ColumnSpace
00744 ) { m_colspace = ColumnSpace; }
00745
00747 void SetInsertPoint (
00748 const DPOINT3D& InsertPt
00749 ) { m_InsertPt = InsertPt; }
00750
00753 void SetLineSpace (
00754 double LineSpace
00755 ) { m_linspace = LineSpace; }
00756
00758 void SetNumColumns (
00759 INT32 NumColumns
00760 ) { m_numcols = static_cast<UINT16>(NumColumns); if (m_numcols == 0) m_numcols = 1; }
00761
00763 void SetNumLines (
00764 INT32 NumLines
00765 ) { m_numlins = static_cast<UINT16>(NumLines); if (m_numlins == 0) m_numlins = 1; }
00766
00768 void SetRotation (
00769 double rotate
00770 ) { m_rotate = rotate; }
00771
00773 void SetXScale (
00774 double xscale
00775 ) { m_xscale = xscale; if (m_xscale == 0.0) m_xscale = 1.0; }
00776
00778 void SetYScale (
00779 double yscale
00780 ) { m_yscale = yscale; if (m_yscale == 0.0) m_yscale = 1.0; }
00781
00783 void SetZScale (
00784 double zscale
00785 ) { m_zscale = zscale; if (m_zscale == 0.0) m_zscale = 1.0; }
00786
00787 private:
00788 #ifndef GENERATING_DOXYGEN_OUTPUT
00789 DPOINT3D m_InsertPt;
00790 INT32 m_BlockNum;
00791 double m_rotate;
00792 double m_xscale;
00793 double m_yscale;
00794 double m_zscale;
00795 UINT16 m_numlins;
00796 UINT16 m_numcols;
00797 double m_linspace;
00798 double m_colspace;
00799 #endif
00800 };
00801
00802
00804 class CADELEMENT::MESH {
00805 public:
00807 MESH (
00808 ) :
00809 m_NumLineVertices(0),
00810 m_NumColumnVertices(0),
00811 m_TopBottomClosed(false),
00812 m_LeftRightClosed(false)
00813 {}
00814
00816 void Clear (
00817 ) {
00818 m_MeshPoints.Clear();
00819 m_NumLineVertices = m_NumColumnVertices = 0;
00820 m_TopBottomClosed = m_LeftRightClosed = false;
00821 return;
00822 }
00823
00827 const POLYLINE& GetMeshPoints (
00828 ) const { return (m_MeshPoints); }
00829
00832 UINT32 GetNumColumnVertices (
00833 ) const { return (m_NumColumnVertices); }
00834
00837 UINT32 GetNumLineVertices (
00838 ) const { return (m_NumLineVertices); }
00839
00842 bool IsLeftRightClosed (
00843 ) const { return (m_LeftRightClosed); }
00844
00847 bool IsTopBottomClosed (
00848 ) const { return (m_TopBottomClosed); }
00849
00851 void SetLeftRightClosed (
00852 bool LeftRightClosed
00853 ) { m_LeftRightClosed = LeftRightClosed; }
00854
00857 void SetMeshPoints (
00858 const POLYLINE& MeshPoints
00859 ) { m_MeshPoints = MeshPoints; }
00860
00862 void SetNumColumnVertices (
00863 UINT32 NumColumnVertices
00864 ) { m_NumColumnVertices = NumColumnVertices; }
00865
00867 void SetNumLineVertices (
00868 UINT32 NumLineVertices
00869 ) { m_NumLineVertices = NumLineVertices; }
00870
00872 void SetTopBottomClosed (
00873 bool TopBottomClosed
00874 ) { m_TopBottomClosed = TopBottomClosed; }
00875
00876 private:
00877 #ifndef GENERATING_DOXYGEN_OUTPUT
00878 UINT32 m_NumLineVertices;
00879 UINT32 m_NumColumnVertices;
00880 bool m_TopBottomClosed;
00881 bool m_LeftRightClosed;
00882 POLYLINE m_MeshPoints;
00883 #endif
00884 };
00885
00886 }
00887
00888 #endif // INC_RVC_CADELEMENT_H