[222] | 1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
| 2 | // Module PI : Peida Interactive PIGraphic
|
---|
| 3 | // Primitives de trace graphiques R. Ansari 97
|
---|
| 4 | // LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA
|
---|
| 5 |
|
---|
| 6 | #ifndef PIGRAPHICGEN_H_SEEN
|
---|
| 7 | #define PIGRAPHICGEN_H_SEEN
|
---|
| 8 |
|
---|
| 9 | #include "pisysdep.h"
|
---|
| 10 |
|
---|
| 11 | #include PIWDG_H
|
---|
| 12 | #include PICMAP_H
|
---|
| 13 |
|
---|
| 14 |
|
---|
| 15 | enum PIColors { PI_ColorFromMap = -2, PI_NotDefColor = -1,
|
---|
| 16 | PI_Black = 0, PI_White = 1, PI_Grey = 2,
|
---|
| 17 | PI_Red = 3, PI_Blue = 4, PI_Green = 5,
|
---|
| 18 | PI_Yellow = 6, PI_Magenta = 7,
|
---|
| 19 | PI_Cyan = 8, PI_Turquoise = 9, PI_NavyBlue = 10,
|
---|
| 20 | PI_Orange = 11, PI_SiennaRed = 12, PI_Purple = 13,
|
---|
| 21 | PI_LimeGreen = 14, PI_Gold = 15 };
|
---|
| 22 |
|
---|
| 23 | enum PIFontSize { PI_NotDefFontSize = -1,
|
---|
| 24 | PI_SmallSizeFont = 1, PI_NormalSizeFont = 2,
|
---|
| 25 | PI_BigSizeFont = 3, PI_HugeSizeFont = 4 };
|
---|
| 26 |
|
---|
| 27 | enum PIFontAtt { PI_NotDefFontAtt = -1,
|
---|
| 28 | PI_RomanFont = 1, PI_BoldFont = 2, PI_ItalicFont = 4 };
|
---|
| 29 |
|
---|
| 30 | enum PILineAtt { PI_NotDefLineAtt = -1,
|
---|
| 31 | PI_NormalLine = 0, PI_ThinLine = 1, PI_ThickLine = 2 ,
|
---|
| 32 | PI_DashedLine = 64, PI_ThinDashedLine = 65, PI_ThickDashedLine = 66 ,
|
---|
| 33 | PI_DottedLine = 128, PI_ThinDottedLine = 129, PI_ThickDottedLine = 130 };
|
---|
| 34 |
|
---|
| 35 | enum PIMarker { PI_NotDefMarker = -1,
|
---|
| 36 | PI_DotMarker = 0, PI_PlusMarker=1, PI_CrossMarker=2,
|
---|
| 37 | PI_CircleMarker=3, PI_FCircleMarker=4,
|
---|
| 38 | PI_BoxMarker=5, PI_FBoxMarker=6,
|
---|
| 39 | PI_TriangleMarker=7, PI_FTriangleMarker=8,
|
---|
| 40 | PI_StarMarker=9, PI_FStarMarker=10 };
|
---|
| 41 |
|
---|
| 42 | enum PIGOMode { PI_GOCopy = 0, PI_GOXOR = 1 };
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | // Classe pour gerer indifferement des coordonnees double ou int
|
---|
| 46 | class PIGrCoord {
|
---|
| 47 | public:
|
---|
| 48 | inline PIGrCoord() { iv = 0; dv = 0.;}
|
---|
| 49 | inline PIGrCoord(int a) { iv = a; dv = (double)a;}
|
---|
| 50 | inline PIGrCoord(float a) { iv = (int)a; dv = (double)a;}
|
---|
| 51 | inline PIGrCoord(double a) { iv = (int)a; dv = a;}
|
---|
| 52 | inline operator int() { return(iv); }
|
---|
| 53 | inline operator short() { return((short)iv); }
|
---|
| 54 | inline operator unsigned int() { return((unsigned int)iv); }
|
---|
| 55 | inline operator unsigned short() { return((unsigned short)iv); }
|
---|
| 56 | inline operator float() { return((float)dv); }
|
---|
| 57 | inline operator double() { return(dv); }
|
---|
| 58 | inline PIGrCoord& operator= (int a) { iv = a; dv = (double)a; return(*this); }
|
---|
| 59 | inline PIGrCoord& operator= (float a) { iv = (int)a; dv = (double)a; return(*this); }
|
---|
| 60 | inline PIGrCoord& operator= (double a) { iv = (int)a; dv = a; return(*this); }
|
---|
| 61 | int iv;
|
---|
| 62 | double dv;
|
---|
| 63 | };
|
---|
| 64 |
|
---|
| 65 | enum PIGraphicsType { PI_UnknownGraphics = 0,
|
---|
| 66 | PI_ScrWindowGraphics = 2, PI_ScrBufferGraphics = 3,
|
---|
| 67 | PI_PSFileGraphics = 8,
|
---|
| 68 | PI_UCGraphics = 32, PI_3DGraphics = 36 };
|
---|
| 69 |
|
---|
| 70 | // Classe generique de trace graphique de base :
|
---|
| 71 |
|
---|
| 72 | class PIGraphicGen
|
---|
| 73 | {
|
---|
| 74 | public:
|
---|
| 75 | PIGraphicGen();
|
---|
| 76 | PIGraphicGen(PIWdg* wdg);
|
---|
| 77 | PIGraphicGen(PIScreenBuffer* grb);
|
---|
| 78 | virtual ~PIGraphicGen();
|
---|
| 79 |
|
---|
| 80 | virtual int kind();
|
---|
| 81 |
|
---|
| 82 | // Espace des coordonnees
|
---|
| 83 | virtual void GetGrSpace(PIGrCoord& xmin, PIGrCoord& xmax, PIGrCoord& ymin, PIGrCoord& ymax);
|
---|
| 84 |
|
---|
| 85 | // Trace graphiques
|
---|
| 86 | virtual void Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy) = 0;
|
---|
| 87 | virtual void DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0) = 0;
|
---|
| 88 | virtual void DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0) = 0;
|
---|
| 89 | virtual void DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2) = 0;
|
---|
| 90 | virtual void DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy) = 0;
|
---|
| 91 | virtual void DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy) = 0;
|
---|
| 92 | virtual void DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r) = 0;
|
---|
| 93 | virtual void DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r) = 0;
|
---|
| 94 | virtual void DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy) = 0;
|
---|
| 95 | virtual void DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy) = 0;
|
---|
| 96 | virtual void DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true) = 0;
|
---|
| 97 | virtual void DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true) = 0;
|
---|
| 98 | virtual void DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
|
---|
| 99 | double degdeb, double degfin) = 0;
|
---|
| 100 | virtual void DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
|
---|
| 101 | double degdeb, double degfin) = 0;
|
---|
| 102 | virtual void DrawMarker(PIGrCoord x0, PIGrCoord y0) = 0;
|
---|
| 103 | virtual void DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n) = 0;
|
---|
| 104 | virtual void DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix,
|
---|
| 105 | int sx, int sy, PIColorMap* cmap) = 0;
|
---|
| 106 |
|
---|
| 107 | // Modifications attributs graphiques
|
---|
| 108 | virtual void SelForeground(PIColors col=PI_Black) = 0;
|
---|
| 109 | virtual void SelBackground(PIColors col=PI_White) = 0;
|
---|
| 110 | virtual void SelForeground(PIColorMap& cmap, int cid) = 0;
|
---|
| 111 | virtual void SelBackground(PIColorMap& cmap, int cid) = 0;
|
---|
| 112 | virtual void SelGOMode(PIGOMode mod=PI_GOCopy) = 0;
|
---|
| 113 | virtual void SelFont(PIFontSize sz=PI_NormalSizeFont,
|
---|
| 114 | PIFontAtt att=PI_RomanFont) = 0;
|
---|
| 115 | virtual void SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont) = 0;
|
---|
| 116 | virtual void SelLine(PILineAtt att=PI_NormalLine) = 0;
|
---|
| 117 | virtual void SelMarker(int msz=3, PIMarker mrk=PI_DotMarker) = 0;
|
---|
| 118 |
|
---|
| 119 | // Selection de zone de trace (clip)
|
---|
| 120 | virtual void SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy) = 0;
|
---|
| 121 | virtual void ClearClipRectangle() = 0;
|
---|
| 122 |
|
---|
| 123 | // Acces aux attributs graphiques
|
---|
| 124 | virtual PIColors GetForeground() = 0;
|
---|
| 125 | virtual PIColors GetBackground() = 0;
|
---|
| 126 | virtual PIGOMode GetGOMode() = 0;
|
---|
| 127 | virtual PIFontAtt GetFontAtt() = 0;
|
---|
| 128 | virtual int GetFontSize() = 0;
|
---|
| 129 | virtual PILineAtt GetLineAtt() = 0;
|
---|
| 130 | virtual PIMarker GetMarker() = 0;
|
---|
| 131 | virtual int GetMarkerSize() = 0;
|
---|
| 132 |
|
---|
| 133 | virtual int GetFontHeight(int& asc, int& desc) = 0;
|
---|
| 134 | virtual PIGrCoord CalcStringWidth(char const* s) = 0;
|
---|
| 135 |
|
---|
| 136 | // Sauvegarde des attributs graphiques
|
---|
| 137 | virtual void SaveGraphicAtt();
|
---|
| 138 | virtual void RestoreGraphicAtt();
|
---|
| 139 |
|
---|
| 140 | protected:
|
---|
| 141 | // Pour Save/Restore des attributs graphiques
|
---|
| 142 | PIWdg* myWdg;
|
---|
| 143 | PIScreenBuffer* myGrb;
|
---|
| 144 |
|
---|
| 145 | PIColors sFCol, sBCol;
|
---|
| 146 | PIGOMode sGOm;
|
---|
| 147 | PIFontAtt sFAtt;
|
---|
| 148 | PILineAtt sLAtt;
|
---|
| 149 | int sFSize;
|
---|
| 150 | PIMarker sMrk;
|
---|
| 151 | int sMrkSz;
|
---|
| 152 | };
|
---|
| 153 |
|
---|
| 154 | #endif
|
---|
| 155 |
|
---|
| 156 | typedef PIGraphicGen PIGraphic;
|
---|
| 157 |
|
---|
| 158 | // hierarchie apparente
|
---|
| 159 | // PIGraphic ( == Gen, mais pas visible de l'utilisateur).
|
---|
| 160 | // PIGraphicWin ( == X ou Mac)
|
---|
| 161 | // PIGraphicPS
|
---|
| 162 | // PIGraphicUC
|
---|