summaryrefslogtreecommitdiff
path: root/src/V2d/V2d_View.cdl
blob: 47c16184866f1cdbc1830bda7066d6d32cd2a4c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
-- File:        V2d_View.cdl
-- Created:     Tue Jul  6 12:32:02 1993
-- Author:      Jean Louis FRENKEL
-- Modified:    EUG - 13/11/97 -> ???????? Plotter management
--              FMN - 06/01/98 -> BUC60065
--              stt: 25-02-98: S3558 ajout IfManageStandardEvent
--              stt: 08-04-98: suppr IfManageStandardEvent
--              dcb/syl : OCT-98 : ScreenCopy() method.
--              TCL - 12-06-00 -> Pick( Xmin, Ymin, Xmax, Ymax )	method
--	            G002 : TCL - 03-10-00 -> new methods for setting up a background 
--              SAV 14/11/01 Added PickByCircle()
--    	    	SAV 24/11/01 setting background by Quantity_Color object.
--    	    	SAV 16/07/02 Added Color( Quantity_Color ) to retrieve background via RGB

---Copyright:    Matra Datavision 1993


class View from V2d inherits View from Viewer

    	---Purpose: Defines the application object view for the 2D Viewer,
    	-- V2d_Viewer. The functions in this framework manage
    	-- the origin and the size of the scene displayed in the view (zoom, panning, etc.).
        
uses

    Viewer                     from V2d,
    TypeOfWindowResizingEffect from V2d,
    ViewerPointer              from V2d,
    DisplayList                from Graphic2d,
    ViewMapping                from Graphic2d,
    View                       from Graphic2d,
    GraphicObject              from Graphic2d,
    PickMode                   from Graphic2d,
    Buffer                     from Graphic2d,
    Length                     from Quantity,
    Ratio                      from Quantity, 
    Factor                     from Quantity,
    WindowDriver               from Aspect,
    FillMethod                 from Aspect,
    TypeOfColorSpace           from Aspect,
    PlotterDriver              from PlotMgt,
    NameOfColor                from Quantity,
    Color                      from Quantity
    
raises
    BadValue from Viewer
