2 // Copyright (c) 1999 Matra Datavision
3 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
20 // Contains all plotter's SetXXX methods
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>
40 //==============================================================================
41 void PlotMgt_Plotter::SetModel (const TCollection_AsciiString& aValue)
43 SetStringValue (PLOT_DRVTYPE, myModel, aValue);
46 //==============================================================================
47 void PlotMgt_Plotter::SetTitle (const TCollection_AsciiString& aValue)
49 SetStringValue (PLOT_TITLE, myTitle, aValue);
52 //==============================================================================
53 void PlotMgt_Plotter::SetFileExtension (const TCollection_AsciiString& aValue)
55 SetStringValue (PLOT_EXTENSION, myExtension, aValue);
58 //==============================================================================
59 void PlotMgt_Plotter::SetPrintCommand (const TCollection_AsciiString& aValue)
61 SetStringValue (PLOT_PRINTCMD, myPrintCommand, aValue);
64 //==============================================================================
65 void PlotMgt_Plotter::SetBeforePrintCommand (const TCollection_AsciiString& aValue)
67 SetStringValue (PLOT_BEFORECMD, myBeforeCommand, aValue);
70 //==============================================================================
71 void PlotMgt_Plotter::SetAfterPrintCommand (const TCollection_AsciiString& aValue)
73 SetStringValue (PLOT_AFTERCMD, myAfterCommand, aValue);
76 //==============================================================================
77 void PlotMgt_Plotter::SetComments (const TCollection_AsciiString& aValue)
79 SetStringValue (PLOT_COMMENTS, myComments, aValue);
82 //==============================================================================
83 void PlotMgt_Plotter::SetBackDraw (const TCollection_AsciiString& aValue)
85 SetStringValue (PLOT_BACKDRAW, myBackDraw, aValue);
88 //==============================================================================
89 void PlotMgt_Plotter::SetColorMapping (const TCollection_AsciiString& aValue)
91 SetStringValue (PLOT_COLORMAPPING, myColorMapping, aValue);
94 //==============================================================================
95 void PlotMgt_Plotter::SetOutputFormat (const TCollection_AsciiString& aValue)
97 SetStringValue (PLOT_OUTFORMAT, myOutputFormat, aValue);
100 //==============================================================================
101 void PlotMgt_Plotter::SetDriverType (const TCollection_AsciiString& aValue)
103 SetStringValue (PLOT_DRVTYPE, myDriverType, aValue);
106 //==============================================================================
107 //==============================================================================
108 //==============================================================================
109 //==============================================================================
110 //==============================================================================
111 //==============================================================================
112 //==============================================================================
113 //==============================================================================
114 //==============================================================================
115 void PlotMgt_Plotter::SetMirrorPlot (const Standard_Boolean aValue)
117 SetBooleanValue (PLOT_MIRRORING, aValue);
120 //==============================================================================
121 void PlotMgt_Plotter::SetMultiSheet (const Standard_Boolean aValue)
123 SetBooleanValue (PLOT_MULTISHEET, aValue);
126 //==============================================================================
127 void PlotMgt_Plotter::SetFramePlot (const Standard_Boolean aValue)
129 SetBooleanValue (PLOT_FRAME, aValue);
134 //==============================================================================
135 void PlotMgt_Plotter::SetPlotTitle (const Standard_Boolean aValue)
137 SetBooleanValue (PLOT_PLOTTITLE, aValue);
140 //==============================================================================
141 void PlotMgt_Plotter::SetPlotComments (const Standard_Boolean aValue)
143 SetBooleanValue (PLOT_PLOTCOMMENT, aValue);
146 //==============================================================================
147 void PlotMgt_Plotter::SetPlotBackDraw (const Standard_Boolean aValue)
149 SetBooleanValue (PLOT_PLOTBACKDRAW, aValue);
154 //==============================================================================
155 void PlotMgt_Plotter::SetPlotterColor (const Standard_Boolean aValue)
157 SetBooleanValue (PLOT_PLOTTERCOLOR, aValue);
160 //==============================================================================
161 void PlotMgt_Plotter::SetEndOfPlotDriven (const Standard_Boolean aValue)
163 SetBooleanValue (PLOT_ENDOFPLOTDRIVEN, aValue);
166 //==============================================================================
167 void PlotMgt_Plotter::SetDryTimeDriven (const Standard_Boolean aValue)
169 SetBooleanValue (PLOT_DRYTIMEDRIVEN, aValue);
172 //==============================================================================
173 void PlotMgt_Plotter::SetPaperFeedDriven (const Standard_Boolean aValue)
175 SetBooleanValue (PLOT_FEEDDRIVEN, aValue);
178 //==============================================================================
179 void PlotMgt_Plotter::SetMirrorDriven (const Standard_Boolean aValue)
181 SetBooleanValue (PLOT_MIRRORDRIVEN, aValue);
184 //==============================================================================
185 void PlotMgt_Plotter::SetCheckSumDriven (const Standard_Boolean aValue)
187 SetBooleanValue (PLOT_CHECKSUMDRIVEN, aValue);
190 //==============================================================================
191 void PlotMgt_Plotter::SetMediaSaverDriven (const Standard_Boolean aValue)
193 SetBooleanValue (PLOT_MEDIASAVDRIVEN, aValue);
196 //==============================================================================
197 void PlotMgt_Plotter::SetQualityDriven (const Standard_Boolean aValue)
199 SetBooleanValue (PLOT_QUALITYDRIVEN, aValue);
202 //==============================================================================
203 void PlotMgt_Plotter::SetCopyDriven (const Standard_Boolean aValue)
205 SetBooleanValue (PLOT_COPYDRIVEN, aValue);
208 //==============================================================================
209 void PlotMgt_Plotter::SetPaperCutDriven (const Standard_Boolean aValue)
211 SetBooleanValue (PLOT_CUTDRIVEN, aValue);
214 //==============================================================================
215 void PlotMgt_Plotter::SetRotateDriven (const Standard_Boolean aValue)
217 SetBooleanValue (PLOT_ROTATEDRIVEN, aValue);
222 //==============================================================================
223 void PlotMgt_Plotter::SetCircleDriven (const Standard_Boolean aValue)
225 SetBooleanValue (PLOT_CIRCLEDRIVEN, aValue);
228 //==============================================================================
229 void PlotMgt_Plotter::SetEllipseDriven (const Standard_Boolean aValue)
231 SetBooleanValue (PLOT_ELLIPSEDRIVEN, aValue);
234 //==============================================================================
235 void PlotMgt_Plotter::SetCurveDriven (const Standard_Boolean aValue)
237 SetBooleanValue (PLOT_CURVEDRIVEN, aValue);
240 //==============================================================================
241 void PlotMgt_Plotter::SetTextDriven (const Standard_Boolean aValue)
243 SetBooleanValue (PLOT_TEXTDRIVEN, aValue);
246 //==============================================================================
247 void PlotMgt_Plotter::SetMarkerDriven (const Standard_Boolean aValue)
249 SetBooleanValue (PLOT_MARKERDRIVEN, aValue);
252 //==============================================================================
253 void PlotMgt_Plotter::SetRectangleDriven (const Standard_Boolean aValue)
255 SetBooleanValue (PLOT_RECTANGLEDRIVEN, aValue);
258 //==============================================================================
259 void PlotMgt_Plotter::SetFillDriven (const Standard_Boolean aValue)
261 SetBooleanValue (PLOT_FILLDRIVEN, aValue);
264 //==============================================================================
265 void PlotMgt_Plotter::SetPlottingColor (const Standard_Boolean aValue)
267 SetBooleanValue (PLOT_PLOTTINGCOLOR, aValue);
271 //==============================================================================
272 //==============================================================================
273 //==============================================================================
274 //==============================================================================
275 //==============================================================================
276 //==============================================================================
277 //==============================================================================
278 //==============================================================================
279 void PlotMgt_Plotter::SetPaperWidth (const Standard_Real aValue)
281 SetRealValue (PLOT_PAPERWIDTH, aValue);
284 //==============================================================================
285 void PlotMgt_Plotter::SetPaperLength (const Standard_Real aValue)
287 SetRealValue (PLOT_PAPERLENGTH, aValue);
290 //==============================================================================
291 void PlotMgt_Plotter::SetPaperSize (const Standard_Real aWidth,
292 const Standard_Real aLength)
294 SetPaperWidth (aWidth);
295 SetPaperLength (aLength);
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)
304 SetRealValue (PLOT_MINTOPMARGIN, aTop);
305 SetRealValue (PLOT_MINLEFTMARGIN, aLeft);
306 SetRealValue (PLOT_MINRIGHTMARGIN, aRight);
307 SetRealValue (PLOT_MINBOTTOMMARGIN, aBottom);
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)
316 SetRealValue (PLOT_TOPMARGIN, aTop);
317 SetRealValue (PLOT_LEFTMARGIN, aLeft);
318 SetRealValue (PLOT_RIGHTMARGIN, aRight);
319 SetRealValue (PLOT_BOTTOMMARGIN, aBottom);
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)
328 SetRealValue (PLOT_WIDTHOFFSET, aWOffset);
329 SetRealValue (PLOT_WIDTHSCALE, aWScale);
330 SetRealValue (PLOT_LENGTHOFFSET, anLOffset);
331 SetRealValue (PLOT_LENGTHSCALE, anLScale);
334 //==============================================================================
335 void PlotMgt_Plotter::SetSpaceDrawing (const Standard_Real aValue)
337 SetRealValue (PLOT_PLOTTINGGAP, aValue);
340 //==============================================================================
341 void PlotMgt_Plotter::SetPhysicalStep (const Standard_Real aValue)
343 SetRealValue (PLOT_PHYSICALSTEP, aValue);
346 //==============================================================================
347 void PlotMgt_Plotter::SetMinWidthOfLine (const Standard_Real aValue)
349 SetRealValue (PLOT_MINWIDTHOFLINE, aValue);
352 //==============================================================================
353 void PlotMgt_Plotter::SetWidthMaxGap (const Standard_Real aValue)
355 SetRealValue (PLOT_WIDTHMAXGAP, aValue);
358 //==============================================================================
359 void PlotMgt_Plotter::SetLineTypeMaxGap (const Standard_Real aValue)
361 SetRealValue (PLOT_LINETYPEMAXGAP, aValue);
364 //==============================================================================
365 void PlotMgt_Plotter::SetResolution (const Standard_Real aValue)
367 SetRealValue (PLOT_RESOLUTION, aValue);
370 //==============================================================================
371 void PlotMgt_Plotter::SetColorResolution (const Standard_Real aValue)
373 SetRealValue (PLOT_COLORRESOLUTION, aValue);
376 //==============================================================================
377 void PlotMgt_Plotter::SetFillWidth (const Standard_Real aValue)
379 SetRealValue (PLOT_FILLWIDTH, aValue);
382 //==============================================================================
383 //==============================================================================
384 //==============================================================================
385 //==============================================================================
386 //==============================================================================
387 //==============================================================================
388 //==============================================================================
389 //==============================================================================
390 void PlotMgt_Plotter::SetMediaSaverDelay (const Standard_Integer aValue)
392 SetIntegerValue (PLOT_MEDIASAVTIME, aValue);
395 //==============================================================================
396 void PlotMgt_Plotter::SetNumberOfCopies (const Standard_Integer aValue)
398 SetIntegerValue (PLOT_COPIES, aValue);
401 //==============================================================================
402 void PlotMgt_Plotter::SetDryTime (const Standard_Integer aValue)
404 SetIntegerValue (PLOT_DRYTIME, aValue);
407 //==============================================================================
408 void PlotMgt_Plotter::SetEndOfPlotTimer (const Standard_Integer aValue)
410 SetIntegerValue (PLOT_ENDOFPLOTTIMER, aValue);
413 //==============================================================================
414 void PlotMgt_Plotter::SetMaxColors (const Standard_Integer aValue)
416 SetIntegerValue (PLOT_MAXCOLORS, aValue);
419 //==============================================================================
420 void PlotMgt_Plotter::SetMaxPatterns (const Standard_Integer aValue)
422 SetIntegerValue (PLOT_MAXPATTERMS, aValue);
425 //==============================================================================
426 void PlotMgt_Plotter::SetColorMaxGap (const Standard_Integer aValue)
428 SetIntegerValue (PLOT_COLORMAXGAP, aValue);
431 //==============================================================================
432 void PlotMgt_Plotter::SetLinearDensity (const Standard_Integer aValue)
434 SetIntegerValue (PLOT_DENSITY, aValue);
437 //==============================================================================
438 void PlotMgt_Plotter::SetStylusNumber (const Standard_Integer aValue)
440 SetIntegerValue (PLOT_STYLUSNUMBER, aValue);
443 //==============================================================================
444 void PlotMgt_Plotter::SetPenMaxNumber (const Standard_Integer aValue)
446 SetIntegerValue (PLOT_MAXPENS, aValue);
449 //==============================================================================
450 void PlotMgt_Plotter::SetNumberInCarrousel (const Standard_Integer aValue)
452 SetIntegerValue (PLOT_MOUNTEDPENS, aValue);
455 //==============================================================================
456 //==============================================================================
457 //==============================================================================
458 //==============================================================================
459 //==============================================================================
460 //==============================================================================
461 //==============================================================================
462 //==============================================================================
463 void PlotMgt_Plotter::SetOrigin (const PlotMgt_TypeOfOrigin anOrigin)
465 TCollection_AsciiString oldVal;
466 GetStringValue (PLOT_ORIGIN, oldVal);
467 SetStringValue (PLOT_ORIGIN, oldVal, PlotMgt::StringFromOrigin (anOrigin));
470 //==============================================================================
471 void PlotMgt_Plotter::SetQuality (const PlotMgt_TypeOfQuality aQuality)
473 TCollection_AsciiString oldVal;
474 GetStringValue (PLOT_QUALITY, oldVal);
475 SetStringValue (PLOT_QUALITY, oldVal, PlotMgt::StringFromQuality (aQuality));
478 //==============================================================================
479 void PlotMgt_Plotter::SetImageFormat (const PlotMgt_ImageFormat anImageFormat)
481 TCollection_AsciiString oldVal;
482 GetStringValue (PLOT_IMGFORMAT, oldVal);
483 SetStringValue (PLOT_IMGFORMAT, oldVal, PlotMgt::StringFromImageFormat (anImageFormat));
486 //==============================================================================
487 void PlotMgt_Plotter::SetPlottingType (const PlotMgt_PlottingType aPlottingType)
489 TCollection_AsciiString oldVal;
490 GetStringValue (PLOT_PLOTTINGTYPE, oldVal);
491 SetStringValue (PLOT_PLOTTINGTYPE, oldVal, PlotMgt::StringFromPlottingType (aPlottingType));
494 //==============================================================================
495 void PlotMgt_Plotter::SetPaperFormat (const PlotMgt_PaperFormat aPaperFormat)
497 TCollection_AsciiString oldVal;
498 GetStringValue (PLOT_PAPERFORMAT, oldVal);
499 SetStringValue (PLOT_PAPERFORMAT, oldVal, PlotMgt::StringFromPaperFormat (aPaperFormat));
502 //==============================================================================
503 //==============================================================================
504 //==============================================================================
505 //==============================================================================
506 //==============================================================================
507 //==============================================================================
508 //==============================================================================
509 void PlotMgt_Plotter::SetPenColorIndex (const Handle(TColStd_HSequenceOfInteger)& aTable)
511 SetIntTable (PLOT_PENSINDEXCOLOR, aTable);
512 myPenColorIndex = aTable -> ShallowCopy ();
515 //==============================================================================
516 void PlotMgt_Plotter::SetPenWidthIndex (const Handle(TColStd_HSequenceOfInteger)& aTable)
518 SetIntTable (PLOT_PENSINDEXWIDTH, aTable);
519 myPenWidthIndex = aTable -> ShallowCopy ();
522 //==============================================================================
523 void PlotMgt_Plotter::SetPenTypeIndex (const Handle(TColStd_HSequenceOfInteger)& aTable)
525 SetIntTable (PLOT_PENSINDEXTYPE, aTable);
526 myPenTypeIndex = aTable -> ShallowCopy ();
529 //==============================================================================
530 void PlotMgt_Plotter::SetColorMap (const Handle(Aspect_ColorMap)& aColorMap)
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);
542 aLine += TCollection_AsciiString (r); aLine += " ";
543 aLine += TCollection_AsciiString (g); aLine += " ";
544 aLine += TCollection_AsciiString (b); aLine += "\"";
545 aMap -> Append (aLine);
547 myParameters -> Value (i) -> SetMValue (aMap);
548 myColorMap = Handle(Aspect_GenericColorMap)::DownCast(aColorMap);
552 //==============================================================================
553 void PlotMgt_Plotter::SetWidthMap (const Handle(Aspect_WidthMap)& aWidthMap)
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);
563 myParameters -> Value (i) -> SetMValue (aMap);
564 myWidthMap = aWidthMap;
568 //==============================================================================
569 void PlotMgt_Plotter::SetTypeMap (const Handle(Aspect_TypeMap)& aTypeMap)
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 ();
579 for (i = low; i <= up; i++) {
580 aLine += TCollection_AsciiString (aStyle.Values().Value (i));
581 if (i != up) aLine += " ";
584 aMap -> Append (aLine);
586 myParameters -> Value (i) -> SetMValue (aMap);
587 myTypeMap = aTypeMap;
591 //==============================================================================
592 void PlotMgt_Plotter::SetFontMap (const Handle(Aspect_FontMap)& aFontMap)
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);
602 myParameters -> Value (i) -> SetMValue (aMap);
603 myFontMap = aFontMap;