b311480e |
1 | -- Created on: 1994-11-21 |
2 | -- Created by: CAL |
3 | -- Copyright (c) 1994-1999 Matra Datavision |
4 | -- Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | -- |
6 | -- The content of this file is subject to the Open CASCADE Technology Public |
7 | -- License Version 6.5 (the "License"). You may not use the content of this file |
8 | -- except in compliance with the License. Please obtain a copy of the License |
9 | -- at http://www.opencascade.org and read it completely before using this file. |
10 | -- |
11 | -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
7fd59977 |
13 | -- |
b311480e |
14 | -- The Original Code and all software distributed under the License is |
15 | -- distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | -- Initial Developer hereby disclaims all such warranties, including without |
17 | -- limitation, any warranties of merchantability, fitness for a particular |
18 | -- purpose or non-infringement. Please see the License for the specific terms |
19 | -- and conditions governing the rights and limitations under the License. |
20 | |
21 | |
7fd59977 |
22 | -- Modified: TCL G002A, 28-11-00, new section "inquire methods" |
23 | |
7fd59977 |
24 | |
25 | class ImageFile from Graphic2d inherits Primitive from Graphic2d |
26 | |
27 | ---Version: |
28 | |
29 | ---Purpose: The primitive ImageFile |
30 | |
31 | ---Keywords: Primitive, ImageFile |
32 | ---Warning: |
33 | ---References: |
34 | |
35 | uses |
36 | |
37 | File from OSD, |
38 | AsciiString from TCollection, |
39 | Drawer from Graphic2d, |
40 | GraphicObject from Graphic2d, |
41 | Factor from Quantity, |
42 | Length from Quantity, |
43 | CardinalPoints from Aspect, |
44 | FStream from Aspect, |
45 | IFStream from Aspect |
46 | |
47 | raises |
48 | ImageDefinitionError from Graphic2d |
49 | |
50 | is |
51 | ------------------------- |
52 | -- Category: Constructors |
53 | ------------------------- |
54 | |
55 | Create (aGraphicObject: GraphicObject from Graphic2d; |
56 | aFile: in out File from OSD; |
57 | X, Y: Length from Quantity; |
58 | adx: Length from Quantity = 0.0; |
59 | ady: Length from Quantity = 0.0; |
60 | aTypeOfPlacement: CardinalPoints |
61 | from Aspect = Aspect_CP_Center; |
62 | aScale: Factor from Quantity = 1.0) |
63 | returns mutable ImageFile from Graphic2d |
64 | ---Level: Public |
65 | ---Purpose: Defines an image with its center location; |
66 | -- <X>, <Y> defines the position in the space model. |
67 | -- <adx>, <ady> defines an offset in the device space. |
68 | -- <ascale> defines a scale factor applied to the |
69 | -- original size of the image. |
70 | -- The image will be placed at this offset |
71 | -- according to the type of placement. |
72 | -- |
73 | -- CardinalPoints values : |
74 | -- - CP_North |
75 | -- - CP_NorthEast |
76 | -- - CP_East |
77 | -- - CP_SouthEast |
78 | -- - CP_South |
79 | -- - CP_SouthWest |
80 | -- - CP_West |
81 | -- - CP_NorthWest |
82 | -- - CP_Center |
83 | raises ImageDefinitionError; |
84 | ---Trigger: |
85 | -- If the file don't exist or has a null size. |
86 | ---Category: Constructors |
87 | |
88 | -------------------------- |
89 | -- Category: Draw and Pick |
90 | -------------------------- |
91 | |
92 | Draw (me : mutable; aDrawer: Drawer from Graphic2d) |
93 | is static protected; |
94 | ---Level: Internal |
95 | ---Purpose: Draws the image at the required center location |
96 | -- defined by the SetCenter method. |
97 | ---Category: Draw and Pick |
98 | |
99 | Pick (me : mutable; |
100 | X, Y: ShortReal from Standard; |
101 | aPrecision: ShortReal from Standard; |
102 | aDrawer: Drawer from Graphic2d) |
103 | returns Boolean from Standard |
104 | is static protected; |
105 | ---Purpose: Returns Standard_True if the image <me> is picked, |
106 | -- Standard_False if not. |
107 | ---Category: Draw and Pick |
108 | |
109 | --------------------------------------------------- |
110 | -- Category: Methods to modify the class definition |
111 | --------------------------------------------------- |
112 | |
113 | SetCenter (me: mutable; |
114 | X, Y: Length from Quantity) |
115 | is static; |
116 | ---Level: Public |
117 | ---Purpose: Modifies the center location of the image <me>. |
118 | ---Category: Methods to modify the class definition |
119 | |
120 | SetOffset (me: mutable; |
121 | dx, dy: Length from Quantity) |
122 | is static; |
123 | ---Level: Public |
124 | ---Purpose: Modifies the offset of the image <me>. |
125 | ---Category: Methods to modify the class definition |
126 | |
127 | SetPlacement (me: mutable; aPlacement: CardinalPoints from Aspect) |
128 | is static; |
129 | ---Level: Public |
130 | ---Purpose: Modifies the type of placement of the image <me>. |
131 | -- |
132 | -- CardinalPoints values : |
133 | -- - CP_North |
134 | -- - CP_NorthEast |
135 | -- - CP_East |
136 | -- - CP_SouthEast |
137 | -- - CP_South |
138 | -- - CP_SouthWest |
139 | -- - CP_West |
140 | -- - CP_NorthWest |
141 | -- - CP_Center |
142 | ---Category: Methods to modify the class definition |
143 | |
144 | Translate (me: mutable; |
145 | DX, DY: Length from Quantity) |
146 | is static; |
147 | ---Level: Public |
148 | ---Purpose: Modifies the center location of the image <me> |
149 | -- by translating it. |
150 | ---Category: Methods to modify the class definition |
151 | |
152 | SetScale (me: mutable; aScale: Factor from Quantity) is static; |
153 | ---Level: Public |
154 | ---Purpose: Changes the scale factor of the image. |
155 | ---Category: Methods to modify the class definition |
156 | |
157 | SetZoomable (me: mutable; aFlag: Boolean from Standard = Standard_False) |
158 | is static; |
159 | ---Level: Public |
160 | ---Purpose: The image <me> follows the scale factor of the view |
161 | -- if the flag is Standard_True. |
162 | ---Category: Zoom management |
163 | |
164 | Clear (me: mutable) is static; |
165 | ---Level: Public |
166 | ---Purpose: Clear the reference to this imagefile if something |
167 | -- inside have changed,Forced the reload of this at Draw() |
168 | -- time. |
169 | ---Category: Methods to modify the class definition |
170 | |
171 | ---------------------------- |
172 | -- Category: Zoom management |
173 | ---------------------------- |
174 | |
175 | Scale (me) |
176 | returns Factor from Quantity; |
177 | ---Level: Internal |
178 | ---Purpose: Returns the original scale factor applied to |
179 | -- the image <me>. |
180 | ---Category: Zoom management |
181 | |
182 | IsZoomable (me) |
183 | returns Boolean from Standard is static; |
184 | ---Level: Internal |
185 | ---Purpose: Returns Standard_True if the image <me> follows |
186 | -- the scale factor of the view. |
187 | ---Category: Zoom management |
188 | |
189 | ---------------------------- |
190 | -- Category: Inquire methods |
191 | ---------------------------- |
192 | |
193 | Position( me; X, Y: out Length from Quantity ); |
194 | ---Level: Public |
195 | ---Purpose: returns the position in the space model |
196 | |
197 | Offset( me; aX, aY: out Length from Quantity ); |
198 | ---Level: Public |
199 | ---Purpose: returns the offset in the device space |
200 | |
201 | Placement( me ) returns CardinalPoints from Aspect; |
202 | ---Level: Public |
203 | ---Purpose: returns the type of placement |
204 | |
205 | ImageFile( me ) returns File from OSD; |
206 | ---Level: Public |
207 | ---Purpose: returns the image file |
208 | |
209 | |
210 | Values (myclass; |
211 | aFile: in out File from OSD; |
212 | aWidth, aHeight: out Integer from Standard; |
213 | aDepth: out Integer from Standard) |
214 | returns Boolean from Standard; |
215 | ---Level: Internal |
216 | ---Purpose: Returns Standard_True, the Image pixel size |
217 | -- and the Image planes depth, if the image file : |
218 | -- - is not open |
219 | -- - exists |
220 | -- - have the extension .xwd |
221 | -- NOTE that only XWD image file type are recognized. |
222 | ---Category: Inquire methods |
223 | |
224 | ---------------------------- |
225 | -- Category: Private methods |
226 | ---------------------------- |
227 | |
228 | ComputeCenterAndSize (me : mutable; |
229 | aDrawer: Drawer from Graphic2d; |
230 | cx, cy, width, height: out ShortReal from Standard) |
231 | returns Boolean from Standard is static private; |
232 | ---Level: Internal |
233 | ---Purpose: Evaluates the center of the image in the device space. |
234 | -- Called by the methods : |
235 | -- - Graphic2d_ImageFile::Draw |
236 | -- - Graphic2d_ImageFile::Pick |
237 | -- - Graphic2d_ImageFile::FillAndDraw |
238 | --Returns FALSE if the size cann't gbe evaluated. |
239 | ---Category: Private methods |
240 | |
241 | SwapLong (myclass; |
242 | anAddress: Address from Standard; |
243 | aNumOfBytes: Integer from Standard); |
244 | ---Level: Internal |
245 | ---Purpose: Swaps long ints |
246 | ---Category: Private methods |
247 | |
248 | ---------------------------------------------------------------------- |
249 | |
250 | Save( me; aFStream: in out FStream from Aspect ) is virtual; |
251 | -- Retrieve( me; aIFStream: in out IFStream from AIS2D ) is virtual; |
252 | |
253 | fields |
254 | |
255 | myFile: File from OSD; |
256 | myFileName: AsciiString from TCollection; |
257 | myX, myY: ShortReal from Standard; |
258 | mydx, mydy: ShortReal from Standard; |
259 | myWidth, myHeight: Integer from Standard; |
260 | myPlacement: CardinalPoints from Aspect; |
261 | myIsZoomable: Boolean from Standard; |
262 | myScale: ShortReal from Standard; |
263 | myIsModified: Boolean from Standard; |
264 | |
265 | end ImageFile from Graphic2d; |