is
    Create( aWindowDriver: WindowDriver from Aspect;
            aViewer: Viewer from V2d;
            aXCenter: Length from Quantity = 0;
            aYCenter: Length from Quantity = 0;
            aSize:    Length from Quantity = 1000) 
    returns mutable View from V2d;
    	---Purpose: Creates a view which represents a portion of the user space.
    	--          This portion is defined by  the point (aXCenter,aYCenter)
    	--          which will be represent at the center of the window and by aSize.
    	--          aWindowDriver defines a window and a driver.
             
    SetDefaultPosition(me: mutable;aXCenter: Length from Quantity = 0;
                             aYCenter: Length from Quantity = 0;
                             aSize:    Length from Quantity = 1000)
    	---Purpose: Defines the default position aXCenter, aYCenter and
    	-- the size aSize used in the Reset function.
    is static;
    
    Fitall (me: mutable) 
    	---Purpose: Automatic Zoom-Panning. Objects visible in the view are
    	--      visualised so as to occupy the maximum amount of space
    	--      while respecting the initial height/width ratio.
    	--      Updates the view. The resulting space also takes into account a default
    	--      margin that can be modified with SetFitallRatio. The view is updated.
    is static;
    
    WindowFit(me: mutable; aX1,aY1,aX2,aY2: Integer from Standard)
    	---Purpose: The point of the graphic view corresponding to the
    	--          middle of the window aX1,aY1,aX2,aY2 (in pixel coordinates)
    	--          comes to the center of the window.
    	--          Updates the view
    raises BadValue from Viewer
    	---Purpose:  Warning! raises BadValue from Viewer if aX1 = aX2 or aY1 = aY2;
    is redefined static;

    
    Fit(me: mutable; aX1,aY1,aX2,aY2: Length from Quantity;UseMinimum: Boolean from Standard = Standard_True)
    	---Purpose: The point of the graphic view corresponding to the
    	--          middle of the window aX1,aY1,aX2,aY2 (in user coordinates)
    	--          comes to the center of the window.
    	--          If UseMinimum is true the smallest dimension of the rectangle
    	--          will be zoom to occupy the view. If not the greatest dimension wiil be used.
    	--          Updates the view
    raises BadValue from Viewer
    	---Purpose:  Warning! raises BadValue from Viewer if aX1 = aX2 or aY1 = aY2;
    is static;

    SetFitallRatio (me: mutable; aRatio: Ratio from Quantity)
    	---Purpose: Sets the 10 mm default margin aRatio which is taken
    	-- into account by the Fitall function.
    	-- Exceptions
    	-- Viewer_BadValue if aRatio is less than 0 or greater than or equal to 1.
    raises BadValue from Viewer
       is static;
    
    Zoom (me:mutable; Zoom: Factor from Quantity)
    	---Purpose: Increases the size of the portion of user-space 
    	--          by a factor of Zoom and updates the view.
    raises BadValue from Viewer
    	---Purpose:  Warning! raises BadValue from Viewer if aRatio <= 0.
    is static;
     
    Zoom (me:mutable; aX1,aY1,aX2,aY2: Integer from Standard;
                      aCoefficient:Ratio from Quantity = 0.005 )
    	---Purpose: Increases the size of the portion of user-space by
    	-- a zoom factor which is calculated from the two
    	-- screen points aX1, aY1 and aX2, aY2 so that Z = 1/(1 + C x D) where:
    	-- -   C is the coefficient aCoefficient and
    	-- -   D is the distance between the two points aX1,aY1 and aX2,aY2.
    is static;
    
    Zoom (me:mutable; aX, aY: Integer from Standard;
                      aCoefficient:Ratio from Quantity = 0.005 ) 
    	---Purpose: Increases the size of the portion of user-space by
    	-- a zoom factor which is calculated from the current
    	-- point aX,aY and the screen center. The default factor is 0.005.
    is static;

    Magnify(me: mutable; anOriginView: View from V2d;
                         X1,Y1,X2,Y2: Integer from Standard)
    	---Purpose: Defines the default view mapping from two screen
    	-- points in a previous view anOriginView. The view is updated.
    is static;
                        
    Translate (me:mutable; dx,dy: Length from Quantity)
    	---Purpose: Translates the dx,dy center of the objects space.
    is static;
    
    Place (me: mutable; x,y: Integer from Standard;
                      aZoomFactor: Factor from Quantity = 1)
    	---Purpose: places the point of the view corresponding
    	--          at the pixel position x,y at the center of the window
    	--          and updates the view.
    is redefined static;
     
    ScreenPlace (me:mutable; x,y: Length from Quantity;
                      aZoomFactor: Factor from Quantity = 1)
    	---Purpose: Places the center of the object's space in the center
    	-- of the window according to the zoom factor. The view is updated.
    is static;
    
    Pan (me:mutable; dx,dy: Integer from Standard)

    	---Purpose: Translates the center of the object's space and
    	-- updates the view. The translation is specified in screen coordinates.
    is static; 

    Convert (me; V: Integer from Standard) returns Length from Quantity
    	---Purpose: Converts a screen value into the view space value V.
    is static;

    Convert (me; X, Y:  Integer from Standard; 
                 ViewX, ViewY: out Length from Quantity)
    	---Purpose: Converts the screen space coordinates X, Y into the
    	-- view space coordinates ViewX, ViewY.
    is static;

    Convert (me; ViewX, ViewY: Length from Quantity;
                 X, Y:  out Integer from Standard)
    	---Purpose: Converts the view space coordinates ViewX, ViewY
    	-- into the screen space coordinates X, Y.
    is static;
    
    Convert (me; aDriverSize: Length from Quantity)
    	---Purpose: returns a view size from a driver size.
    returns Length from Quantity
    is static;
    
    Reset (me: mutable)
    	---Purpose: Resets the viewmapping of the view and updates the view.
    is static;
    
    Previous(me: mutable)
    	---Purpose: switches the view to its previous viewmapping
    	--          and updates the view.
    is static;
    
    DisableStorePrevious(me: mutable)
    	---Purpose: Disables the Previous function in this framework.
    is static;
    
    EnableStorePrevious(me: mutable)
    	---Purpose: Enables the Previous function in this framework.
    is static;
    
    Update(me)
    	---Purpose: Clears the window and redraws all primitives.
    is redefined static;
    

    UpdateNew(me)
    	---Purpose: draws the objects created since the last update.
    is static;
 
    RestoreArea ( me ;
                      Xc, Yc : Integer from Standard ;
                      Width, Height : Integer from Standard )
    	---Purpose: Restores The Window Area defined by his center
    	---         and PIXEL size from the BackingStored Window
        -- Warning
    	-- This function only works if the window is double-buffered.
    is static;
    
    Restore(me)
    	---Purpose: Restores the full window area from the backing stored window.
    	-- Warning
    	-- This function only works if the window is double-buffered.
    is static;
     
    Dump(me)
    ---Purpose: 
    is static;
    
	Dump( me; aFileName: CString from Standard );
    ---Purpose: 
    
    
