source: Sophya/trunk/Poubelle/PI/pidrawer.h

Last change on this file was 222, checked in by ansari, 26 years ago

Creation module DPC/PI Reza 09/04/99

File size: 6.9 KB
RevLine 
[222]1// This may look like C code, but it is really -*- C++ -*-
2// Objets traceur qui peuvent etre attaches a un PIBaseWidget
3// R. Ansari 97-98
4// LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA
5#ifndef PIDRAWER_H
6#define PIDRAWER_H
7
8#include "pibwdggen.h"
9#include "pigraphuc.h"
10
11#include <list>
12#if defined(__KCC__)
13#include <list.h>
14#endif
15
16enum {
17 kStdAxes = 0x0001,
18 kBoxAxes = 0x0002,
19 kTicks = 0x0004,
20 kIntTicks = 0x0010,
21 kExtTicks = 0x0020,
22 kMajTicks = 0x0040,
23 kMinTicks = 0x0080,
24 kLabels = 0x1000,
25 kGridOn = 0x2000,
26 kAxesDflt = kStdAxes | kTicks | kLabels, // Axes trace par defaut
27 kAxesNone = 0 // Pas de trace d axe
28};
29
30
31class PIDrawer {
32public:
33 PIDrawer();
34 virtual ~PIDrawer();
35
36 virtual void SetLimits(double xmin, double xmax, double ymin, double ymax,
37 int axrl=kAxeDirSame, int ayud=kAxeDirSame);
38
39 virtual void DrawAxes(PIGraphicUC* g);
40 virtual void SetAxesFlags(unsigned int flags=kAxesNone);
41
42 virtual void Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
43
44 virtual void Refresh(); // Recalcule les limites et reaffiche
45 virtual void UpdateLimits(); // Calcule et change les limites
46
47 inline double XMin() const {return xMin;}
48 inline double XMax() const {return xMax;}
49 inline double YMin() const {return yMin;}
50 inline double YMax() const {return yMax;}
51
52 void GetAxesConfig(int& xa, int& ya);
53 inline unsigned int GetAxesFlags() { return(axesFlags); }
54
55 inline PIGraphicUC* GetGraphicUC() { return(mGrUC); }
56
57 inline int LimitsFixed() const {return limitsFixed;}
58 inline void FreeLimits() {limitsFixed = 0;}
59
60// Changement des attributs graphiques
61 virtual void SetColAtt(PIColors fg=PI_NotDefColor,
62 PIColors bg=PI_NotDefColor);
63 virtual void SetLineAtt(PILineAtt lat=PI_NotDefLineAtt);
64 virtual void SetFontAtt(PIFontSize fsz=PI_NotDefFontSize,
65 PIFontAtt fat=PI_NotDefFontAtt);
66 virtual void SetMarkerAtt(int sz=-1, PIMarker mrk=PI_NotDefMarker);
67 virtual void SetColMapId(CMapId cid=CMAP_OTHER);
68
69 void SelGraAtt(PIGraphicUC* g);
70
71// Acces aux attributs graphiques
72 inline PIColors GetFgColAtt() { return(mFCol); }
73 inline PIColors GetBgColAtt() { return(mBCol); }
74 inline PILineAtt GetLineAtt() { return(mLAtt); }
75 inline PIFontSize GetFontSz() { return(mFSz); }
76 inline PIFontAtt GetFontAtt() { return(mFAtt); }
77 inline int GetMarkerSz() { return(mMSz); }
78 inline PIMarker GetMarker() { return(mMrk); }
79 inline CMapId GetColMapId() { return(mCmapid); }
80
81
82// --- Methode static ----
83// Calcul des Distances optimales des subdivisions
84 static void BestTicks(double rmin,double rmax,int nticks,double& majt);
85
86// Les objets/methodes suivants devraient etre protected
87// Pb avec acces depuis PIBaseWdgGen (Reza 11/07/97)
88 virtual PIGraphicUC* SetDrwWdg(PIBaseWdgGen* drw, int x0, int y0, int dx, int dy, PIGraphicGen* g);
89
90// Je declare en public a cause de cxx - Reza 11/07/97
91 struct DrwBWId { int id; PIBaseWdgGen* wdg; };
92
93protected:
94 friend class PIBaseWdgGen;
95 virtual void Attach(PIBaseWdgGen*, int id);
96 virtual void Detach(PIBaseWdgGen*, int id);
97
98 void CalcTicks();
99
100 void DrawHTicks(PIGraphicUC* g, double y, double tickUp, double tickDown, double xBeg, double xStep);
101 void DrawVTicks(PIGraphicUC* g, double x, double tickLeft, double tickRight, double yBeg, double yStep);
102 void DrawHLabels(PIGraphicUC* g, double y, double xBeg, double xStep, int just=0);
103 void DrawVLabels(PIGraphicUC* g, double x, double yBeg, double yStep, int just=0);
104 void DrawGrid(PIGraphicUC* g);
105
106
107 double xMin, xMax, yMin, yMax; // Valeurs en unites user
108 int xW0, yW0, xWd, yWd; // Origine/largeur ds la fenetre de trace
109 bool aXdir, aYdir; // Sens des axes horiz, vertical
110 int aXFlg, aYFlg;
111
112 double xFirstMajTick, xFirstMinTick;
113 double yFirstMajTick, yFirstMinTick;
114 double xMajTickStep, xMinTickStep;
115 double yMajTickStep, yMinTickStep;
116 double xMajTickLen, xMinTickLen;
117 double yMajTickLen, yMinTickLen;
118
119 int limitsFixed;
120 unsigned int axesFlags;
121
122 PIBaseWdgGen* mBWdg;
123 PIGraphicUC* mGrUC;
124
125 list<DrwBWId> mBWdgList;
126 bool mDndfg;
127
128// Gestion d attributs graphiques associes a chaque drawer
129 PIColors mFCol, mBCol;
130 PILineAtt mLAtt;
131 PIFontSize mFSz;
132 PIFontAtt mFAtt;
133 int mMSz;
134 PIMarker mMrk;
135 CMapId mCmapid;
136
137};
138
139
140// Classe avec gestion d une liste d elements a tracer
141
142class PIElDrawer : public PIDrawer
143{
144public:
145 enum { PIDEL_Line = 1, PIDEL_Text = 2,
146 PIDEL_Rect = 3, PIDEL_FRect = 4,
147 PIDEL_Circ = 5, PIDEL_FCirc = 6 } ;
148
149 PIElDrawer();
150 virtual ~PIElDrawer();
151
152 virtual void SetTitles(const char* tt=NULL, const char* tb=NULL);
153 virtual void SetTitles(string const & tt, string const & tb);
154
155 virtual void Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
156
157 inline int ElAddLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2,
158 PIColors c=PI_NotDefColor)
159 { return( ElAdd(PIDEL_Line, x1, y1, x2, y2, NULL, c) ); }
160 inline int ElAddText(PIGrCoord x, PIGrCoord y, const char* s, PIColors c=PI_NotDefColor)
161 { return( ElAdd(PIDEL_Text, x, y, 0, 0, s, c) ); }
162 inline int ElAddRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy,
163 PIColors c=PI_NotDefColor)
164 { return( ElAdd(PIDEL_Rect, x, y, dx, dy, NULL, c) ); }
165 inline int ElAddFRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy,
166 PIColors c=PI_NotDefColor)
167 { return( ElAdd(PIDEL_FRect, x, y, dx, dy, NULL, c) ); }
168 inline int ElAddCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r, PIColors c=PI_NotDefColor)
169 { return( ElAdd(PIDEL_Circ, x, y, r, r, NULL, c) ); }
170 inline int ElAddFCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r, PIColors c=PI_NotDefColor)
171 { return( ElAdd(PIDEL_FCirc, x, y, r, r, NULL, c) ); }
172
173 void ElDel(int id);
174 void ElDelAll();
175
176protected:
177 int ElAdd(int typ, PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy,
178 const char* s, PIColors c=PI_NotDefColor);
179#ifdef __DECCXX
180public:
181#endif
182 struct DrwEl{
183 int eid, etyp;
184 PIGrCoord ex,ey;
185 PIGrCoord edx,edy;
186 string es;
187 PIColors col;
188 };
189#ifdef __DECCXX
190protected:
191#endif
192 typedef list<DrwEl> DrwElList;
193
194 DrwElList mElist;
195 int mEn;
196
197 string titleT, titleB; // Titre Haut - Bas
198
199};
200
201#endif
Note: See TracBrowser for help on using the repository browser.