OOFILE  1.9
oofPlBit.cpp
Go to the documentation of this file.
1 // COPYRIGHT 1996 A.D. Software, All rights reserved
2 
3 // =================================================================================
4 // oofPlBit.cp
5 // =================================================================================
6 
7 #include "oofpch_g.h" // for precompilation of graph files
8 
9 #ifndef H_OOFRECT
10  #include "oofRect.h"
11 #endif
12 #ifndef H_OOFPLBIT
13  #include "oofPlBit.h"
14 #endif
15 
16 #ifdef OOF_MEM_DEBUG_LAST_INCLUDE
17  #include OOF_MEM_DEBUG_LAST_INCLUDE
18 #endif
19 
20 #ifndef OOF_NO_STDLIB
21  #ifndef std
22  using namespace std;
23  #endif
24 #endif
25 
26 // ---------------------------------------------------------------------------------
27 // oofPlotBitsItem
28 // ---------------------------------------------------------------------------------
29 
30 
32  : mNext(0), mItem(inItem)
33 {
34 }
35 
36 
38 {
39  delete mItem; // oofPlotBitsItem owns the oofGeo
40 }
41 
42 
45 {
46  return mNext;
47 }
48 
49 
50 oofGeo*
52 {
53  return mItem;
54 }
55 
56 
57 void
59 {
60  mNext = inItem;
61 }
62 
63 
64 // ---------------------------------------------------------------------------------
65 // oofPlotBits
66 // ---------------------------------------------------------------------------------
67 
69  : mCount(0),
70  mFirst(0),
71  mLast(0)
72 {
73  oofRect initialPaneRect(0,0,100,100);
74  setPaneRect(initialPaneRect); // to stop div by zero, caused by transforming before pane set before pane set
75 
76 }
77 
78 
80 {
81  while (mCount)
82  remove();
83 }
84 
85 
86 void
88 {
89  // Add the GEO to the list
90  oofPlotBitsItem *theItem = new oofPlotBitsItem(inItem);
91 
92  if (isEmpty()) { // list is empty
93  mFirst = theItem;
94  mLast = theItem;
95  }
96  else { // else put it after last
97  mLast->setNext(theItem);
98  mLast = theItem;
99  }
100  mCount++;
101 
102  // Grow the IdealRect to fit this item
106  switch (inItem->Position()) {
107  case oofGeo::posNone:{
109  mTransformationManager.ExpandToInclude(R.right,R.bottom);
110  }
111  break;
112  case oofGeo::posTop:{
113 
114 // These are commented out since this stuff is all hacked into the
115 // objects for now - I'll need to make a manager for this !
116 
117 /* // NOTE: In this case, we'll have a oofRect in Draw Coords.
118  M.top+=(R.bottom-R.top);
119  // Modify the margins
120  mTransformationManager.setMargins(M);
121  // set the location of the geo
122  inItem->SetLocation(0,(R.bottom-R.top));
123 */ }
124  break;
125 
126  case oofGeo::posBottom:{
127  // NOTE: In this case, we'll have a oofRect in Draw Coords.
128 /* M.bottom+=(R.bottom-R.top);
129  mTransformationManager.setMargins(M);
130  // set the location of the geo
131  int dx,dy;
132  mTransformationManager.TransformPoint(0,I.bottom,dx,dy);
133  inItem->SetLocation(0,dy+(R.bottom-R.top));
134 */ }
135  break;
136  case oofGeo::posBelow:{
137  }
138  break;
139  case oofGeo::posLeft:{
140  // NOTE: In this case, we'll have a oofRect in Draw Coords.
141  M.left += R.width();
143  inItem->setLocation(0, I.height() / 2 + I.bottom);
144  }
145  break;
146  case oofGeo::posRight:{
147  // NOTE: In this case, we'll have a oofRect in Draw Coords.
148  M.right += R.width();
150  int Mx,My;
151  mTransformationManager.TransformPoint(I.right,0,Mx,My);
152  inItem->setLocation(Mx, I.height() / 2 + I.bottom);
153  }
154  break;
155  default: ; // FixMe
156  }
157 
158 }
159 
160 
161 void
163 {
164  if (isEmpty())
165  return;
166 
167  oofPlotBitsItem *theItem = mFirst;
168  oofGeo *theGeo = mFirst->item();
169 
170  if (mFirst == mLast) { // list had one item, now has none
171  mFirst = 0;
172  mLast = 0;
173  } else {
174  mFirst = theItem->next();
175  }
176 
177  mCount--;
178 
179  delete theItem;
180 }
181 
182 
185 {
186  return mFirst; // return first element
187 }
188 
189 
190 bool
192 {
193  return (mCount==0); // is the list empty?
194 }
195 
196 
197 unsigned long
199 {
200  return mCount; // Return the number of items
201 }
202 
203 
204 void
206 {
207  // do any setup here
208  DrawSelf();
209 }
210 
211 
212 void
213 oofPlotBits::describe(ostream& os) const
214 {
215  // do any setup here
216  DescribeSelf(os);
217 }
218 
219 
220 void
222 {
224 }
225 
226 
227 void
229 {
231 }
232 
233 
234 oofRect&
236 {
238 }
239 
240 
241 void
243 {
244  if(mTransformationManager.isDirty()) { // Do we need to transform ?
245 
246 
247 #ifdef OOF_GRAPH_DEBUG_DUMP
248  // this debug stream monitors impact of final tranformation
249  ofstream debugStream("DrawsSelfState",ios::app);
250  int passIndex = 0;
251 #endif
253  mTransformationManager.setToClean(); // Mark us as clean and make sure we stay that way !
254  // The reason for this is that some of our GEO's
255  // may resize the DrawRect because of margin stuff !
256  for(oofPlotBitsItem *theItem=first();theItem;theItem=theItem->next()) {
257  oofGeo* theGeo=theItem->item();
258 #ifdef OOF_GRAPH_DEBUG_DUMP
259  mTransformationManager.describe(debugStream); // david debug
260  theGeo->describe(debugStream);
261 #endif
262 
263  theGeo->Transform( &mTransformationManager );
264 
265 #ifdef OOF_GRAPH_DEBUG_DUMP
266  mTransformationManager.describe(debugStream);
267  theGeo->describe(debugStream);// david debug 990804
268 #endif
269 
270  }
271 
272 #ifdef OOF_GRAPH_DEBUG_DUMP
273  debugStream << endl << endl;
274  debugStream << " transformation pass: "<< passIndex << endl;
275  passIndex++;// david debug
276 
277 #endif
278  }
279 #ifdef OOF_GRAPH_DEBUG_DUMP
280  debugStream << "---oofplot bits fully transformed----" << endl << endl << endl;
281  debugStream.close();
282 #endif
283 
284  }
285  for(oofPlotBitsItem *theItem=first();theItem;theItem=theItem->next()) {
286  oofGeo* theGeo=theItem->item();
287  theGeo->draw();
288  }
289 #if defined(TARGET_API_MAC_CARBON) && TARGET_API_MAC_CARBON!=0
290  QDFlushPortBuffer( GetQDGlobalsThePort(), NULL );
291 #endif
292 }
293 
294 
295 void
296 oofPlotBits::DescribeSelf(ostream& os) const
297 {
298  for(oofPlotBitsItem *theItem=first();theItem;theItem=theItem->next()) {
299  oofGeo* theGeo=theItem->item();
300  theGeo->describe(os);
301  }
302 }
virtual void Transform(oofTransformationManager *inTransformationManagerPtr)=0
virtual void DescribeSelf(std::ostream &os) const
Definition: oofPlBit.cpp:296
Cross-platform way to specify rectangle with Mac-style setter.
Definition: oofRect.h:39
virtual void TransformPoint(int idealX, int idealY, int &drawX, int &drawY)
Definition: oofTrMgr.cpp:232
virtual void setMargins(oofRect &inRect)
Definition: oofTrMgr.cpp:149
oofPlotBitsItem * mLast
Definition: oofPlBit.h:69
virtual oofRect getMargins()
Definition: oofTrMgr.cpp:138
oofTransformationManager mTransformationManager
Definition: oofPlBit.h:65
oofPlotBitsItem(oofGeo *inItem)
Definition: oofPlBit.cpp:31
void describe(std::ostream &os) const
Definition: oofPlBit.cpp:213
void draw()
Definition: oofPlBit.cpp:205
oofPlotBitsItem * mFirst
Definition: oofPlBit.h:67
oofRect & getIdealRect()
Definition: oofPlBit.cpp:235
virtual void describe(std::ostream &) const
Definition: oofGeos.cpp:102
Single item in an oofPlotBits to track one oofGeo.
Definition: oofPlBit.h:18
int width()
Definition: oofRect.h:71
bool isEmpty()
Definition: oofPlBit.cpp:191
virtual void ExpandToInclude(long x, long y)
Definition: oofTrMgr.cpp:85
oofPlotBitsItem * first() const
Definition: oofPlBit.cpp:184
virtual void setIdealRect(oofRect &inRect)
Definition: oofTrMgr.cpp:71
virtual void describe(std::ostream &os) const
Definition: oofTrMgr.cpp:340
PositionState Position()
Definition: oofGeos.h:51
void setPaneRect(oofRect &inRect)
Definition: oofPlBit.cpp:228
void draw()
Definition: oofGeos.cpp:83
void append(oofGeo *inItem)
Definition: oofPlBit.cpp:87
virtual void setLocation(long inXIdeal, long inYIdeal)
Definition: oofGeos.cpp:75
virtual oofRect & getIdealRect()
Definition: oofTrMgr.cpp:127
int height()
Definition: oofRect.h:73
Graph Element Object drawn in an oofGraph.
Definition: oofGeos.h:43
unsigned long mCount
Definition: oofPlBit.h:66
void setIdealRect(oofRect &inRect)
Definition: oofPlBit.cpp:221
virtual void setPaneRect(oofRect &inRect)
Definition: oofTrMgr.cpp:112
virtual oofRect BoundingRect(oofTransformationManager *)
Definition: oofGeos.cpp:117
oofPlotBitsItem * next()
Definition: oofPlBit.cpp:44
virtual ~oofPlotBits()
Definition: oofPlBit.cpp:79
oofGeo * item()
Definition: oofPlBit.cpp:51
bool isDirty() const
Definition: oofTrMgr.cpp:212
unsigned long count()
Definition: oofPlBit.cpp:198
void setNext(oofPlotBitsItem *)
Definition: oofPlBit.cpp:58
virtual void DrawSelf()
Definition: oofPlBit.cpp:242
void remove()
Definition: oofPlBit.cpp:162