0024830: Remove redundant keyword 'mutable' in CDL declarations
[occt.git] / src / IGESDraw / IGESDraw_Drawing.cxx
CommitLineData
b311480e 1// Created by: CKY / Contract Toubro-Larsen
2// Copyright (c) 1993-1999 Matra Datavision
973c2be1 3// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
7fd59977 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
7fd59977 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
16//--------------------------------------------------------------------
7fd59977 17//--------------------------------------------------------------------
18
19#include <IGESDraw_Drawing.ixx>
20#include <IGESDraw_View.hxx>
21#include <IGESDraw_PerspectiveView.hxx>
22
23#include <IGESGraph_DrawingUnits.hxx>
24#include <IGESGraph_DrawingSize.hxx>
25
26#include <Interface_Macros.hxx>
27
28
b311480e 29IGESDraw_Drawing::IGESDraw_Drawing () { }
7fd59977 30
31
32 void IGESDraw_Drawing::Init
33 (const Handle(IGESDraw_HArray1OfViewKindEntity)& allViews,
34 const Handle(TColgp_HArray1OfXY)& allViewOrigins,
35 const Handle(IGESData_HArray1OfIGESEntity)& allAnnotations)
36{
37 if (!allViews.IsNull()) {
38 Standard_Integer Len = allViews->Length();
39 Standard_Boolean Flag = ( allViewOrigins->Length() == Len );
40 if (!Flag || allViews->Lower() != 1 || allViewOrigins->Lower() != 1)
41 Standard_DimensionMismatch::Raise("IGESDraw_Drawing : Init");
42 }
43 if (!allAnnotations.IsNull())
44 if (allAnnotations->Lower() != 1) Standard_DimensionMismatch::Raise
45 ("IGESDraw_Drawing : Init");
46
47 theViews = allViews;
48 theViewOrigins = allViewOrigins;
49 theAnnotations = allAnnotations;
50 InitTypeAndForm(404,0);
51}
52
53 Standard_Integer IGESDraw_Drawing::NbViews () const
54{
55 return (theViews.IsNull() ? 0 : theViews->Length());
56}
57
58 Handle(IGESData_ViewKindEntity) IGESDraw_Drawing::ViewItem
59 (const Standard_Integer ViewIndex) const
60{
61 return theViews->Value(ViewIndex);
62}
63
64 gp_Pnt2d IGESDraw_Drawing::ViewOrigin
65 (const Standard_Integer TViewIndex) const
66{
67 return (gp_Pnt2d (theViewOrigins->Value(TViewIndex)) );
68}
69
70 Standard_Integer IGESDraw_Drawing::NbAnnotations () const
71{
72 return (theAnnotations.IsNull() ? 0 : theAnnotations->Length() );
73}
74
75 Handle(IGESData_IGESEntity) IGESDraw_Drawing::Annotation
76 (const Standard_Integer AnnotationIndex) const
77{
78 return ( theAnnotations->Value(AnnotationIndex) );
79}
80
81 gp_XY IGESDraw_Drawing::ViewToDrawing
82 (const Standard_Integer NumView, const gp_XYZ& ViewCoords) const
83{
84 gp_XY thisOrigin = theViewOrigins->Value(NumView);
85 Standard_Real XOrigin = thisOrigin.X();
86 Standard_Real YOrigin = thisOrigin.Y();
87 Standard_Real theScaleFactor=0.;
88
89 Handle(IGESData_ViewKindEntity) tempView = theViews->Value(NumView);
90 if (tempView->IsKind(STANDARD_TYPE(IGESDraw_View)))
91 {
92 DeclareAndCast(IGESDraw_View, thisView, tempView);
93 theScaleFactor = thisView->ScaleFactor();
94 }
95 else if (tempView->IsKind(STANDARD_TYPE(IGESDraw_PerspectiveView)))
96 {
97 DeclareAndCast(IGESDraw_PerspectiveView, thisView, tempView);
98 theScaleFactor = thisView->ScaleFactor();
99 }
100
101 Standard_Real XV = ViewCoords.X();
102 Standard_Real YV = ViewCoords.Y();
103
104 Standard_Real XD = XOrigin + (theScaleFactor * XV);
105 Standard_Real YD = YOrigin + (theScaleFactor * YV);
106
107 return ( gp_XY(XD, YD) );
108}
109
110
111 Standard_Boolean IGESDraw_Drawing::DrawingUnit (Standard_Real& val) const
112{
113 val = 0.;
114 Handle(Standard_Type) typunit = STANDARD_TYPE(IGESGraph_DrawingUnits);
115 if (NbTypedProperties(typunit) != 1) return Standard_False;
116 DeclareAndCast(IGESGraph_DrawingUnits,units,TypedProperty(typunit));
117 if (units.IsNull()) return Standard_False;
118 val = units->UnitValue();
119 return Standard_True;
120}
121
122 Standard_Boolean IGESDraw_Drawing::DrawingSize
123 (Standard_Real& X, Standard_Real& Y) const
124{
125 X = Y = 0.;
126 Handle(Standard_Type) typsize = STANDARD_TYPE(IGESGraph_DrawingSize);
127 if (NbTypedProperties(typsize) != 1) return Standard_False;
128 DeclareAndCast(IGESGraph_DrawingSize,size,TypedProperty(typsize));
129 if (size.IsNull()) return Standard_False;
130 X = size->XSize(); Y = size->YSize();
131 return Standard_True;
132}