summaryrefslogtreecommitdiff
path: root/inc/PlotMgt_PlotterTools.hxx
blob: cf0b7466b803c9ab508259d6ad6e0c5ccf9bf3ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#ifndef PLOTMGT_PLOTTERTOOLS
#define PLOTMGT_PLOTTERTOOLS

#include <Standard_Stream.hxx>

#include <OSD_Path.hxx>
#include <OSD_File.hxx>
#include <OSD_FileIterator.hxx>
#include <PlotMgt_TypeOfPlotterParameter.hxx>
#include <TCollection_AsciiString.hxx>
#include <TColStd_HSequenceOfAsciiString.hxx>
#include <stdio.h>
#ifndef WNT
# include <strings.h>
# include <unistd.h>
#else
# define STRICT
# include <windows.h>
# pragma comment (lib,"GDI32.LIB")
#endif // WNT

#define _T_UNK   PlotMgt_TOPP_Undefined
#define _T_INT   PlotMgt_TOPP_Integer
#define _T_REAL  PlotMgt_TOPP_Real
#define _T_BOOL  PlotMgt_TOPP_Boolean
#define _T_STR   PlotMgt_TOPP_String
#define _T_LSTR  PlotMgt_TOPP_ListString

#define _TYPE_SIGN    ".Type"
#define _DIALOG_SIGN  ".Dialog"
#define _MINVAL_SIGN  ".Min"
#define _MAXVAL_SIGN  ".Max"
#define _VALUES_SIGN  ".Values"
#define _LENGTH_SIGN  ".Length"
#define _DELIM_SIGN   " : "

typedef struct _ParameterDesc {
  Standard_CString               _new_name;
  Standard_CString               _old_name;
  PlotMgt_TypeOfPlotterParameter _type;
  Standard_Integer               _ismap;
} ParameterDesc;

extern ParameterDesc __PossibleParameters[];

//==============================================================================
#define PLOT_CONFIGVER       "ConfigurationVersion"
#define PLOT_DIALOGUNIT      "DialogUnit"
#define PLOT_MODEL           "Model"
#define PLOT_OUTFORMAT       "OutputFormat"
#define PLOT_IMGFORMAT       "ImageFormat"
#define PLOT_SETBKWHITE      "SetBackgroundInWhite"
#define PLOT_TITLE           "Title"
#define PLOT_DRVTYPE         "DriverType"
#define PLOT_EXTENSION       "Extension"
#define PLOT_PAPERFORMAT     "PaperFormat"
#define PLOT_ORIENTATION     "PlottingOrientation"
#define PLOT_MIRRORDRIVEN    "MirroringDriven"
#define PLOT_MIRRORING       "PlottingMirroring"
#define PLOT_PAPERWIDTH      "PaperWidth"
#define PLOT_PAPERLENGTH     "PaperLength"
#define PLOT_QUALITYDRIVEN   "QualityDriven"
#define PLOT_QUALITY         "Quality"
#define PLOT_COPYDRIVEN      "CopyDriven"
#define PLOT_FEEDDRIVEN      "PaperFeedDriven"
#define PLOT_PAPERFEED       "PaperFeed"
#define PLOT_CUTDRIVEN       "PaperCutDriven"
#define PLOT_ORIGIN          "Origin"
#define PLOT_MINLEFTMARGIN   "MinLeftMargin"
#define PLOT_MINBOTTOMMARGIN "MinBottomMargin"
#define PLOT_MINTOPMARGIN    "MinTopMargin"
#define PLOT_MINRIGHTMARGIN  "MinRightMargin"
#define PLOT_LEFTMARGIN      "LeftMargin"
#define PLOT_BOTTOMMARGIN    "BottomMargin"
#define PLOT_TOPMARGIN       "TopMargin"
#define PLOT_RIGHTMARGIN     "RightMargin"
#define PLOT_PLOTTINGGAP     "PlottingGap"
#define PLOT_PLOTTERCOLOR    "PlotterColor"
#define PLOT_MAXCOLORS       "MaxColors"
#define PLOT_PLOTTINGCOLOR   "PlottingColor"
#define PLOT_COLORMAPPING    "ColorMapping"
#define PLOT_MAXPATTERMS     "MaxPatterns"
#define PLOT_COLORMAPRGB     "ColorMapRGB"
#define PLOT_COLORMAXGAP     "ColorMaxGap"
#define PLOT_WIDTHMAP        "WidthMap"
#define PLOT_WIDTHMAXGAP     "WidthMaxGap"
#define PLOT_LINETYPEMAP     "LineTypeMap"
#define PLOT_LINETYPEMAXGAP  "LineTypeMaxGap"
#define PLOT_RESOLUTION      "Resolution"
#define PLOT_COLORRESOLUTION "ColorResolution"
#define PLOT_CIRCLEDRIVEN    "CircleDriven"
#define PLOT_ELLIPSEDRIVEN   "EllipseDriven"
#define PLOT_CURVEDRIVEN     "CurveDriven"
#define PLOT_TEXTDRIVEN      "TextDriven"
#define PLOT_MARKERDRIVEN    "MarkerDriven"
#define PLOT_RECTANGLEDRIVEN "RectangleDriven"
#define PLOT_FILLDRIVEN      "FillDriven"
#define PLOT_FONTMAP         "FontMap"
#define PLOT_PLOTTINGTYPE    "PlottingType"
#define PLOT_STYLUSNUMBER    "StylusNumber"
#define PLOT_DENSITY         "LinearDensity"
#define PLOT_MAXPENS         "MaxPens"
#define PLOT_MOUNTEDPENS     "MountedPens"
#define PLOT_PENSINDEXWIDTH  "PensIndexWidth"
#define PLOT_PENSINDEXCOLOR  "PensIndexColor"
#define PLOT_PENSINDEXTYPE   "PensIndexLineType"
#define PLOT_CHECKSUMDRIVEN  "ChecksumDriven"
#define PLOT_BEFORECMD       "CommandBeforeDriver"
#define PLOT_AFTERCMD        "CommandAfterDriver"
#define PLOT_PRINTCMD        "CommandToPrint"
#define PLOT_MEDIASAVDRIVEN  "MediaSaverDriven"
#define PLOT_MEDIASAVTIME    "MediaSaverTimeOut"
#define PLOT_ENDOFPLOTDRIVEN "EndOfPlotTimerDriven"
#define PLOT_ENDOFPLOTTIMER  "EndOfPlotTimer"
#define PLOT_DRYTIMEDRIVEN   "DryTimeDriven"
#define PLOT_DRYTIME         "DryTime"
#define PLOT_PHYSICALSTEP    "PhysicalStep"
#define PLOT_MINWIDTHOFLINE  "MinWidthOfLine"
#define PLOT_COPIES          "PlottingCopie"
#define PLOT_ROTATEDRIVEN    "RotationDriven"
#define PLOT_ROTATION        "PlottingRotation"
#define PLOT_FRAME           "PlottingFrame"
#define PLOT_FRAMEAROUNDIMG  "FrameAroundImage"
#define PLOT_MULTISHEET      "PlottingMultiSheet"
#define PLOT_PLOTCOMMENT     "PlottingComment"
#define PLOT_COMMENTS        "Comment"
#define PLOT_PLOTTITLE       "PlottingTitle"
#define PLOT_PLOTBACKDRAW    "PlottingBackDraw"
#define PLOT_BACKDRAW        "BackgroundDrawing"
#define PLOT_WIDTHOFFSET     "WidthOffset"
#define PLOT_WIDTHSCALE      "WidthScale"
#define PLOT_LENGTHOFFSET    "LengthOffset"
#define PLOT_LENGTHSCALE     "LengthScale"
#define PLOT_FILLWIDTH       "FillWidth"