--    Pick(me; X,Y, aPrecision: Integer from Standard)
    Pick(me : mutable; X,Y, aPrecision: Integer from Standard)
        returns DisplayList from Graphic2d
    	---Purpose: From the X, Y coordinates, returns the list of picked
    	-- graphic objects within the precision value aPrecision.
    is static;

    PickByCircle(me : mutable; X, Y, Radius: Integer from Standard)
        returns DisplayList from Graphic2d
    ---Purpose: 
    is static;

	Pick( me: mutable; Xmin, Ymin, Xmax, Ymax: Integer from Standard;
	      aPickMode: PickMode from Graphic2d = Graphic2d_PM_INCLUDE )
        returns DisplayList from Graphic2d;
    	---Purpose: Returns the list of the picked graphic objects.
    
    Erase( me: mutable )
    	---Purpose: Removes all the graphic objects from the view.
    is static;
    
    MustBeResized(me: mutable; anEffect: TypeOfWindowResizingEffect from V2d)
    	---Purpose: indicates that the window in which the view is drawn has been resized
    	--          and updates the view. 
    is static;

    HasBeenMoved(me: mutable)
    	---Purpose: Indicates whether the window associated with the
    	-- view has been moved or not.
    is static;
        
    Plot(me; aPlotterDriver: PlotterDriver from PlotMgt;
             aXCenter: Length from Quantity;
             aYCenter: Length from Quantity;
             aScale: Factor from Quantity=1.0) 
    is static;
    	---Purpose:    Plots the view to a plotter aPlotterDriver centered
    	-- through aXCenter, aYCenter with the plotting scale aScale.
    
    Plot(me; aPlotterDriver: PlotterDriver from PlotMgt;
             aScale: Factor from Quantity=1.0) 
    is static;          
    	---Purpose: plot a view as on screen.
    	-- Note:     if <aScale> is zero then plots exactly what is on the screen
    
    PlotScreen(me; aPlotterDriver: PlotterDriver from PlotMgt)
    	---Purpose:Plots the view to a plotter according to the current
    	-- size and center of the view.
    is static;
        
    ScreenCopy (me: mutable;
      aPlotterDriver   : PlotterDriver from PlotMgt;
      fWhiteBackground : Boolean from Standard = Standard_True;
      aScale           : Factor from Quantity = 1.0
    ) is static;   
    	---Purpose: dump the view

    PostScriptOutput(me; aFile: CString from Standard;
                         aWidth, aHeight: Length from Quantity;
                         aXCenter, aYCenter: Length from Quantity;
                         aScale: Factor from Quantity;
                         aTypeOfColorSpace: TypeOfColorSpace from Aspect)
    	---Purpose: 
    	-- Plots the view to the PostScript file aFile according to
    	-- a paper format specified by the arguments aWidth,
    	-- aHeight, aXCenter, aYCenter with the scale aScale.
    is static;
                         
    ScreenPostScriptOutput(me; aFile: CString from Standard;
                               aWidth, aHeight: Length from Quantity;
                               aTypeOfColorSpace: TypeOfColorSpace from Aspect)
    	---Purpose: Plots the view to the PostScript file aFile according to
    	-- the paper format specified by the arguments aWidth,
    	-- aHeight. This is done by keeping the same view size and center.
    is static;
    
    Hit(me; X,Y: Integer from Standard;
            gx,gy: out Length from Quantity)
    	---Purpose: From the X,Y point, returns the nearest point gx,gy
    	-- on the grid.
    is static;
    
    ShowHit(me: mutable; X,Y: Integer from Standard)
    	---Purpose: shows the point matching the grid.
    	--          if the hit has already been shown, it is first erased.
    	--          Does not update the view.
    is static;
    
    
    EraseHit(me: mutable)
    	---Purpose: erases the hit point and updates the view.
    is static;
    
    SetDefaultHighlightColor(me: mutable; aColorIndex: Integer from Standard)
    is static;
    	---Purpose: Defines the default override color of objects or 
    	--		primitives using Highlight() methods.
    
    SetDeflection(me: mutable; aDeflection: Length from Quantity)
    	---Purpose: Updates the drawing precision factor aDeflection for
    	-- curves and circles.
    is static;
        
