00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __SO_VECTORIZE_GDI_ACTION_
00025 #define __SO_VECTORIZE_GDI_ACTION_
00026
00027 #include <SbTypes.h>
00028
00029 #ifdef _WIN32
00030 # ifdef _SO_QT_
00031 # include <windows.h>
00032 # include <wingdi.h>
00033 # else
00034 # include <Inventor/Win/SoWinDef.h>
00035 # endif
00036 #elif defined(__NUTC__)
00037 # include <windows.h>
00038 # include <wingdi.h>
00039 #else
00040 # define HPEN void *
00041 # define HGDIOBJ void *
00042 # define HBRUSH void *
00043 # define HGDIOBJ void *
00044 typedef uint32_t DWORD;
00045 typedef DWORD COLORREF;
00046 {
00047 long x;
00048 long y;
00049 } POINT;
00050 #endif
00051
00052 #include <HardCopy/SoVectorizeAction.h>
00053
00068 class SoGDIVectorOutput : public SoVectorOutput
00069 {
00070
00071 public:
00072
00076 SoGDIVectorOutput();
00077
00082 virtual ~SoGDIVectorOutput();
00083
00090 SoNONUNICODE SbBool openFile(const char *file_name);
00091
00096 SbBool openFile( const SbString& file_name );
00097
00105 void openFile(HDC hdc);
00106
00110 void openFile();
00111
00116 void closeFile();
00117
00118 private:
00119
00120 SbString getGDIOutputName();
00121
00122 HDC getGDIHdc();
00123
00124 private:
00125
00126 SbString m_filename;
00127 HDC m_hdc;
00128 };
00129
00205 class SoVectorizeGDIAction : public SoVectorizeAction
00206 {
00207
00208 SO_ACTION_HEADER(SoVectorizeGDIAction);
00209
00210 public:
00211
00215 SoVectorizeGDIAction();
00216
00220 virtual ~SoVectorizeGDIAction();
00221
00222
00223
00227 SoGDIVectorOutput *getGDIVectorOutput() const;
00228
00232 SbBool hasPrinter() { return m_hasPrinter; };
00233
00234 #if 1 SoDEPRECATED
00237 SoGDIVectorOutput *getOutput() const;
00238
00239 #endif
00241 private:
00242
00245 static void initClass();
00246 static void exitClass();
00247
00248 private:
00249
00250 virtual void printPolyMark(const SbVec4f* points, int num_points,
00251 const SbColor* colors, SbBool color_flag, float size);
00252 virtual void printPolyMark(const SbVec4f* points, int num_points,
00253 const SbColor* colors, SbBool color_flag,
00254 SoMarkerSet *markerSet);
00255 virtual void printImage(const SbVec4f &origin, const unsigned char *imagePixels,
00256 SbVec2s &sourceSize, SbVec2s &requestedSize,
00257 int numComponents,
00258 SoImage::HorAlignment horAlign,
00259 SoImage::VertAlignment vertAlign);
00260 virtual void printPolyLine(const SbVec4f* points, int num_points,
00261 const SbColor* colors, SbBool color_flag,
00262 float thickness, u_short pattern, int linePatternScaleFactor);
00263 virtual void printPolygon(const SbVec4f* points, int num_points,
00264 const SbColor* colors, SbBool color_flag, const SbString &category,
00265 const SbString &name, const unsigned char* pattern);
00266 virtual void printText2(const SbVec4f point, const SbColor color,
00267 const SbString& font_name, float font_size,
00268 const SbString& string, int justif, float angle);
00269
00270
00271 HDC getPrinterDC(void);
00272
00273
00274 virtual void writeHeader();
00275 virtual void writeFooter();
00276
00277
00278 virtual void printBorder();
00279 virtual void printBackground();
00280
00281
00282 virtual void setHardwareClip();
00283
00284
00285 private:
00286 void assignColor(SbColor, float);
00287 void selectPen(DWORD, DWORD, COLORREF, SbBool);
00288 SbBool isPenUsedAgain(DWORD, DWORD, COLORREF, SbBool);
00289 void pointsToLandscape(POINT *, int);
00290
00291
00292 {
00293 DWORD style;
00294 DWORD thickness;
00295 COLORREF color;
00296 } structCurrentPen;
00297
00298 structCurrentPen currentPen;
00299 HPEN m_currentPen;
00300 HGDIOBJ m_oldPen;
00301 HBRUSH m_currentBrush;
00302 HGDIOBJ m_oldBrush;
00303 COLORREF m_currentBrushColor;
00304 SbBool m_patternFlag;
00305
00306 SbColor m_currentColor;
00307 EndLineStyle m_currentLineEndStyle;
00308 JoinLineStyle m_currentLineJoinsStyle;
00309 float m_currentMiterLimit;
00310
00311 SbString m_filename;
00312
00313 HDC m_hdc;
00314 SbBool m_hasPrinter;
00315
00316 SbBool m_printerFlag;
00317 SbBool m_solidPenFlag;
00318 int m_offsetX, m_offsetY;
00319 int m_portraitWidth;
00320 int m_unitRatio;
00321 };
00322
00323
00324 #endif //__SO_VECTORIZE_GDI_ACTION_
00325
00326