0027961: Visualization - remove unused and no more working OpenGl_AVIWriter
[occt.git] / src / IGESDraw / IGESDraw_Drawing.cxx
1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
18
19 #include <gp_Pnt2d.hxx>
20 #include <gp_XY.hxx>
21 #include <gp_XYZ.hxx>
22 #include <IGESData_IGESEntity.hxx>
23 #include <IGESData_ViewKindEntity.hxx>
24 #include <IGESDraw_Drawing.hxx>
25 #include <IGESDraw_PerspectiveView.hxx>
26 #include <IGESDraw_View.hxx>
27 #include <IGESGraph_DrawingSize.hxx>
28 #include <IGESGraph_DrawingUnits.hxx>
29 #include <Interface_Macros.hxx>
30 #include <Standard_DimensionMismatch.hxx>
31 #include <Standard_OutOfRange.hxx>
32 #include <Standard_Type.hxx>
33
34 IMPLEMENT_STANDARD_RTTIEXT(IGESDraw_Drawing,IGESData_IGESEntity)
35
36 IGESDraw_Drawing::IGESDraw_Drawing ()    {  }
37
38
39     void IGESDraw_Drawing::Init
40   (const Handle(IGESDraw_HArray1OfViewKindEntity)& allViews,
41    const Handle(TColgp_HArray1OfXY)&               allViewOrigins,
42    const Handle(IGESData_HArray1OfIGESEntity)&     allAnnotations)
43 {
44   if (!allViews.IsNull()) {
45     Standard_Integer Len  = allViews->Length();
46     Standard_Boolean Flag = ( allViewOrigins->Length() == Len );
47     if (!Flag || allViews->Lower() != 1 || allViewOrigins->Lower() != 1)
48       Standard_DimensionMismatch::Raise("IGESDraw_Drawing : Init");
49   }
50   if (!allAnnotations.IsNull())
51     if (allAnnotations->Lower() != 1) Standard_DimensionMismatch::Raise
52       ("IGESDraw_Drawing : Init");
53
54   theViews         = allViews; 
55   theViewOrigins   = allViewOrigins; 
56   theAnnotations   = allAnnotations;
57   InitTypeAndForm(404,0);
58 }
59
60     Standard_Integer IGESDraw_Drawing::NbViews () const
61 {
62   return (theViews.IsNull() ? 0 : theViews->Length());
63 }
64
65     Handle(IGESData_ViewKindEntity) IGESDraw_Drawing::ViewItem
66   (const Standard_Integer ViewIndex) const
67 {
68   return theViews->Value(ViewIndex);
69 }
70
71     gp_Pnt2d IGESDraw_Drawing::ViewOrigin
72   (const Standard_Integer TViewIndex) const
73 {
74   return (gp_Pnt2d (theViewOrigins->Value(TViewIndex)) );
75 }
76
77     Standard_Integer IGESDraw_Drawing::NbAnnotations () const
78 {
79   return (theAnnotations.IsNull() ? 0 : theAnnotations->Length() );
80 }
81
82     Handle(IGESData_IGESEntity) IGESDraw_Drawing::Annotation
83   (const Standard_Integer AnnotationIndex) const
84 {
85   return ( theAnnotations->Value(AnnotationIndex) );
86 }
87
88     gp_XY IGESDraw_Drawing::ViewToDrawing
89   (const Standard_Integer NumView, const gp_XYZ& ViewCoords) const
90 {
91   gp_XY         thisOrigin       = theViewOrigins->Value(NumView);
92   Standard_Real XOrigin          = thisOrigin.X();
93   Standard_Real YOrigin          = thisOrigin.Y();
94   Standard_Real theScaleFactor=0.; 
95
96   Handle(IGESData_ViewKindEntity) tempView = theViews->Value(NumView);
97   if (tempView->IsKind(STANDARD_TYPE(IGESDraw_View)))
98     {
99       DeclareAndCast(IGESDraw_View, thisView, tempView);
100       theScaleFactor   = thisView->ScaleFactor();
101     }
102   else if (tempView->IsKind(STANDARD_TYPE(IGESDraw_PerspectiveView)))
103     {
104       DeclareAndCast(IGESDraw_PerspectiveView, thisView, tempView);
105       theScaleFactor   = thisView->ScaleFactor();
106     }
107
108   Standard_Real XV               = ViewCoords.X();
109   Standard_Real YV               = ViewCoords.Y();
110
111   Standard_Real XD = XOrigin + (theScaleFactor * XV);
112   Standard_Real YD = YOrigin + (theScaleFactor * YV);
113
114   return ( gp_XY(XD, YD) );
115 }
116
117
118     Standard_Boolean  IGESDraw_Drawing::DrawingUnit (Standard_Real& val) const
119 {
120   val = 0.;
121   Handle(Standard_Type) typunit = STANDARD_TYPE(IGESGraph_DrawingUnits);
122   if (NbTypedProperties(typunit) != 1) return Standard_False;
123   DeclareAndCast(IGESGraph_DrawingUnits,units,TypedProperty(typunit)); 
124   if (units.IsNull()) return Standard_False;
125   val = units->UnitValue();
126   return Standard_True;
127 }
128
129     Standard_Boolean  IGESDraw_Drawing::DrawingSize
130   (Standard_Real& X, Standard_Real& Y) const
131 {
132   X = Y = 0.;
133   Handle(Standard_Type) typsize = STANDARD_TYPE(IGESGraph_DrawingSize);
134   if (NbTypedProperties(typsize) != 1) return Standard_False;
135   DeclareAndCast(IGESGraph_DrawingSize,size,TypedProperty(typsize)); 
136   if (size.IsNull()) return Standard_False;
137   X = size->XSize();  Y = size->YSize();
138   return Standard_True;
139 }