---Category: inquire methods
--           
    Deflection(me) returns Length from Quantity
    is static;

    	---Purpose: Returns the current deflection coefficient.
    
    View (me) returns mutable View from Graphic2d
    	---Purpose: Returns the associated Grahic2d view with this view.
    is static;
    
    Viewer (me) returns mutable Viewer from V2d
    	---Purpose: Returns the parent viewer of this view.
    is static;
    
    Driver(me) returns mutable WindowDriver from Aspect
    	---Purpose: Returns the window driver handle associated with this view.
    is static;
    
    Zoom(me) returns Factor from Quantity
    	---Purpose: returns the current zoom factor of the view.
    is static;
    
    Center(me; aX, aY: out Length from Quantity)
    	---Purpose: returns the current point of the user space
    	--          being at the center of the view.
    is static;
    ---Category: private methods:

    Size(me) returns Length from Quantity
    is static;
  
    	---Purpose: Returns the current size of the view.  
    
    Color(me) returns NameOfColor from Quantity
    	---Purpose: returns the background color of the view.
    is static;

    Color(me; color : out Color from Quantity)
    	---Purpose: returns the background color of the view.
    is static;

    Scroll(me: mutable; XCenter,YCenter,DX,DY: out Integer from Standard)
    is static;
    
    StoreCurrent(me: mutable)
    ---Purpose: 
    is static private;
    
    MapToCenter(me: mutable)
    ---Purpose: 
    is static private; 
    
    DefaultHighlightColor(me)
    returns Integer from Standard is static;
    	---Purpose: Returns the default override color of objects or 
    	--		primitives using Highlight() methods.
    	--  Warning: Returns -1 when the color index is not defined.
    
---Category: compatibility.

    Fit(me: mutable; aX1,aY1,aX2,aY2: Integer from Standard)
    	---Purpose: idem than WindowFit
    is static;

-------------------------------------------------------------------------
---Category: Methods to modify the background of this view
-------------------------------------------------------------------------
    
	SetBackground( me: mutable; aNameColor: NameOfColor from Quantity );
	---Level: Public
	---Purpose: Defines the color of view's background

	SetBackground( me: mutable; color: Color from Quantity );
	---Level: Public
	---Purpose: Defines the color of view's background

	SetBackground( me: mutable; 
		aNameFile: CString from Standard;
		aMethod: FillMethod from Aspect = Aspect_FM_CENTERED )
	returns Boolean from Standard;
	---Level: Public
	---Purpose: Loads the view background from an image file <aName>
	-- defined with a supported format XWD,GIF or BMP
	-- and returns TRUE if the operation is successfull.

--------------------------------------------------------------------------

fields

    myWindowDriver: WindowDriver from Aspect;
    myViewer:   ViewerPointer from V2d;
    myFitallRatio: Real from Standard;
    myDeflection: Real from Standard;
    myViewMapping: ViewMapping from Graphic2d;
    
-- MapTo definition:

    myXPosition: Real from Standard;
    myYPosition: Real from Standard;
    myScale: Real from Standard;
    
-- Previous Position:

    myPreviousX: Real from Standard;
    myPreviousY: Real from Standard;
    myPreviousSize: Real from Standard;
    myPreviousXPosition: Real from Standard;
    myPreviousYPosition: Real from Standard;
    myPreviousScale: Real from Standard;
    myEnablePrevious: Boolean from Standard;    
    myHitPoint: GraphicObject from Graphic2d; 
    myHitBuf: Buffer from Graphic2d;
-- Current window size:

    myWidth: Real from Standard;
    myHeight: Real from Standard;    

-- scrolling managment.
    pxmin,pymin,pxmax,pymax: Real from Standard;
    
end View from V2d;