0023510: Integration of test grid "vis" into the new testing system
[occt.git] / src / PlotMgt / PlotMgt_PlotterDriver.cxx
CommitLineData
b311480e 1// Created by: SYL & DCB
2// Copyright (c) 1993-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
7fd59977 20
21#define BUC60766 //GG 041000
22// The plotter filename must be preserved when it contains
23// a directory definition for compatibillity.
24
25#include <PlotMgt_PlotterDriver.ixx>
26#include <PlotMgt_Plotter.hxx>
27#include <PlotMgt_PlotterParameter.hxx>
28#include <PlotMgt_PlotterTools.hxx>
29#include <Aspect_Units.hxx>
30#include <Aspect_FontMapEntry.hxx>
31#include <Aspect_MarkMapEntry.hxx>
32#include <Aspect_DriverError.hxx>
33#include <TColStd_Array1OfBoolean.hxx>
34#include <AlienImage.hxx>
35#include <OSD_Environment.hxx>
36
37#define xTRACE 1
38//#define DEBUG_KEEP
39#define MAXPOINT 1024
40#define PPI 72./(0.0254005 METER)
41#define ERROR_NO_PLOTTER "PlotMgt_PlotterDriver::Plotter() --> No plotter defined."
42
43#ifdef WNT
44# pragma warning (disable : 4244 4305)
45# ifdef DrawText
46# undef DrawText
47# endif
48#endif
49
50//===============================================================================
51static OSD_Environment& _DIRPLOTDEF() {
52 static OSD_Environment DIRPLOTDEF("DIRPLOTDEF");
53 return DIRPLOTDEF;
54}
55#define DIRPLOTDEF _DIRPLOTDEF()
56
57//===============================================================================
58#define SET_SPOOL_NAME(aFileName) { \
59 TCollection_AsciiString FileName = DIRPLOTDEF.Value(); \
60 myFileName = aFileName; \
61 if (!FileName.IsEmpty()) { \
62 myDrawingName = aFileName; \
63 Standard_Character aChar = FileName.Value(FileName.Length()); \
64 if ( (aChar != '\\') && (aChar != '/') ) FileName += "/"; \
65 FileName += myFileName; \
66 myFileName = FileName; \
67 } else { \
68 myFileName = "./"; \
69 myFileName += aFileName; \
70 } \
71 }
72//===============================================================================
73#define INIT_GRAPHIC_ATTRIB() \
74 myLineColorIndex = 0; \
75 myLineTypeIndex = 0; \
76 myLineWidthIndex = 0; \
77 myPolyColorIndex = 0; \
78 myPolyTileIndex = 0; \
79 myPolyEdgeFlag = Standard_False; \
80 myMarkerColorIndex = 0; \
81 myMarkerWidthIndex = 0; \
82 myMarkerFillFlag = Standard_False; \
83 myTextColorIndex = 0; \
84 myTextFontIndex = 0; \
85 myTextSlant = 0.0F; \
86 myTextHScale = 1.0; \
87 myTextWScale = 1.0; \
88 myCapsHeight = Standard_False; \
89 myTextIsUnderlined = Standard_False; \
90 myColorIndex = -1; \
91 myTypeIndex = -1; \
92 myWidthIndex = -1; \
93 myFontIndex = -1; \
94 myPaperMargin = 8.;
95
96//===============================================================================
97PlotMgt_PlotterDriver::PlotMgt_PlotterDriver (const Handle(PlotMgt_Plotter)& aPlotter,
98 const Standard_CString aFileName,
99 const Standard_Boolean fCreateFile)
100 : myPixelSize (0.325 METER / 1152),
101 myPrimitiveType (Aspect_TOP_UNKNOWN),
102 myPrimitiveLength (0),
103 myPrimitiveX (1, MAXPOINT),
104 myPrimitiveY (1, MAXPOINT),
105 myPlotterIsDefined (Standard_True)
106{
107#ifdef BUC60766
108 myFileName = aFileName;
109 myDrawingName = aFileName;
110 if( myFileName.Search("/") <= 0 && myFileName.Search("\\") <= 0 )
111#endif
112 SET_SPOOL_NAME (aFileName);
113 INIT_GRAPHIC_ATTRIB ();
114 if (fCreateFile) {
115 myFStream = new ofstream;
116 myFStream->open(myFileName.ToCString(),ios::out);
117#ifdef BUC60766
118 if( !myFStream->rdbuf()->is_open() ) {
119 cout << "*PlotMgt_PlotterDriver Failed on opening the file '" << myFileName << "'" <<endl;
120 }
121#endif
122 } else {
123 myFStream = NULL;
124 }
125#if TRACE > 0
126 cout << "PlotMgt_PlotterDriver::PlotMgt_PlotterDriver('"
127 << aPlotter->Name() << "','" << aFileName << "') : myFileName '" << myFileName << "'" << endl;
128#endif
129 myPlotter = aPlotter;
130}
131
132//===============================================================================
133PlotMgt_PlotterDriver::PlotMgt_PlotterDriver (const Standard_CString aFileName,
134 const Standard_Boolean fCreateFile)
135 : myPixelSize (0.325 METER / 1152),
136 myPrimitiveType (Aspect_TOP_UNKNOWN),
137 myPrimitiveLength (0),
138 myPrimitiveX (1, MAXPOINT),
139 myPrimitiveY (1, MAXPOINT),
140 myPlotterIsDefined (Standard_False)
141{
142#ifdef BUC60766
143 myFileName = aFileName;
144 myDrawingName = aFileName;
145 if( myFileName.Search("/") <= 0 && myFileName.Search("\\") <= 0 )
146#endif
147 SET_SPOOL_NAME (aFileName);
148 INIT_GRAPHIC_ATTRIB ();
149 if (fCreateFile) {
150 myFStream = new ofstream;
151 myFStream->open(myFileName.ToCString(),ios::out);
152#ifdef BUC60766
153 if( !myFStream->rdbuf()->is_open() ) {
154 cout << "*PlotMgt_PlotterDriver Failed on opening the file '" << myFileName << "'" <<endl;
155 }
156#endif
157 } else {
158 myFStream = NULL;
159 }
160#if TRACE > 0
161 cout << "PlotMgt_PlotterDriver::PlotMgt_PlotterDriver('" << aFileName
162 << "') : myFileName '" << myFileName << "'" << endl;
163#endif
164 myPlotter.Nullify ();
165}
166
167//===============================================================================
168void PlotMgt_PlotterDriver::Close ()
169{
170 if (myFStream)
171 myFStream->close();
172#ifdef BUC60766
173 myFStream = NULL;
174#endif
175#if TRACE > 0
176 cout << "Aspect_PlotterDriver::Close()" << endl << flush;
177#endif
178}
179
180//===============================================================================
181void PlotMgt_PlotterDriver::SetPixelSize (const Standard_Real aPixelSize)
182{
183 myPixelSize = aPixelSize;
184}
185
186//===============================================================================
187void PlotMgt_PlotterDriver::SetPlotter (const Handle(PlotMgt_Plotter)& aPlotter)
188{
189 if (myPlotterIsDefined) {
190 if (myPlotter->Name() != aPlotter->Name()) {
191 Aspect_DriverError_Raise_if(Standard_True, "PlotMgt_PlotterDriver::SetPlotter -> Plotter already defined.");
192 }
193 }
194 myPlotterIsDefined = Standard_True;
195 myPlotter = aPlotter;
196}
197
198//===============================================================================
199Aspect_FStream PlotMgt_PlotterDriver::Cout () const
200{
201 return myFStream;
202}
203
204//===============================================================================
205TCollection_AsciiString PlotMgt_PlotterDriver::PlotFileName () const
206{
207 return myFileName;
208}
209
210//===============================================================================
211TCollection_AsciiString PlotMgt_PlotterDriver::DrawingName () const
212{
213 return myDrawingName;
214}
215//===============================================================================
216TCollection_AsciiString PlotMgt_PlotterDriver::SpoolDirectory () const
217{
218 TCollection_AsciiString aRes = DIRPLOTDEF.Value();
219 if (!aRes.IsEmpty()) {
220 Standard_Character aChar = aRes.Value(aRes.Length());
221 if ( (aChar != '\\') && (aChar != '/') )
222 aRes += "/";
223 } else {
224 aRes = "./";
225 }
226 return aRes;
227}
228
229//===============================================================================
230Handle(PlotMgt_Plotter) PlotMgt_PlotterDriver::Plotter () const
231{
232 Aspect_DriverError_Raise_if(!myPlotterIsDefined, ERROR_NO_PLOTTER);
233 return myPlotter;
234}
235
236//===============================================================================
237Standard_Boolean PlotMgt_PlotterDriver::Spool (const Aspect_PlotMode aPlotMode,
238 const Standard_CString /*aReserved1*/,
239 const Standard_Boolean /*aReserved2*/)
240{
241 Standard_Boolean Done = Standard_True;
242 Close();
243 TCollection_AsciiString beforeCommand = Plotter() -> BeforePrintCommand ();
244 TCollection_AsciiString afterCommand = Plotter() -> AfterPrintCommand ();
245 TCollection_AsciiString printCommand = Plotter() -> PrintCommand ();
246
247 if (!afterCommand.IsEmpty() ||
248 (aPlotMode != Aspect_PM_FILEONLY && !printCommand.IsEmpty())) {
249 TCollection_AsciiString theCmdFileName;
250 OSD_Path aCmdPath (myFileName);
251#ifdef WNT
252 aCmdPath.SetExtension (".cmd");
253#else
254 aCmdPath.SetExtension (".csh");
255#endif // WNT
256 aCmdPath.SystemName (theCmdFileName);
257 Aspect_FStream cmdFStream = new ofstream;
258 cmdFStream -> open (theCmdFileName.ToCString(), ios::out);
259#ifdef WNT
260 *cmdFStream << "set DESSNOM=" << myFileName << endl;
261 *cmdFStream << "set Plot_FileName=" << myFileName << endl;
262 *cmdFStream << "set Plot_PlotterName=" << myPlotter->Name() << endl;
263#else
264 *cmdFStream << "#!/bin/csh" << endl;
265 *cmdFStream << "setenv DESSNOM " << myFileName << endl;
266 *cmdFStream << "setenv Plot_FileName " << myFileName << endl;
267 *cmdFStream << "setenv Plot_PlotterName " << myPlotter->Name() << endl;
268#endif // WNT
269
270 Standard_Integer theNumber = myPlotter->NumberOfParameters();
271 Standard_Integer i;
272 TCollection_AsciiString theName;
273// Standard_Integer theType;
274 TCollection_AsciiString theValue;
275// Standard_Boolean theStatusOfGet;
276 *cmdFStream << endl << flush;
277 for (i = 1; i <= theNumber; i++) {
278 Handle(PlotMgt_PlotterParameter) aParameter = Plotter() -> Parameter (i);
279 aParameter -> PutCommandInfo (cmdFStream);
280 }
281 *cmdFStream << endl << flush;
282
283 if (!afterCommand.IsEmpty())
284 *cmdFStream << endl << afterCommand << endl;
285 if (aPlotMode != Aspect_PM_FILEONLY) {
286 if (!printCommand.IsEmpty())
287 *cmdFStream << endl << printCommand << endl;
288 }
289#ifndef WNT
290 *cmdFStream << "rm " << theCmdFileName.ToCString() << endl;
291#else
292 *cmdFStream << "del " << theCmdFileName.ToCString() << endl;
293#endif // WNT
294 *cmdFStream << "exit" << endl << flush;
295 cmdFStream -> close();
296
297 TCollection_AsciiString theCmd;
298#ifdef WNT
299 Standard_Integer theStatus = 0;
300#else
301 theCmd = "chmod 755 ";
302 theCmd += theCmdFileName;
303 Standard_Integer theStatus = system (theCmd.ToCString());
304#endif // WNT
305 if (theStatus == 0) {
306 theCmd = theCmdFileName;
307// theStatus = system (theCmd.ToCString());
308 if (theStatus != 0)
309 Done = Standard_False;
310 } else
311 Done = Standard_False;
312 }
313 return Done;
314}
315
316//===============================================================================
317void PlotMgt_PlotterDriver::CreateDriverColorMap ()
318{
319}
320
321//===============================================================================
322void PlotMgt_PlotterDriver::CreateDriverTypeMap ()
323{
324}
325
326//===============================================================================
327void PlotMgt_PlotterDriver::CreateDriverWidthMap ()
328{
329}
330
331//===============================================================================
332void PlotMgt_PlotterDriver::CreateDriverMarkMap ()
333{
334}
335
336//===============================================================================
337void PlotMgt_PlotterDriver::InitializeColorMap (const Handle(Aspect_ColorMap)& /*aColorMap*/)
338{
339}
340
341//===============================================================================
342void PlotMgt_PlotterDriver::InitializeTypeMap (const Handle(Aspect_TypeMap)& /*aTypeMap*/)
343{
344}
345
346//===============================================================================
347void PlotMgt_PlotterDriver::InitializeWidthMap (const Handle(Aspect_WidthMap)& /*aWidthMap*/)
348{
349}
350
351//===============================================================================
352void PlotMgt_PlotterDriver::InitializeFontMap (const Handle(Aspect_FontMap)& aFontMap)
353{
354 if (!UseMFT())
355 return;
356 Aspect_FontMapEntry entry;
357 Standard_Integer index,iindex,minindex=IntegerLast(),maxindex= -minindex;
358
359 for( index=1; index<=aFontMap->Size(); index++ ) {
360 entry = aFontMap->Entry(index);
361 maxindex = Max(maxindex, entry.Index());
362 minindex = Min(minindex, entry.Index());
363 }
364 Handle(MFT_FontManager) dummy;
365 dummy.Nullify ();
366 myMFTFonts = new PlotMgt_HListOfMFTFonts(minindex, maxindex, dummy);
367 myMFTSizes = new TShort_HArray1OfShortReal(minindex, maxindex, 0.);
368
369 TCollection_AsciiString aname;
370 Aspect_FontStyle style;
371 Standard_Boolean theCapsHeight;
372 Quantity_PlaneAngle theFontSlant;
373 Quantity_Length theFontSize;
374 Standard_Real fsize;
375
376 for (index=1; index <= aFontMap->Size(); index++) {
377 entry = aFontMap->Entry(index);
378 iindex = entry.Index();
379 style = entry.Type();
380 theFontSize = TOMILLIMETER(style.Size());
381 theFontSlant = style.Slant();
382 aname = style.AliasName();
383 theCapsHeight = style.CapsHeight();
384 fsize = theFontSize;
385 if (fsize > 0.0001) fsize = Convert(fsize);
386 else fsize = 1.;
387 Standard_Boolean found = MFT_FontManager::IsKnown(aname.ToCString());
388 if (found) {
389 found = Standard_False;
390 Handle(MFT_FontManager) theFontManager;
391 Aspect_FontStyle fstyle = MFT_FontManager::Font(aname.ToCString());
392 for (Standard_Integer i = minindex; i <= maxindex; i++) {
393 theFontManager = myMFTFonts->Value(i);
394 if (!theFontManager.IsNull()) {
395 if (fstyle == theFontManager->Font()) {
396 found = Standard_True;
397 break;
398 }
399 }
400 }
401 if (!found) {
402 theFontManager = new MFT_FontManager(aname.ToCString());
403 }
404 theFontManager->SetFontAttribs (theFontSize,theFontSize,
405 theFontSlant,0.,theCapsHeight);
406 myMFTFonts->SetValue (iindex, theFontManager);
407 if (theCapsHeight)
408 myMFTSizes->SetValue (iindex, Standard_ShortReal(-theFontSize));
409 else
410 myMFTSizes->SetValue (iindex, Standard_ShortReal(theFontSize));
411 } else {
412 Handle(MFT_FontManager) theFontManager;
413 if (MFT_FontManager::IsKnown("Defaultfont")) {
414 theFontManager = new MFT_FontManager ("Defaultfont");
415 } else {
416 for (int j=1; j <= aFontMap->Size(); j++) {
417 if (MFT_FontManager::IsKnown(aFontMap->Entry(j).Type().AliasName())) {
418 cout << "--->>> PlotterDriver: First found font is : '"
419 << aFontMap->Entry(j).Type().AliasName() << "'" << endl << flush;
420 theFontManager = new MFT_FontManager (aFontMap->Entry(j).Type().AliasName());
421 break;
422 }
423 }
424 }
425 if (!theFontManager.IsNull()) {
426 myMFTFonts->SetValue (iindex, theFontManager);
427 if (theCapsHeight)
428 myMFTSizes->SetValue (iindex, Standard_ShortReal(-theFontSize));
429 else
430 myMFTSizes->SetValue (iindex, Standard_ShortReal(theFontSize));
431 }
432 }
433 }
434}
435
436//===============================================================================
437void PlotMgt_PlotterDriver::InitializeMarkMap (const Handle(Aspect_MarkMap)& /*aMarkMap*/)
438{
439}
440
441//===============================================================================
442void PlotMgt_PlotterDriver::SetLineAttrib (const Standard_Integer ColorIndex,
443 const Standard_Integer TypeIndex,
444 const Standard_Integer WidthIndex)
445{
446 myLineColorIndex = ColorIndex;
447 myLineTypeIndex = TypeIndex;
448 myLineWidthIndex = WidthIndex;
449}
450
451//===============================================================================
452void PlotMgt_PlotterDriver::SetTextAttrib (const Standard_Integer ColorIndex,
453 const Standard_Integer FontIndex)
454{
455 SetTextAttrib (ColorIndex, FontIndex, 0., 1., 1.);
456}
457
458//===============================================================================
459void PlotMgt_PlotterDriver::SetTextAttrib (const Standard_Integer ColorIndex,
460 const Standard_Integer FontIndex,
461 const Quantity_PlaneAngle aSlant,
462 const Quantity_Factor aHScale,
463 const Quantity_Factor aWScale,
464 const Standard_Boolean isUnderlined)
465{
466 myTextColorIndex = ColorIndex;
467 myTextFontIndex = FontIndex;
468 myTextIsUnderlined = isUnderlined;
469 if (FontIndex != myFontIndex || aSlant != myTextSlant ||
470 aHScale != myTextHScale || aWScale != myTextWScale) {
471 myFontIndex = FontIndex;
472 myTextSlant = aSlant;
473 myTextHScale = aHScale;
474 myTextWScale = (aWScale > 0.) ? aWScale : aHScale;
475 if (UseMFT()) {
476 Handle(MFT_FontManager) theFontManager
477 = myMFTFonts->Value(myFontIndex);
478 if (!theFontManager.IsNull()) {
479 Quantity_Length theTextSize = myMFTSizes->Value(myFontIndex);
480 Quantity_Length theTextWidth = myTextWScale * Abs(theTextSize);
481 Quantity_Length theTextHeight = myTextHScale * Abs(theTextSize);
482 Quantity_PlaneAngle theTextSlant = myTextSlant;
483 Standard_Boolean theCapsHeight =
484 (theTextSize > 0.) ? Standard_False : Standard_True;
485 theFontManager->SetFontAttribs (theTextWidth, theTextHeight,
486 theTextSlant, 0., theCapsHeight);
487 }
488 }
489 }
490}
491
492//===============================================================================
493void PlotMgt_PlotterDriver::SetPolyAttrib (const Standard_Integer ColorIndex,
494 const Standard_Integer TileIndex,
495 const Standard_Boolean DrawEdge)
496{
497 myPolyColorIndex = ColorIndex;
498 myPolyTileIndex = TileIndex;
499 myPolyEdgeFlag = DrawEdge;
500}
501
502//===============================================================================
503void PlotMgt_PlotterDriver::SetMarkerAttrib (const Standard_Integer ColorIndex,
504 const Standard_Integer WidthIndex,
505 const Standard_Boolean FillMarker)
506{
507 myMarkerColorIndex = ColorIndex;
508 myMarkerWidthIndex = WidthIndex;
509 myMarkerFillFlag = FillMarker;
510}
511
512//===============================================================================
513void PlotMgt_PlotterDriver::PlotLineAttrib (const Standard_Integer /*ColorIndex*/,
514 const Standard_Integer /*TypeIndex*/,
515 const Standard_Integer /*WidthIndex*/)
516{
517}
518
519//===============================================================================
520void PlotMgt_PlotterDriver::PlotPolyAttrib (const Standard_Integer /*ColorIndex*/,
521 const Standard_Integer /*TileIndex*/,
522 const Standard_Boolean /*DrawEdge*/)
523{
524}
525
526//===============================================================================
527//===============================================================================
528//===============================================================================
529//===============================================================================
530//===============================================================================
531//===============================================================================
532//===============================================================================
533//===============================================================================
534
535//===============================================================================
536void PlotMgt_PlotterDriver::DrawPoint (const Standard_ShortReal X,
537 const Standard_ShortReal Y)
538{
539 switch (myPrimitiveType) {
540 case Aspect_TOP_POLYLINE:
541 case Aspect_TOP_POLYGON:
542 if (myPrimitiveLength < MAXPOINT) {
543 myPrimitiveLength++;
544 myPrimitiveX(myPrimitiveLength) = X;
545 myPrimitiveY(myPrimitiveLength) = Y;
546 }
547 break;
548 default:
549 PlotLineAttrib (myLineColorIndex, myLineTypeIndex, myLineWidthIndex);
550 PlotPoint (MapX(X), MapY(Y));
551 break;
552 }
553}
554
555//===============================================================================
556void PlotMgt_PlotterDriver::DrawSegment (const Standard_ShortReal X1,
557 const Standard_ShortReal Y1,
558 const Standard_ShortReal X2,
559 const Standard_ShortReal Y2)
560{
561 PlotLineAttrib (myLineColorIndex, myLineTypeIndex, myLineWidthIndex);
562 PlotSegment (MapX(X1), MapY(Y1), MapX(X2), MapY(Y2));
563}
564
565//===============================================================================
566void PlotMgt_PlotterDriver::DrawRectangle (const Standard_ShortReal aX,
567 const Standard_ShortReal aY,
568 const Standard_ShortReal aDX,
569 const Standard_ShortReal aDY)
570{
571 Standard_Boolean Done = Standard_False;
572 if (myPlotter->RectangleDriven()) {
573 PlotLineAttrib (myLineColorIndex, myLineTypeIndex, myLineWidthIndex);
574 Done = PlotRectangle (MapX(aX), MapY(aY), MapX(aDX), MapY(aDY), 0.0);
575 }
576
577 if (!Done) {
578 BeginPolyline (5);
579 DrawPoint (aX, aY);
580 DrawPoint (aX, aY + aDY);
581 DrawPoint (aX + aDX, aY + aDY);
582 DrawPoint (aX + aDX, aY);
583 DrawPoint (aX, aY);
584 ClosePrimitive ();
585 }
586}
587
588//===============================================================================
589void PlotMgt_PlotterDriver::DrawPolyline (const TShort_Array1OfShortReal& aListX,
590 const TShort_Array1OfShortReal& aListY)
591{
592 static float xarray[MAXPOINT], yarray[MAXPOINT];
593 Standard_Integer u = aListX.Upper(), l = aListX.Lower(), n = aListX.Length();
594 if (n != aListY.Length ())
595 Aspect_DriverError::Raise ("PlotMgt_PlotterDriver::DrawPolyline() -> 2 different lengths.");
596 if (n > MAXPOINT)
597 Aspect_DriverError::Raise ("PlotMgt_PlotterDriver::DrawPolyline() -> Array is too long.");
598 if (n > 1) {
599 for (Standard_Integer i=l; i<=u; i++) {
600 xarray[i-l] = MapX(aListX(i));
601 yarray[i-l] = MapY(aListY(i));
602 }
603 PlotLineAttrib (myLineColorIndex, myLineTypeIndex, myLineWidthIndex);
604 PlotPolyline (xarray, yarray, &n, 1);
605 }
606}
607
608//===============================================================================
609void PlotMgt_PlotterDriver::DrawPolygon (const TShort_Array1OfShortReal& aListX,
610 const TShort_Array1OfShortReal& aListY)
611{
612 static float xarray[MAXPOINT+1], yarray[MAXPOINT+1];
613 Standard_Integer u = aListX.Upper(), l = aListX.Lower(), n = aListX.Length();
614 if (n != aListY.Length ())
615 Aspect_DriverError::Raise ("PlotMgt_PlotterDriver::DrawPolygon() -> 2 different lengths.");
616 if (n > MAXPOINT)
617 Aspect_DriverError::Raise ("PlotMgt_PlotterDriver::DrawPolygon() -> Array is too long.");
618 if (n > 1) {
619 for (Standard_Integer i=l; i<=u; i++) {
620 xarray[i-l] = MapX(aListX(i));
621 yarray[i-l] = MapY(aListY(i));
622 }
623 if ((xarray[l] != xarray[u]) || (yarray[l] != yarray[u])) {
624 xarray[n] = xarray[0]; yarray[n] = yarray[0]; n++;
625 }
626 PlotLineAttrib (myLineColorIndex, myLineTypeIndex, myLineWidthIndex);
627 PlotPolyAttrib (myPolyColorIndex, myPolyTileIndex, myPolyEdgeFlag);
628 PlotPolygon (xarray, yarray, &n, 1);
629 }
630}
631
632//===============================================================================
633Standard_Boolean PlotMgt_PlotterDriver::DrawArc (const Standard_ShortReal X,
634 const Standard_ShortReal Y,
635 const Standard_ShortReal anXradius,
636 const Standard_ShortReal anYradius,
637 const Standard_ShortReal aStartAngle,
638 const Standard_ShortReal anOpenAngle)
639{
640 Standard_Boolean Done = Standard_False;
641 float san, oan;
c6541a0c
D
642 if (anOpenAngle == 0.F || anOpenAngle > 2*M_PI) {
643 san = 0.F; oan = 2.*M_PI;
7fd59977 644 } else if (anOpenAngle < 0.F) {
c6541a0c 645 san = 2.*M_PI + aStartAngle + anOpenAngle;
7fd59977 646 oan = -anOpenAngle;
647 } else {
648 san = aStartAngle; oan = anOpenAngle;
649 }
650
651 if ( ((anXradius == anYradius) && myPlotter->CircleDriven ()) ||
652 ((anXradius != anYradius) && myPlotter->EllipseDriven()) ) {
653 PlotLineAttrib (myLineColorIndex, myLineTypeIndex, myLineWidthIndex);
654 Done = PlotArc (MapX(X), MapX(Y), MapX(anXradius), MapY(anYradius), san, oan);
655 }
656
657 if (!Done) {
658 Standard_ShortReal precis = FROMCENTIMETER(myPlotter->Resolution());
659 Standard_ShortReal value;
660 Standard_ShortReal aRadius = Max (anXradius, anYradius);
661 if (aRadius > precis)
662 value = Max (0.0044, Min (0.7854, 2. * ACos(1.-precis/aRadius)));
663 else
c6541a0c 664 value = M_PI/4.;
7fd59977 665 Standard_Integer nbpoints = Min(MAXPOINT,
666 Standard_Integer(Abs(oan)/value)+2);
667
668 nbpoints = 10;
669 float pX, pY, alpha;
670 BeginPolyline (nbpoints);
671 for (int i=0; i <= nbpoints; i++) {
672 alpha = san + (oan*i)/nbpoints;
673 pX = float(X + anXradius*Cos(alpha));
674 pY = float(Y + anYradius*Sin(alpha));
675 DrawPoint (pX, pY);
676 }
677 ClosePrimitive ();
678 Done = Standard_True;
679 }
680 return Done;
681}
682
683//===============================================================================
684Standard_Boolean PlotMgt_PlotterDriver::DrawPolyArc (const Standard_ShortReal X,
685 const Standard_ShortReal Y,
686 const Standard_ShortReal anXradius,
687 const Standard_ShortReal anYradius,
688 const Standard_ShortReal aStartAngle,
689 const Standard_ShortReal anOpenAngle)
690{
691 Standard_Boolean Done = Standard_False;
692 float san, oan;
c6541a0c
D
693 if (anOpenAngle == 0.F || anOpenAngle > 2*M_PI) {
694 san = 0.F; oan = 2.*M_PI;
7fd59977 695 } else if (anOpenAngle < 0.F) {
c6541a0c 696 san = 2.*M_PI + aStartAngle + anOpenAngle;
7fd59977 697 oan = -anOpenAngle;
698 } else {
699 san = aStartAngle; oan = anOpenAngle;
700 }
701
702 if ( ((anXradius == anYradius) && myPlotter->CircleDriven ()) ||
703 ((anXradius != anYradius) && myPlotter->EllipseDriven()) ) {
704 PlotLineAttrib (myLineColorIndex, myLineTypeIndex, myLineWidthIndex);
705 PlotPolyAttrib (myPolyColorIndex, myPolyTileIndex, myPolyEdgeFlag);
706 Done = PlotPolyArc (MapX(X), MapY(Y), MapX(anXradius), MapY(anYradius), san, oan);
707 }
708
709 if (!Done) {
710 Standard_ShortReal precis = FROMCENTIMETER(myPlotter->Resolution());
711 Standard_ShortReal value;
712 Standard_ShortReal aRadius = Max (anXradius, anYradius);
713 if (aRadius > precis)
714 value = Max (0.0044, Min (0.7854, 2. * ACos(1.-precis/aRadius)));
715 else
c6541a0c 716 value = M_PI/4.;
7fd59977 717 Standard_Integer nbpoints = Min(MAXPOINT,
718 Standard_Integer(Abs(oan)/value)+2);
719
720 nbpoints = 10;
721 float pX, pY, alpha;
722 BeginPolygon (nbpoints+1);
723 DrawPoint (X, Y);
724 for (int i=0; i <= nbpoints; i++) {
725 alpha = san + (oan*i)/nbpoints;
726 pX = float(X + anXradius*Cos(alpha));
727 pY = float(Y + anYradius*Sin(alpha));
728 DrawPoint (pX, pY);
729 }
730 ClosePrimitive ();
731 Done = Standard_True;
732 }
733 return Done;
734}
735
736//===============================================================================
737void PlotMgt_PlotterDriver::DrawMarker (const Standard_Integer aMarker,
738 const Standard_ShortReal Xpos,
739 const Standard_ShortReal Ypos,
740 const Standard_ShortReal Width,
741 const Standard_ShortReal Height,
742 const Standard_ShortReal Angle)
743{
744 Standard_Boolean Done = Standard_False;
745 if (myPlotter->MarkerDriven())
746 Done = PlotMarker (aMarker, MapX(Xpos), MapY(Ypos), Width, Height, Angle);
747
748 if (!Done) {
749 if (aMarker >= 0 && Width > 0. && Height > 0.) {
750 // Declare the arrays to put in the marker points.
751
752 const TShort_Array1OfShortReal& amx =
753 MarkMap ()->Entry(aMarker+1).Style().XValues();
754 const TShort_Array1OfShortReal& amy =
755 MarkMap ()->Entry(aMarker+1).Style().YValues();
756 const TColStd_Array1OfBoolean& ams =
757 MarkMap ()->Entry(aMarker+1).Style().SValues();
758 Standard_Integer i, sl, su;
c6541a0c
D
759 Standard_ShortReal Ca = (float)Cos((3 * M_PI) / 2 + Angle),
760 Sa = (float)Sin((3 * M_PI) / 2 + Angle);
7fd59977 761 Standard_ShortReal dx, dy, Cx, Cy;
762
763 // Remember the old attributes
764 Standard_Integer lci, lti, lwi, pci, pti;
765 Standard_Boolean pef;
766 LineAttrib (lci, lti, lwi);
767 PolyAttrib (pci, pti, pef);
768 // Set new line params
769 SetLineAttrib (myMarkerColorIndex, 0, myMarkerWidthIndex);
770 SetPolyAttrib (myPolyColorIndex, 0, Standard_True);
771
772 // Actual drawing
773 sl = amx.Lower(); su = amx.Upper();
774 for (i=sl; i <= su; i++) {
775 Cx = amx(i)*Width/2.F;
776 Cy = amy(i)*Height/2.F;
777 if (!ams(i)) {
778 dx = Xpos+((Ca*Cx)+(Sa*Cy));
779 dy = Ypos+((Sa*Cx)-(Ca*Cy));
780 ClosePrimitive ();
781 if (myMarkerFillFlag) BeginPolygon (su);
782 else BeginPolyline (su);
783 DrawPoint (dx, dy);
784 } else {
785 dx = Xpos+((Ca*Cx)+(Sa*Cy));
786 dy = Ypos+((Sa*Cx)-(Ca*Cy));
787 DrawPoint (dx, dy);
788 }
789 }
790 ClosePrimitive ();
791 // Restore old attributes
792 SetLineAttrib (lci, lti, lwi);
793 SetPolyAttrib (pci, pti, pef);
794 } else {
795 DrawPoint (Xpos, Ypos);
796 }
797 }
798}
799
800//===============================================================================
801//===============================================================================
802//===============================================================================
803//===============================================================================
804//===============================================================================
805//===============================================================================
806//===============================================================================
807#define TRANSFORM(X,Y,rX,rY) \
808{ \
809 Standard_Real x = X,y = Y; \
810 X = (float)(rX + x*Ca - y*Sa); \
811 Y = (float)(rY + x*Sa + y*Ca); \
812}
813
814#define DRAW_TEXT_FRAME(aText) \
815 Standard_Real underlinePosition = \
816 (myTextIsUnderlined) ? theFontManager->UnderlinePosition() : 0.; \
817 Quantity_Length theWidth = 0.,theAscent = 0., \
818 theLbearing = 0.,theDescent = 0.; \
819 theFontManager->TextSize (aText, theWidth, theAscent, \
820 theLbearing, theDescent); \
821 theDescent = Max(theDescent, underlinePosition); \
822 TShort_Array1OfShortReal Xp (1,4), Yp (1,4); \
823 Standard_ShortReal rwidth = theWidth; \
824 Standard_ShortReal rheight = theAscent + theDescent; \
825 Standard_ShortReal rxmin = theLbearing; \
826 Standard_ShortReal rymin = -theDescent; \
827 Standard_ShortReal marge = rheight * aMargin; \
828 rwidth += 2.F*marge; rheight += 2.F*marge; \
829 rxmin -= marge; rymin -= marge; \
830 Standard_ShortReal X1, Y1, X2, Y2, X3, Y3, X4, Y4; \
831 X1 = rxmin; Y1 = rymin; \
832 X2 = rxmin + rwidth; Y2 = rymin; \
833 X3 = rxmin + rwidth; Y3 = rymin + rheight; \
834 X4 = rxmin; Y4 = rymin + rheight; \
835 TRANSFORM (X1, Y1, Xpos, Ypos); \
836 TRANSFORM (X2, Y2, Xpos, Ypos); \
837 TRANSFORM (X3, Y3, Xpos, Ypos); \
838 TRANSFORM (X4, Y4, Xpos, Ypos); \
839 Xp.SetValue (1, X1); Yp.SetValue (1, Y1); \
840 Xp.SetValue (2, X2); Yp.SetValue (2, Y2); \
841 Xp.SetValue (3, X3); Yp.SetValue (3, Y3); \
842 Xp.SetValue (4, X4); Yp.SetValue (4, Y4); \
843 DrawPolygon (Xp, Yp);
844
845//===============================================================================
846void PlotMgt_PlotterDriver::DrawText (const TCollection_ExtendedString& aText,
847 const Standard_ShortReal Xpos,
848 const Standard_ShortReal Ypos,
849 const Standard_ShortReal anAngle,
850 const Aspect_TypeOfText aType)
851{
852 if (aText.Length() > 0) {
853 if (aText.IsAscii()) {
854 TCollection_AsciiString atext(aText,'?');
855 DrawText (atext.ToCString(), Xpos, Ypos, anAngle, aType);
856 } else {
857 Standard_Boolean Done = Standard_False;
858#ifdef BUC60766
859 if (myPlotter->TextDriven())
860#else
861 if (myPlotter->TextDriven() == (unsigned int ) -1)
862#endif
863 Done = PlotText (aText, Xpos, Ypos, anAngle, aType);
864
865 if (!Done && UseMFT()) {
866 Handle(MFT_FontManager) theFontManager = myMFTFonts->Value(myFontIndex);
867 if (!theFontManager.IsNull()) {
868 if (!aText.IsAscii() && !theFontManager->IsComposite()) {
869 cout << "***ERROR***PlotMgt_PlotterDriver::DrawExtText.UNABLE to draw"
870 << " an extended text with an ANSI font" << endl << flush;
871 return;
872 }
873 Standard_Real underlinePosition =
874 (myTextIsUnderlined) ? theFontManager->UnderlinePosition() : 0.;
875 myTextManager->SetTextAttribs (myTextColorIndex, aType, underlinePosition);
876 theFontManager->DrawText (myTextManager, aText.ToExtString(),
877 Quantity_Length(Xpos), Quantity_Length(Ypos),
878 Quantity_PlaneAngle(anAngle));
879 }
880 } // MFT
881 } // Ascii
882 } // Length > 0
883}
884
885//===============================================================================
886void PlotMgt_PlotterDriver::DrawText (const Standard_CString aText,
887 const Standard_ShortReal Xpos,
888 const Standard_ShortReal Ypos,
889 const Standard_ShortReal anAngle,
890 const Aspect_TypeOfText aType)
891{
892 if (strlen(aText) > 0) {
893 Standard_Boolean Done = Standard_False;
894#ifdef BUC60766
895 if (myPlotter->TextDriven())
896#else
897 if (myPlotter->TextDriven() == (unsigned int ) -1)
898#endif
899 Done = PlotText (aText, Xpos, Ypos, anAngle, aType);
900
901 if (!Done && UseMFT()) {
902 Handle(MFT_FontManager) theFontManager = myMFTFonts->Value(myFontIndex);
903 if (!theFontManager.IsNull()) {
904 Standard_Real underlinePosition =
905 (myTextIsUnderlined) ? theFontManager->UnderlinePosition() : 0.;
906 myTextManager->SetTextAttribs (myTextColorIndex, aType, underlinePosition);
907 theFontManager->DrawText (myTextManager, aText,
908 Quantity_Length(Xpos), Quantity_Length(Ypos),
909 Quantity_PlaneAngle(anAngle));
910 }
911 } // MFT
912 } // Length > 0
913}
914
915//===============================================================================
916void PlotMgt_PlotterDriver::DrawPolyText (const TCollection_ExtendedString& aText,
917 const Standard_ShortReal Xpos,
918 const Standard_ShortReal Ypos,
919 const Quantity_Ratio aMargin,
920 const Standard_ShortReal anAngle,
921 const Aspect_TypeOfText aType)
922{
923 if (aText.Length() > 0) {
924 if (aText.IsAscii()) {
925 TCollection_AsciiString atext(aText,'?');
926 DrawPolyText (atext.ToCString(), Xpos, Ypos, aMargin, anAngle, aType);
927 } else {
928 Standard_Boolean Done = Standard_False;
929#ifdef BUC60766
930 if (myPlotter->TextDriven())
931#else
932 if (myPlotter->TextDriven() == (unsigned int ) -1)
933#endif
934 {
935 PlotPolyAttrib (myPolyColorIndex, myPolyTileIndex, myPolyEdgeFlag);
936 Done = PlotPolyText(aText, Xpos, Ypos, aMargin, anAngle, aType);
937 }
938
939 if (!Done && UseMFT()) {
940 Standard_ShortReal Ca = Cos(anAngle), Sa = Sin(anAngle);
941// Standard_ShortReal Tsl = Tan(myTextSlant);
942 Handle(MFT_FontManager) theFontManager = myMFTFonts->Value(myFontIndex);
943 if (!theFontManager.IsNull()) {
944 if (!theFontManager->IsComposite()) {
945 cout << "***PlotMgt_PlotterDriver::DrawPolyExtText.UNABLE to draw"
946 << " an extended text with an ANSI font" << endl << flush;
947 return;
948 }
949 DRAW_TEXT_FRAME (aText.ToExtString());
950 myTextManager->SetTextAttribs (myTextColorIndex, aType, underlinePosition);
951 theFontManager->DrawText (myTextManager, aText.ToExtString(),
952 Quantity_Length(Xpos), Quantity_Length(Ypos),
953 Quantity_PlaneAngle(anAngle));
954 }
955 } // MFT
956 } // Ascii
957 } // aText.Length() > 0
958}
959
960//===============================================================================
961void PlotMgt_PlotterDriver::DrawPolyText (const Standard_CString aText,
962 const Standard_ShortReal Xpos,
963 const Standard_ShortReal Ypos,
964 const Quantity_Ratio aMargin,
965 const Standard_ShortReal anAngle,
966 const Aspect_TypeOfText aType)
967{
968 if (strlen(aText) > 0) {
969 Standard_Boolean Done = Standard_False;
970#ifdef BUC60766
971 if (myPlotter->TextDriven())
972#else
973 if (myPlotter->TextDriven() == (unsigned int ) -1)
974#endif
975 {
976 PlotPolyAttrib (myPolyColorIndex, myPolyTileIndex, myPolyEdgeFlag);
977 Done = PlotPolyText(aText, Xpos, Ypos, aMargin, anAngle, aType);
978 }
979
980 if (!Done && UseMFT()) {
981 Standard_ShortReal Ca = Cos(anAngle),
982 Sa = Sin(anAngle);
983 Handle(MFT_FontManager) theFontManager = myMFTFonts->Value(myFontIndex);
984 if (!theFontManager.IsNull()) {
985 DRAW_TEXT_FRAME (aText);
986 myTextManager->SetTextAttribs (myTextColorIndex, aType, underlinePosition);
987 theFontManager->DrawText (myTextManager, aText,
988 Quantity_Length(Xpos), Quantity_Length(Ypos),
989 Quantity_PlaneAngle(anAngle));
990 }
991 } // MFT
992 } // strlen(aText) > 0
993}
994
995//===============================================================================
996//===============================================================================
997//===============================================================================
998//===============================================================================
999//===============================================================================
1000//===============================================================================
1001//===============================================================================
1002//===============================================================================
1003//===============================================================================
1004
1005//===============================================================================
1006Standard_Boolean PlotMgt_PlotterDriver::PlotPoint (const Standard_ShortReal /*X*/,
1007 const Standard_ShortReal /*Y*/)
1008{
1009 return Standard_False;
1010}
1011
1012//===============================================================================
1013Standard_Boolean PlotMgt_PlotterDriver::PlotSegment (const Standard_ShortReal /*X1*/,
1014 const Standard_ShortReal /*Y1*/,
1015 const Standard_ShortReal /*X2*/,
1016 const Standard_ShortReal /*Y2*/)
1017{
1018 return Standard_False;
1019}
1020
1021//===============================================================================
1022Standard_Boolean PlotMgt_PlotterDriver::PlotRectangle (const Standard_ShortReal /*aX*/,
1023 const Standard_ShortReal /*aY*/,
1024 const Standard_ShortReal /*aDX*/,
1025 const Standard_ShortReal /*aDY*/,
1026 const Standard_ShortReal /*aAngle*/)
1027{
1028 return Standard_False;
1029}
1030
1031//===============================================================================
1032Standard_Boolean PlotMgt_PlotterDriver::PlotPolyline (const Standard_Address /*xArray*/,
1033 const Standard_Address /*yArray*/,
1034 const Standard_Address /*nPts*/,
1035 const Standard_Integer /*nParts*/)
1036{
1037 return Standard_False;
1038}
1039
1040//===============================================================================
1041Standard_Boolean PlotMgt_PlotterDriver::PlotPolygon (const Standard_Address /*xArray*/,
1042 const Standard_Address /*yArray*/,
1043 const Standard_Address /*nPts*/,
1044 const Standard_Integer /*nParts*/)
1045{
1046 return Standard_False;
1047}
1048
1049//===============================================================================
1050Standard_Boolean PlotMgt_PlotterDriver::PlotArc (const Standard_ShortReal /*X*/,
1051 const Standard_ShortReal /*Y*/,
1052 const Standard_ShortReal /*anXradius*/,
1053 const Standard_ShortReal /*anYradius*/,
1054 const Standard_ShortReal /*sAngle*/,
1055 const Standard_ShortReal /*oAngle*/)
1056{
1057 return Standard_False;
1058}
1059
1060//===============================================================================
1061Standard_Boolean PlotMgt_PlotterDriver::PlotPolyArc (const Standard_ShortReal /*X*/,
1062 const Standard_ShortReal /*Y*/,
1063 const Standard_ShortReal /*anXradius*/,
1064 const Standard_ShortReal /*anYradius*/,
1065 const Standard_ShortReal /*sAngle*/,
1066 const Standard_ShortReal /*oAngle*/)
1067{
1068 return Standard_False;
1069}
1070
1071//===============================================================================
1072Standard_Boolean PlotMgt_PlotterDriver::PlotMarker (const Standard_Integer /*aMarker*/,
1073 const Standard_ShortReal /*Xpos*/,
1074 const Standard_ShortReal /*Ypos*/,
1075 const Standard_ShortReal /*Width*/,
1076 const Standard_ShortReal /*Height*/,
1077 const Standard_ShortReal /*Angle*/)
1078{
1079 return Standard_False;
1080}
1081
1082//===============================================================================
1083Standard_Boolean PlotMgt_PlotterDriver::PlotText (const TCollection_ExtendedString& /*aText*/,
1084 const Standard_ShortReal /*Xpos*/,
1085 const Standard_ShortReal /*Ypos*/,
1086 const Standard_ShortReal /*anAngle*/,
1087 const Aspect_TypeOfText /*aType*/)
1088{
1089 return Standard_False;
1090}
1091
1092//===============================================================================
1093Standard_Boolean PlotMgt_PlotterDriver::PlotText (const Standard_CString /*aText*/,
1094 const Standard_ShortReal /*Xpos*/,
1095 const Standard_ShortReal /*Ypos*/,
1096 const Standard_ShortReal /*anAngle*/,
1097 const Aspect_TypeOfText /*aType*/)
1098{
1099 return Standard_False;
1100}
1101
1102//===============================================================================
1103Standard_Boolean PlotMgt_PlotterDriver::PlotPolyText (const TCollection_ExtendedString& /*aText*/,
1104 const Standard_ShortReal /*Xpos*/,
1105 const Standard_ShortReal /*Ypos*/,
1106 const Quantity_Ratio /*aMargin*/,
1107 const Standard_ShortReal /*anAngle*/,
1108 const Aspect_TypeOfText /*aType*/)
1109{
1110 return Standard_False;
1111}
1112
1113//===============================================================================
1114Standard_Boolean PlotMgt_PlotterDriver::PlotPolyText (const Standard_CString /*aText*/,
1115 const Standard_ShortReal /*Xpos*/,
1116 const Standard_ShortReal /*Ypos*/,
1117 const Quantity_Ratio /*aMargin*/,
1118 const Standard_ShortReal /*anAngle*/,
1119 const Aspect_TypeOfText /*aType*/)
1120{
1121 return Standard_False;
1122}
1123
1124//===============================================================================
1125//===============================================================================
1126//===============================================================================
1127//===============================================================================
1128//===============================================================================
1129//===============================================================================
1130//===============================================================================
1131//===============================================================================
1132//===============================================================================
1133void PlotMgt_PlotterDriver::BeginPolyline (const Standard_Integer aNumber)
1134{
1135 if (myPrimitiveType != Aspect_TOP_UNKNOWN) ClosePrimitive ();
1136 if (aNumber <= 0) return;
1137 myPrimitiveType = Aspect_TOP_POLYLINE;
1138 myPrimitiveLength = 0;
1139}
1140
1141//===============================================================================
1142void PlotMgt_PlotterDriver::BeginPolygon (const Standard_Integer aNumber)
1143{
1144 if (myPrimitiveType != Aspect_TOP_UNKNOWN) ClosePrimitive();
1145 if (aNumber <= 0) return;
1146 myPrimitiveType = Aspect_TOP_POLYGON;
1147 myPrimitiveLength = 0;
1148}
1149
1150//===============================================================================
1151void PlotMgt_PlotterDriver::BeginSegments ()
1152{
1153 if (myPrimitiveType != Aspect_TOP_UNKNOWN) ClosePrimitive();
1154 myPrimitiveType = Aspect_TOP_SEGMENTS;
1155 myPrimitiveLength = 0;
1156}
1157
1158//===============================================================================
1159void PlotMgt_PlotterDriver::BeginArcs ()
1160{
1161 if (myPrimitiveType != Aspect_TOP_UNKNOWN) ClosePrimitive();
1162 myPrimitiveType = Aspect_TOP_ARCS;
1163 myPrimitiveLength = 0;
1164}
1165
1166//===============================================================================
1167void PlotMgt_PlotterDriver::BeginPolyArcs ()
1168{
1169 if (myPrimitiveType != Aspect_TOP_UNKNOWN) ClosePrimitive();
1170 myPrimitiveType = Aspect_TOP_POLYARCS;
1171 myPrimitiveLength = 0;
1172}
1173
1174//===============================================================================
1175void PlotMgt_PlotterDriver::BeginMarkers ()
1176{
1177 if (myPrimitiveType != Aspect_TOP_UNKNOWN) ClosePrimitive();
1178 myPrimitiveType = Aspect_TOP_MARKERS;
1179 myPrimitiveLength = 0;
1180}
1181
1182//===============================================================================
1183void PlotMgt_PlotterDriver::BeginPoints ()
1184{
1185 if (myPrimitiveType != Aspect_TOP_UNKNOWN) ClosePrimitive();
1186 myPrimitiveType = Aspect_TOP_POINTS;
1187 myPrimitiveLength = 0;
1188}
1189
1190//===============================================================================
1191void PlotMgt_PlotterDriver::ClosePrimitive ()
1192{
1193 switch (myPrimitiveType) {
1194 case Aspect_TOP_POLYLINE:
1195 if (myPrimitiveLength > 0) {
1196 TShort_Array1OfShortReal Xpoint(myPrimitiveX(1),1,myPrimitiveLength);
1197 TShort_Array1OfShortReal Ypoint(myPrimitiveY(1),1,myPrimitiveLength);
1198 myPrimitiveLength = 0;
1199 DrawPolyline (Xpoint,Ypoint);
1200 }
1201 break;
1202 case Aspect_TOP_POLYGON:
1203 if (myPrimitiveLength > 0) {
1204 TShort_Array1OfShortReal Xpoint(myPrimitiveX(1),1,myPrimitiveLength);
1205 TShort_Array1OfShortReal Ypoint(myPrimitiveY(1),1,myPrimitiveLength);
1206 myPrimitiveLength = 0;
1207 DrawPolygon (Xpoint,Ypoint);
1208 }
1209 break;
1210 case Aspect_TOP_SEGMENTS:
1211 case Aspect_TOP_ARCS:
1212 case Aspect_TOP_POLYARCS:
1213 case Aspect_TOP_MARKERS:
1214 case Aspect_TOP_POINTS:
1215 break;
1216 default:
1217 myPrimitiveType = Aspect_TOP_UNKNOWN;
1218 }
1219 myPrimitiveType = Aspect_TOP_UNKNOWN;
1220}
1221
1222//===============================================================================
1223//===============================================================================
1224//===============================================================================
1225//===============================================================================
1226//===============================================================================
1227//===============================================================================
1228//===============================================================================
1229//===============================================================================
1230
1231//===============================================================================
1232Standard_Boolean PlotMgt_PlotterDriver::IsKnownImage (const Handle(Standard_Transient)& /*anImage*/)
1233{
1234 return Standard_False;
1235}
1236
1237//===============================================================================
1238void PlotMgt_PlotterDriver::ClearImage (const Handle(Standard_Transient)& /*anImage*/)
1239{
1240}
1241
1242//===============================================================================
1243void PlotMgt_PlotterDriver::ClearImageFile (const Standard_CString /*anImageFile*/)
1244{
1245}
1246
1247//===============================================================================
1248void PlotMgt_PlotterDriver::DrawImage (const Handle(Standard_Transient)& /*anImage*/,
1249 const Standard_ShortReal /*aX*/,
1250 const Standard_ShortReal /*aY*/)
1251{
1252}
1253
1254//===============================================================================
1255Standard_Boolean PlotMgt_PlotterDriver::SizeOfImageFile (const Standard_CString /*anImageFile*/,
1256 Standard_Integer &aWidth,
1257 Standard_Integer &aHeight) const
1258{
1259 aWidth = aHeight = 0;
1260 return Standard_False;
1261}
1262
1263//===============================================================================
1264void PlotMgt_PlotterDriver::DrawImageFile (const Standard_CString anImageFile,
1265 const Standard_ShortReal aX,
1266 const Standard_ShortReal aY,
1267 const Quantity_Factor aScale)
1268{
1269 PlotImage (aX, aY, 0.0F, 0.0F, (float)aScale, anImageFile, NULL);
1270}
1271
1272//===============================================================================
1273void PlotMgt_PlotterDriver::FillAndDrawImage (const Handle(Standard_Transient)& /*anImage*/,
1274 const Standard_ShortReal aX,
1275 const Standard_ShortReal aY,
1276 const Standard_Integer aWidth,
1277 const Standard_Integer aHeight,
1278 const Standard_Address anArrayOfPixels)
1279{
1280 PlotImage (aX, aY, (float)aWidth, (float)aHeight, 1.0F,
1281 NULL, anArrayOfPixels);
1282}
1283
1284//===============================================================================
1285void PlotMgt_PlotterDriver::FillAndDrawImage (const Handle(Standard_Transient)& /*anImage*/,
1286 const Standard_ShortReal aX,
1287 const Standard_ShortReal aY,
1288 const Standard_Integer anIndexOfLine,
1289 const Standard_Integer aWidth,
1290 const Standard_Integer aHeight,
1291 const Standard_Address anArrayOfPixels)
1292{
1293 PlotImage (aX, aY, (float)aWidth, (float)aHeight, 1.0F,
1294 NULL, anArrayOfPixels, anIndexOfLine);
1295}
1296
1297//===============================================================================
1298Standard_Boolean PlotMgt_PlotterDriver::PlotImage (const Standard_ShortReal /*aX*/,
1299 const Standard_ShortReal /*aY*/,
1300 const Standard_ShortReal /*aWidth*/,
1301 const Standard_ShortReal /*aHeight*/,
1302 const Standard_ShortReal /*aScale*/,
1303 const Standard_CString /*anImageFile*/,
1304 const Standard_Address /*anArrayOfPixels*/,
1305 const Standard_Integer /*aLineIndex*/)
1306{
1307 return Standard_False;
1308}
1309
1310//===============================================================================
1311//===============================================================================
1312//===============================================================================
1313//===============================================================================
1314//===============================================================================
1315//===============================================================================
1316//===============================================================================
1317//===============================================================================
1318
1319//===============================================================================
1320void PlotMgt_PlotterDriver::LineAttrib (Standard_Integer& ColorIndex,
1321 Standard_Integer& TypeIndex,
1322 Standard_Integer& WidthIndex) const
1323{
1324 ColorIndex = myLineColorIndex;
1325 TypeIndex = myLineTypeIndex;
1326 WidthIndex = myLineWidthIndex;
1327}
1328
1329//===============================================================================
1330void PlotMgt_PlotterDriver::PolyAttrib (Standard_Integer& ColorIndex,
1331 Standard_Integer& TileIndex,
1332 Standard_Boolean& EdgeFlag) const
1333{
1334 ColorIndex = myPolyColorIndex;
1335 TileIndex = myPolyTileIndex;
1336 EdgeFlag = myPolyEdgeFlag;
1337}
1338
1339//===============================================================================
1340void PlotMgt_PlotterDriver::WorkSpace (Quantity_Length& Width,
1341 Quantity_Length& Height) const
1342{
1343 Width = Quantity_Length (myWidth);
1344 Height = Quantity_Length (myHeight);
1345}
1346
1347//===============================================================================
1348Standard_Boolean PlotMgt_PlotterDriver::DrawCurveCapable () const
1349{
1350 return Standard_False;
1351}
1352
1353//===============================================================================
1354Standard_ShortReal PlotMgt_PlotterDriver::MapX (const Standard_ShortReal aShortreal) const
1355{
1356 return aShortreal;
1357}
1358
1359//===============================================================================
1360Standard_ShortReal PlotMgt_PlotterDriver::MapY (const Standard_ShortReal aShortreal) const
1361{
1362 return aShortreal;
1363}
1364
1365//===============================================================================
1366Quantity_Length PlotMgt_PlotterDriver::Convert (const Standard_Integer PV) const
1367{
1368 return Quantity_Length (PV * myPixelSize);
1369}
1370
1371//===============================================================================
1372Standard_Integer PlotMgt_PlotterDriver::Convert (const Quantity_Length DV) const
1373{
1374 return Standard_Integer (DV/myPixelSize);
1375}
1376
1377//===============================================================================
1378void PlotMgt_PlotterDriver::Convert (const Standard_Integer PX,
1379 const Standard_Integer PY,
1380 Quantity_Length& DX,
1381 Quantity_Length& DY) const
1382{
1383 DX = PX * myPixelSize;
1384 DY = PY * myPixelSize;
1385}
1386
1387//===============================================================================
1388void PlotMgt_PlotterDriver::Convert (const Quantity_Length DX,
1389 const Quantity_Length DY,
1390 Standard_Integer& PX,
1391 Standard_Integer& PY) const
1392{
1393 PX = (Standard_Integer )( DX / myPixelSize);
1394 PY = (Standard_Integer )( DY / myPixelSize);
1395}