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 #else
00037 # define HPEN void *
00038 # define HGDIOBJ void *
00039 # define HBRUSH void *
00040 # define HGDIOBJ void *
00041 typedef uint32_t DWORD;
00042 typedef DWORD COLORREF;
00043 {
00044 long x;
00045 long y;
00046 } POINT;
00047 #endif
00048
00049 #include <HardCopy/SoVectorizeAction.h>
00050
00064 class SoGDIVectorOutput : public SoVectorOutput
00065 {
00066
00067 public:
00068
00072 SoGDIVectorOutput();
00073
00078 virtual ~SoGDIVectorOutput();
00079
00086 SoNONUNICODE SbBool openFile(const char *file_name);
00087
00092 SbBool openFile( const SbString& file_name );
00093
00101 void openFile(HDC hdc);
00102
00106 void openFile();
00107
00112 void closeFile();
00113
00114 private:
00115
00116 SbString getGDIOutputName();
00117
00118 HDC getGDIHdc();
00119
00120 private:
00121
00122 SbString m_filename;
00123 HDC m_hdc;
00124 };
00125
00200 class SoVectorizeGDIAction : public SoVectorizeAction
00201 {
00202
00203 SO_ACTION_HEADER(SoVectorizeGDIAction);
00204
00205 public:
00206
00210 SoVectorizeGDIAction();
00211
00215 virtual ~SoVectorizeGDIAction();
00216
00217
00218
00222 SoGDIVectorOutput *getGDIVectorOutput() const;
00223
00227 SbBool hasPrinter() { return m_hasPrinter; };
00228
00229 private:
00233 static void initClass();
00234 static void exitClass();
00235
00236 private:
00237
00238 virtual void printPolyMark(const SbVec4f* points, int num_points,
00239 const SbColor* colors, SbBool color_flag, float size);
00240 virtual void printPolyMark(const SbVec4f* points, int num_points,
00241 const SbColor* colors, SbBool color_flag,
00242 SoMarkerSet *markerSet);
00243 virtual void printImage(const SbVec4f &origin, const unsigned char *imagePixels,
00244 SbVec2s &sourceSize, SbVec2s &requestedSize,
00245 int numComponents,
00246 SoImage::HorAlignment horAlign,
00247 SoImage::VertAlignment vertAlign);
00248 virtual void printPolyLine(const SbVec4f* points, int num_points,
00249 const SbColor* colors, SbBool color_flag,
00250 float thickness, u_short pattern, int linePatternScaleFactor);
00251 virtual void printPolygon(const SbVec4f* points, int num_points,
00252 const SbColor* colors, SbBool color_flag, const SbString &category,
00253 const SbString &name, const unsigned char* pattern);
00254 virtual void printText2(const SbVec4f point, const SbColor color,
00255 const SbString& font_name, float font_size,
00256 const SbString& string, int justif, float angle);
00257
00258
00259 HDC getPrinterDC(void);
00260
00261
00262 virtual void writeHeader();
00263 virtual void writeFooter();
00264
00265
00266 virtual void printBorder();
00267 virtual void printBackground();
00268
00269
00270 virtual void setHardwareClip();
00271
00272
00273 private:
00274 void assignColor(SbColor, float);
00275 void selectPen(DWORD, DWORD, COLORREF, SbBool);
00276 SbBool isPenUsedAgain(DWORD, DWORD, COLORREF, SbBool);
00277 void pointsToLandscape(POINT *, int);
00278
00279
00280 {
00281 DWORD style;
00282 DWORD thickness;
00283 COLORREF color;
00284 } structCurrentPen;
00285
00286 structCurrentPen currentPen;
00287 HPEN m_currentPen;
00288 HGDIOBJ m_oldPen;
00289 HBRUSH m_currentBrush;
00290 HGDIOBJ m_oldBrush;
00291 COLORREF m_currentBrushColor;
00292 SbBool m_patternFlag;
00293
00294 SbColor m_currentColor;
00295 EndLineStyle m_currentLineEndStyle;
00296 JoinLineStyle m_currentLineJoinsStyle;
00297 float m_currentMiterLimit;
00298
00299 SbString m_filename;
00300
00301 HDC m_hdc;
00302 SbBool m_hasPrinter;
00303
00304 SbBool m_printerFlag;
00305 SbBool m_solidPenFlag;
00306 int m_offsetX, m_offsetY;
00307 int m_portraitWidth;
00308 int m_unitRatio;
00309 };
00310
00311
00312 #endif //__SO_VECTORIZE_GDI_ACTION_
00313
00314