//==============================================================================
#ifdef WNT
  #define GET_WNT_DEVICE_SIZE()                                        \
    HDC hdc;                                                           \
    if (!lstrcmpi (myName.ToCString(), "DISPLAY"))                     \
      hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);                    \
    else                                                               \
      hdc = CreateDC ("WINSPOOL", myName.ToCString(), NULL, NULL);     \
    if (hdc != NULL) {                                                 \
      myWidth  = ((Standard_Real)GetDeviceCaps (hdc, HORZSIZE) / 10.); \
      myLength = ((Standard_Real)GetDeviceCaps (hdc, VERTSIZE) / 10.); \
      DeleteDC (hdc);                                                  \
    }
#else
  #define GET_WNT_DEVICE_SIZE() { myWidth = 0.0; myLength = 0.0; }
#endif

//==============================================================================
#define TRIM_RIGHT(aBuffer)                \
  {                                        \
    int aPos = strlen (aBuffer);           \
    while ( ((aBuffer[aPos-1] == '\n') ||  \
             (aBuffer[aPos-1] == ' ' )) && \
            aPos )                         \
      aPos--;                              \
    aBuffer [aPos] = '\0';                 \
  }


//==============================================================================
#define BAD_VALUE1(theVal)          (theVal <= 0)

#define BAD_VALUE2(theVal)          ((theVal != 0) && (theVal != -1))

#define BAD_PLOTTER_MSG()                                      \
  cout << "Plotter ignored : BAD CONFIG ('" << aModel << "','" \
       << aOutFormat << "'," << anImgFormat << ")\n" << flush;

//==============================================================================
Standard_CString PARAM_BAD_VALUE1   (const Standard_CString aMethodName);
Standard_CString PARAM_BAD_VALUE2   (const Standard_CString aMethodName);
char*            trim               (char* buffer);
Standard_Integer ItemIndex          (Handle(TColStd_HSequenceOfAsciiString)&,
                                     const TCollection_AsciiString&,
                                     const Standard_Integer nStartIndex = 1);
void             FillListByIterator (Handle(TColStd_HSequenceOfAsciiString)& aList,
                                     OSD_FileIterator& anIterator,
                                     Standard_CString aNeedExtension,
                                     // If plotter already exist in the list do not use it.
                                     const Standard_Boolean aCheckExisted = Standard_False);

#endif // PLOTMGT_PLOTTERTOOLS