0023510: Integration of test grid "vis" into the new testing system
[occt.git] / src / PlotMgt / PlotMgt_Plotter_2.cxx
1 // Created by: DCB
2 // Copyright (c) 1999 Matra Datavision
3 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20 // Contains all plotter's SetXXX methods
21
22 #include <PlotMgt.hxx>
23 #include <PlotMgt_Plotter.hxx>
24 #include <PlotMgt_PlotterTools.hxx>
25 #include <PlotMgt_PlotterParameter.hxx>
26 #include <PlotMgt_HListOfPlotterParameter.hxx>
27 #include <TColQuantity_Array1OfLength.hxx>
28 #include <TColStd_HSequenceOfInteger.hxx>
29 #include <Quantity_Color.hxx>
30 #include <Quantity_TypeOfColor.hxx>
31 #include <Aspect_ColorMap.hxx>
32 #include <Aspect_WidthMap.hxx>
33 #include <Aspect_TypeMap.hxx>
34 #include <Aspect_FontMap.hxx>
35 #include <Aspect_ColorMapEntry.hxx>
36 #include <Aspect_WidthMapEntry.hxx>
37 #include <Aspect_TypeMapEntry.hxx>
38 #include <Aspect_FontMapEntry.hxx>
39
40 //==============================================================================
41 void PlotMgt_Plotter::SetModel (const TCollection_AsciiString& aValue)
42 {
43   SetStringValue (PLOT_DRVTYPE, myModel, aValue);
44 }
45
46 //==============================================================================
47 void PlotMgt_Plotter::SetTitle (const TCollection_AsciiString& aValue)
48 {
49   SetStringValue (PLOT_TITLE, myTitle, aValue);
50 }
51
52 //==============================================================================
53 void PlotMgt_Plotter::SetFileExtension (const TCollection_AsciiString& aValue)
54 {
55   SetStringValue (PLOT_EXTENSION, myExtension, aValue);
56 }
57
58 //==============================================================================
59 void PlotMgt_Plotter::SetPrintCommand (const TCollection_AsciiString& aValue)
60 {
61   SetStringValue (PLOT_PRINTCMD, myPrintCommand, aValue);
62 }
63
64 //==============================================================================
65 void PlotMgt_Plotter::SetBeforePrintCommand (const TCollection_AsciiString& aValue)
66 {
67   SetStringValue (PLOT_BEFORECMD, myBeforeCommand, aValue);
68 }
69
70 //==============================================================================
71 void PlotMgt_Plotter::SetAfterPrintCommand (const TCollection_AsciiString& aValue)
72 {
73   SetStringValue (PLOT_AFTERCMD, myAfterCommand, aValue);
74 }
75
76 //==============================================================================
77 void PlotMgt_Plotter::SetComments (const TCollection_AsciiString& aValue)
78 {
79   SetStringValue (PLOT_COMMENTS, myComments, aValue);
80 }
81
82 //==============================================================================
83 void PlotMgt_Plotter::SetBackDraw (const TCollection_AsciiString& aValue)
84 {
85   SetStringValue (PLOT_BACKDRAW, myBackDraw, aValue);
86 }
87
88 //==============================================================================
89 void PlotMgt_Plotter::SetColorMapping (const TCollection_AsciiString& aValue)
90 {
91   SetStringValue (PLOT_COLORMAPPING, myColorMapping, aValue);
92 }
93
94 //==============================================================================
95 void PlotMgt_Plotter::SetOutputFormat (const TCollection_AsciiString& aValue)
96 {
97   SetStringValue (PLOT_OUTFORMAT, myOutputFormat, aValue);
98 }
99
100 //==============================================================================
101 void PlotMgt_Plotter::SetDriverType (const TCollection_AsciiString& aValue)
102 {
103   SetStringValue (PLOT_DRVTYPE, myDriverType, aValue);
104 }
105
106 //==============================================================================
107 //==============================================================================
108 //==============================================================================
109 //==============================================================================
110 //==============================================================================
111 //==============================================================================
112 //==============================================================================
113 //==============================================================================
114 //==============================================================================
115 void PlotMgt_Plotter::SetMirrorPlot (const Standard_Boolean aValue)
116 {
117   SetBooleanValue (PLOT_MIRRORING, aValue);
118 }
119
120 //==============================================================================
121 void PlotMgt_Plotter::SetMultiSheet (const Standard_Boolean aValue)
122 {
123   SetBooleanValue (PLOT_MULTISHEET, aValue);
124 }
125
126 //==============================================================================
127 void PlotMgt_Plotter::SetFramePlot (const Standard_Boolean aValue)
128 {
129   SetBooleanValue (PLOT_FRAME, aValue);
130 }
131
132
133
134 //==============================================================================
135 void PlotMgt_Plotter::SetPlotTitle (const Standard_Boolean aValue)
136 {
137   SetBooleanValue (PLOT_PLOTTITLE, aValue);
138 }
139
140 //==============================================================================
141 void PlotMgt_Plotter::SetPlotComments (const Standard_Boolean aValue)
142 {
143   SetBooleanValue (PLOT_PLOTCOMMENT, aValue);
144 }
145
146 //==============================================================================
147 void PlotMgt_Plotter::SetPlotBackDraw (const Standard_Boolean aValue)
148 {
149   SetBooleanValue (PLOT_PLOTBACKDRAW, aValue);
150 }
151
152
153
154 //==============================================================================
155 void PlotMgt_Plotter::SetPlotterColor (const Standard_Boolean aValue)
156 {
157   SetBooleanValue (PLOT_PLOTTERCOLOR, aValue);
158 }
159
160 //==============================================================================
161 void PlotMgt_Plotter::SetEndOfPlotDriven (const Standard_Boolean aValue)
162 {
163   SetBooleanValue (PLOT_ENDOFPLOTDRIVEN, aValue);
164 }
165
166 //==============================================================================
167 void PlotMgt_Plotter::SetDryTimeDriven (const Standard_Boolean aValue)
168 {
169   SetBooleanValue (PLOT_DRYTIMEDRIVEN, aValue);
170 }
171
172 //==============================================================================
173 void PlotMgt_Plotter::SetPaperFeedDriven (const Standard_Boolean aValue)
174 {
175   SetBooleanValue (PLOT_FEEDDRIVEN, aValue);
176 }
177
178 //==============================================================================
179 void PlotMgt_Plotter::SetMirrorDriven (const Standard_Boolean aValue)
180 {
181   SetBooleanValue (PLOT_MIRRORDRIVEN, aValue);
182 }
183
184 //==============================================================================
185 void PlotMgt_Plotter::SetCheckSumDriven (const Standard_Boolean aValue)
186 {
187   SetBooleanValue (PLOT_CHECKSUMDRIVEN, aValue);
188 }
189
190 //==============================================================================
191 void PlotMgt_Plotter::SetMediaSaverDriven (const Standard_Boolean aValue)
192 {
193   SetBooleanValue (PLOT_MEDIASAVDRIVEN, aValue);
194 }
195
196 //==============================================================================
197 void PlotMgt_Plotter::SetQualityDriven (const Standard_Boolean aValue)
198 {
199   SetBooleanValue (PLOT_QUALITYDRIVEN, aValue);
200 }
201
202 //==============================================================================
203 void PlotMgt_Plotter::SetCopyDriven (const Standard_Boolean aValue)
204 {
205   SetBooleanValue (PLOT_COPYDRIVEN, aValue);
206 }
207
208 //==============================================================================
209 void PlotMgt_Plotter::SetPaperCutDriven (const Standard_Boolean aValue)
210 {
211   SetBooleanValue (PLOT_CUTDRIVEN, aValue);
212 }
213
214 //==============================================================================
215 void PlotMgt_Plotter::SetRotateDriven (const Standard_Boolean aValue)
216 {
217   SetBooleanValue (PLOT_ROTATEDRIVEN, aValue);
218 }
219
220
221
222 //==============================================================================
223 void PlotMgt_Plotter::SetCircleDriven (const Standard_Boolean aValue)
224 {
225   SetBooleanValue (PLOT_CIRCLEDRIVEN, aValue);
226 }
227
228 //==============================================================================
229 void PlotMgt_Plotter::SetEllipseDriven (const Standard_Boolean aValue)
230 {
231   SetBooleanValue (PLOT_ELLIPSEDRIVEN, aValue);
232 }
233
234 //==============================================================================
235 void PlotMgt_Plotter::SetCurveDriven (const Standard_Boolean aValue)
236 {
237   SetBooleanValue (PLOT_CURVEDRIVEN, aValue);
238 }
239
240 //==============================================================================
241 void PlotMgt_Plotter::SetTextDriven (const Standard_Boolean aValue)
242 {
243   SetBooleanValue (PLOT_TEXTDRIVEN, aValue);
244 }
245
246 //==============================================================================
247 void PlotMgt_Plotter::SetMarkerDriven (const Standard_Boolean aValue)
248 {
249   SetBooleanValue (PLOT_MARKERDRIVEN, aValue);
250 }
251
252 //==============================================================================
253 void PlotMgt_Plotter::SetRectangleDriven (const Standard_Boolean aValue)
254 {
255   SetBooleanValue (PLOT_RECTANGLEDRIVEN, aValue);
256 }
257
258 //==============================================================================
259 void PlotMgt_Plotter::SetFillDriven (const Standard_Boolean aValue)
260 {
261   SetBooleanValue (PLOT_FILLDRIVEN, aValue);
262 }
263
264 //==============================================================================
265 void PlotMgt_Plotter::SetPlottingColor (const Standard_Boolean aValue)
266 {
267   SetBooleanValue (PLOT_PLOTTINGCOLOR, aValue);
268 }
269
270
271 //==============================================================================
272 //==============================================================================
273 //==============================================================================
274 //==============================================================================
275 //==============================================================================
276 //==============================================================================
277 //==============================================================================
278 //==============================================================================
279 void PlotMgt_Plotter::SetPaperWidth (const Standard_Real aValue)
280 {
281   SetRealValue (PLOT_PAPERWIDTH, aValue);
282 }
283
284 //==============================================================================
285 void PlotMgt_Plotter::SetPaperLength (const Standard_Real aValue)
286 {
287   SetRealValue (PLOT_PAPERLENGTH, aValue);
288 }
289
290 //==============================================================================
291 void PlotMgt_Plotter::SetPaperSize (const Standard_Real aWidth,
292                                     const Standard_Real aLength)
293 {
294   SetPaperWidth  (aWidth);
295   SetPaperLength (aLength);
296 }
297
298 //==============================================================================
299 void PlotMgt_Plotter::SetHardMargins (const Standard_Real aLeft,
300                                       const Standard_Real aTop,
301                                       const Standard_Real aRight,
302                                       const Standard_Real aBottom)
303 {
304   SetRealValue (PLOT_MINTOPMARGIN,    aTop);
305   SetRealValue (PLOT_MINLEFTMARGIN,   aLeft);
306   SetRealValue (PLOT_MINRIGHTMARGIN,  aRight);
307   SetRealValue (PLOT_MINBOTTOMMARGIN, aBottom);
308 }
309
310 //==============================================================================
311 void PlotMgt_Plotter::SetMargins (const Standard_Real aLeft,
312                                   const Standard_Real aTop,
313                                   const Standard_Real aRight,
314                                   const Standard_Real aBottom)
315 {
316   SetRealValue (PLOT_TOPMARGIN,    aTop);
317   SetRealValue (PLOT_LEFTMARGIN,   aLeft);
318   SetRealValue (PLOT_RIGHTMARGIN,  aRight);
319   SetRealValue (PLOT_BOTTOMMARGIN, aBottom);
320 }
321
322 //==============================================================================
323 void PlotMgt_Plotter::SetHardMappings (const Standard_Real aWOffset,
324                                        const Standard_Real aWScale,
325                                        const Standard_Real anLOffset,
326                                        const Standard_Real anLScale)
327 {
328   SetRealValue (PLOT_WIDTHOFFSET,  aWOffset);
329   SetRealValue (PLOT_WIDTHSCALE,   aWScale);
330   SetRealValue (PLOT_LENGTHOFFSET, anLOffset);
331   SetRealValue (PLOT_LENGTHSCALE,  anLScale);
332 }
333
334 //==============================================================================
335 void PlotMgt_Plotter::SetSpaceDrawing (const Standard_Real aValue)
336 {
337   SetRealValue (PLOT_PLOTTINGGAP, aValue);
338 }
339
340 //==============================================================================
341 void PlotMgt_Plotter::SetPhysicalStep (const Standard_Real aValue)
342 {
343   SetRealValue (PLOT_PHYSICALSTEP, aValue);
344 }
345
346 //==============================================================================
347 void PlotMgt_Plotter::SetMinWidthOfLine (const Standard_Real aValue)
348 {
349   SetRealValue (PLOT_MINWIDTHOFLINE, aValue);
350 }
351
352 //==============================================================================
353 void PlotMgt_Plotter::SetWidthMaxGap (const Standard_Real aValue)
354 {
355   SetRealValue (PLOT_WIDTHMAXGAP, aValue);
356 }
357
358 //==============================================================================
359 void PlotMgt_Plotter::SetLineTypeMaxGap (const Standard_Real aValue)
360 {
361   SetRealValue (PLOT_LINETYPEMAXGAP, aValue);
362 }
363
364 //==============================================================================
365 void PlotMgt_Plotter::SetResolution (const Standard_Real aValue)
366 {
367   SetRealValue (PLOT_RESOLUTION, aValue);
368 }
369
370 //==============================================================================
371 void PlotMgt_Plotter::SetColorResolution (const Standard_Real aValue)
372 {
373   SetRealValue (PLOT_COLORRESOLUTION, aValue);
374 }
375
376 //==============================================================================
377 void PlotMgt_Plotter::SetFillWidth (const Standard_Real aValue)
378 {
379   SetRealValue (PLOT_FILLWIDTH, aValue);
380 }
381
382 //==============================================================================
383 //==============================================================================
384 //==============================================================================
385 //==============================================================================
386 //==============================================================================
387 //==============================================================================
388 //==============================================================================
389 //==============================================================================
390 void PlotMgt_Plotter::SetMediaSaverDelay (const Standard_Integer aValue)
391 {
392   SetIntegerValue (PLOT_MEDIASAVTIME, aValue);
393 }
394
395 //==============================================================================
396 void PlotMgt_Plotter::SetNumberOfCopies (const Standard_Integer aValue)
397 {
398   SetIntegerValue (PLOT_COPIES, aValue);
399 }
400
401 //==============================================================================
402 void PlotMgt_Plotter::SetDryTime (const Standard_Integer aValue)
403 {
404   SetIntegerValue (PLOT_DRYTIME, aValue);
405 }
406
407 //==============================================================================
408 void PlotMgt_Plotter::SetEndOfPlotTimer (const Standard_Integer aValue)
409 {
410   SetIntegerValue (PLOT_ENDOFPLOTTIMER, aValue);
411 }
412
413 //==============================================================================
414 void PlotMgt_Plotter::SetMaxColors (const Standard_Integer aValue)
415 {
416   SetIntegerValue (PLOT_MAXCOLORS, aValue);
417 }
418
419 //==============================================================================
420 void PlotMgt_Plotter::SetMaxPatterns (const Standard_Integer aValue)
421 {
422   SetIntegerValue (PLOT_MAXPATTERMS, aValue);
423 }
424
425 //==============================================================================
426 void PlotMgt_Plotter::SetColorMaxGap (const Standard_Integer aValue)
427 {
428   SetIntegerValue (PLOT_COLORMAXGAP, aValue);
429 }
430
431 //==============================================================================
432 void PlotMgt_Plotter::SetLinearDensity (const Standard_Integer aValue)
433 {
434   SetIntegerValue (PLOT_DENSITY, aValue);
435 }
436
437 //==============================================================================
438 void PlotMgt_Plotter::SetStylusNumber (const Standard_Integer aValue)
439 {
440   SetIntegerValue (PLOT_STYLUSNUMBER, aValue);
441 }
442
443 //==============================================================================
444 void PlotMgt_Plotter::SetPenMaxNumber (const Standard_Integer aValue)
445 {
446   SetIntegerValue (PLOT_MAXPENS, aValue);
447 }
448
449 //==============================================================================
450 void PlotMgt_Plotter::SetNumberInCarrousel (const Standard_Integer aValue)
451 {
452   SetIntegerValue (PLOT_MOUNTEDPENS, aValue);
453 }
454
455 //==============================================================================
456 //==============================================================================
457 //==============================================================================
458 //==============================================================================
459 //==============================================================================
460 //==============================================================================
461 //==============================================================================
462 //==============================================================================
463 void PlotMgt_Plotter::SetOrigin (const PlotMgt_TypeOfOrigin anOrigin)
464 {
465   TCollection_AsciiString oldVal;
466   GetStringValue (PLOT_ORIGIN, oldVal);
467   SetStringValue (PLOT_ORIGIN, oldVal, PlotMgt::StringFromOrigin (anOrigin));
468 }
469
470 //==============================================================================
471 void PlotMgt_Plotter::SetQuality (const PlotMgt_TypeOfQuality aQuality)
472 {
473   TCollection_AsciiString oldVal;
474   GetStringValue (PLOT_QUALITY, oldVal);
475   SetStringValue (PLOT_QUALITY, oldVal, PlotMgt::StringFromQuality (aQuality));
476 }
477
478 //==============================================================================
479 void PlotMgt_Plotter::SetImageFormat (const PlotMgt_ImageFormat anImageFormat)
480 {
481   TCollection_AsciiString oldVal;
482   GetStringValue (PLOT_IMGFORMAT, oldVal);
483   SetStringValue (PLOT_IMGFORMAT, oldVal, PlotMgt::StringFromImageFormat (anImageFormat));
484 }
485
486 //==============================================================================
487 void PlotMgt_Plotter::SetPlottingType (const PlotMgt_PlottingType aPlottingType)
488 {
489   TCollection_AsciiString oldVal;
490   GetStringValue (PLOT_PLOTTINGTYPE, oldVal);
491   SetStringValue (PLOT_PLOTTINGTYPE, oldVal, PlotMgt::StringFromPlottingType (aPlottingType));
492 }
493
494 //==============================================================================
495 void PlotMgt_Plotter::SetPaperFormat (const PlotMgt_PaperFormat aPaperFormat)
496 {
497   TCollection_AsciiString oldVal;
498   GetStringValue (PLOT_PAPERFORMAT, oldVal);
499   SetStringValue (PLOT_PAPERFORMAT, oldVal, PlotMgt::StringFromPaperFormat (aPaperFormat));
500 }
501
502 //==============================================================================
503 //==============================================================================
504 //==============================================================================
505 //==============================================================================
506 //==============================================================================
507 //==============================================================================
508 //==============================================================================
509 void PlotMgt_Plotter::SetPenColorIndex (const Handle(TColStd_HSequenceOfInteger)& aTable)
510 {
511   SetIntTable (PLOT_PENSINDEXCOLOR, aTable);
512   myPenColorIndex = aTable -> ShallowCopy ();
513 }
514
515 //==============================================================================
516 void PlotMgt_Plotter::SetPenWidthIndex (const Handle(TColStd_HSequenceOfInteger)& aTable)
517 {
518   SetIntTable (PLOT_PENSINDEXWIDTH, aTable);
519   myPenWidthIndex = aTable -> ShallowCopy ();
520 }
521
522 //==============================================================================
523 void PlotMgt_Plotter::SetPenTypeIndex (const Handle(TColStd_HSequenceOfInteger)& aTable)
524 {
525   SetIntTable (PLOT_PENSINDEXTYPE, aTable);
526   myPenTypeIndex = aTable -> ShallowCopy ();
527 }
528
529 //==============================================================================
530 void PlotMgt_Plotter::SetColorMap (const Handle(Aspect_ColorMap)& aColorMap)
531 {
532   Handle(TColStd_HSequenceOfAsciiString) aMap = new TColStd_HSequenceOfAsciiString ();
533   Standard_Integer j, i = FindParameter (PLOT_COLORMAPRGB), n = aColorMap -> Size ();
534   if (i >= 1 && i <= NumberOfParameters ()) {
535     TCollection_AsciiString aLine;
536     Quantity_Color aColor;
537     Standard_Real r, g, b;
538     for (j = 1; j <= n; j++) {
539       aColor = aColorMap -> Entry (j).Color ();
540       aColor.Values (r, g, b, Quantity_TOC_RGB);
541       aLine  = "\"";
542       aLine += TCollection_AsciiString (r); aLine += " ";
543       aLine += TCollection_AsciiString (g); aLine += " ";
544       aLine += TCollection_AsciiString (b); aLine += "\"";
545       aMap -> Append (aLine);
546     }
547     myParameters -> Value (i) -> SetMValue (aMap);
548     myColorMap = Handle(Aspect_GenericColorMap)::DownCast(aColorMap);
549   }
550 }
551
552 //==============================================================================
553 void PlotMgt_Plotter::SetWidthMap (const Handle(Aspect_WidthMap)& aWidthMap)
554 {
555   Handle(TColStd_HSequenceOfAsciiString) aMap = new TColStd_HSequenceOfAsciiString ();
556   Standard_Integer j, i = FindParameter (PLOT_WIDTHMAP), n = aWidthMap -> Size ();
557   if (i >= 1 && i <= NumberOfParameters ()) {
558     TCollection_AsciiString aLine;
559     for (j = 1; j <= n; j++) {
560       aLine = TCollection_AsciiString (aWidthMap -> Entry(j).Width());
561       aMap -> Append (aLine);
562     }
563     myParameters -> Value (i) -> SetMValue (aMap);
564     myWidthMap = aWidthMap;
565   }
566 }
567
568 //==============================================================================
569 void PlotMgt_Plotter::SetTypeMap (const Handle(Aspect_TypeMap)& aTypeMap)
570 {
571   Handle(TColStd_HSequenceOfAsciiString) aMap = new TColStd_HSequenceOfAsciiString ();
572   Standard_Integer j, i = FindParameter (PLOT_LINETYPEMAP), n = aTypeMap -> Size ();
573   if (i >= 1 && i <= NumberOfParameters ()) {
574     TCollection_AsciiString aLine;
575     for (j = 1; j <= n; j++) {
576       Aspect_LineStyle aStyle = aTypeMap -> Entry(j).Type();
577       Standard_Integer low = aStyle.Values().Lower (), up = aStyle.Values().Upper ();
578       aLine  = "\"";
579       for (i = low; i <= up; i++) {
580         aLine += TCollection_AsciiString (aStyle.Values().Value (i));
581         if (i != up) aLine += " ";
582         else         aLine += "\"";
583       }
584       aMap -> Append (aLine);
585     }
586     myParameters -> Value (i) -> SetMValue (aMap);
587     myTypeMap = aTypeMap;
588   }
589 }
590
591 //==============================================================================
592 void PlotMgt_Plotter::SetFontMap (const Handle(Aspect_FontMap)& aFontMap)
593 {
594   Handle(TColStd_HSequenceOfAsciiString) aMap = new TColStd_HSequenceOfAsciiString ();
595   Standard_Integer j, i = FindParameter (PLOT_FONTMAP), n = aFontMap -> Size ();
596   if (i >= 1 && i <= NumberOfParameters ()) {
597     TCollection_AsciiString aLine;
598     for (j = 1; j <= n; j++) {
599       aLine = aFontMap -> Entry(j).Type().AliasName();
600       aMap -> Append (aLine);
601     }
602     myParameters -> Value (i) -> SetMValue (aMap);
603     myFontMap = aFontMap;
604   }
605 }