3
Index: 3depict-0.0.16/src/backend/plot.cpp
4
===================================================================
5
--- 3depict-0.0.16.orig/src/backend/plot.cpp 2014-04-25 00:52:47.042185677 +0200
6
+++ 3depict-0.0.16/src/backend/plot.cpp 2014-04-25 00:52:47.038185728 +0200
8
// perform a little "push off" by this fudge factor
9
const float AXIS_MIN_TOLERANCE=10*sqrtf(std::numeric_limits<float>::epsilon());
11
-int MGLColourFixer::maxCols=-1;
12
+const unsigned int MGL_RESERVED_COLOURS=2;
14
-void MGLColourFixer::reset()
21
-char MGLColourFixer::haveExactColour(float r, float g, float b) const
23
- ASSERT(rs.size() == gs.size())
24
- ASSERT(gs.size() == bs.size())
26
- ASSERT(rs.size() <=getMaxColours());
28
- for(unsigned int ui=0; ui<rs.size(); ui++)
30
- if( fabs(r-rs[ui]) <std::numeric_limits<float>::epsilon()
31
- && fabs(g-gs[ui]) <std::numeric_limits<float>::epsilon()
32
- && fabs(b-bs[ui]) <std::numeric_limits<float>::epsilon())
33
- return mglColorIds[ui+1].id; //Add one to offset to avoid the reserved "k"
39
-unsigned int MGLColourFixer::getMaxColours()
41
- //Used cached value if available
45
- //The array is statically defined in
46
- //mgl/mgl_main.cpp, and must end with an id of zero.
48
- //this is not documented at all.
50
- while(mglColorIds[maxCols].id)
56
-char MGLColourFixer::getNextBestColour(float r, float g, float b)
58
- ASSERT(rs.size() == gs.size());
59
- ASSERT(gs.size() == bs.size());
62
- //As a special case, mgl has its own black
63
- if(r == 0.0f && g == 0.0f && b == 0.0f)
64
- return mglColorIds[0].id;
67
- unsigned int best=0;
68
- if(rs.size() == getMaxColours())
70
- ASSERT(getMaxColours());
71
- //Looks like we ran out of palette colours.
72
- //lets just give up and try to match this against our existing colours
74
- //TODO: let this modify the existing palette
75
- // to find a better match.
76
- float distanceSqr=std::numeric_limits<float>::max();
77
- for(unsigned int ui=0; ui<rs.size(); ui++)
82
- //3,4,2 weighted euclidean distance. Weights allow for closer human perception
83
- distanceTmp= 3.0*(rs[ui] - r )*(rs[ui] - r ) +4.0*(gs[ui] - g )*(gs[ui] - g )
84
- + 2.0*(bs[ui] - b )*(bs[ui] - b );
88
- //use alternate weighting for closer colour perception in "non-red" half of colour cube
89
- distanceTmp= 2.0*(rs[ui] - r )*(rs[ui] - r ) +4.0*(gs[ui] - g )*(gs[ui] - g )
90
- + 3.0*(bs[ui] - b )*(bs[ui] - b );
93
- if(distanceTmp < distanceSqr)
95
- distanceSqr = (distanceTmp);
96
- best=ui+1; //offset by 1 because mathgl colour 0 is special
104
- //Check to see if we don't already have this
105
- // no use wasting palette positions on existing
107
- exactMatch=haveExactColour(r,g,b);
112
- //Offset zero is special, for black things, like axes
114
- mglColorIds[best].col = mglColor(r,g,b);
121
- ASSERT(mglColorIds[best].id != 'k');
122
- return mglColorIds[best].id;
125
//Mathgl uses some internal for(float=...) constructions,
126
// which are just generally a bad idea, as they often won't terminate
131
+std::string mglColourCode(float r, float g, float b)
133
+ ASSERT(r >=0.0f && g >=0.0f && b >=0.0f)
134
+ ASSERT(r <=255.0f && g <=255.0f && b <=255.0f)
136
+ genColString((unsigned char)(r*255),
137
+ (unsigned char)(g*255),(unsigned char)(b*255),s);
140
+ return string("{x") + uppercase(s) + string("}");
143
//TODO: Refactor these functions to use a common string map
145
string plotString(unsigned int traceType)
149
//Un-fudger for mathgl plots
150
- MGLColourFixer colourFixer;
152
bool haveMultiTitles=false;
153
float minX,maxX,minY,maxY;
154
@@ -994,17 +895,15 @@
155
if(!curPlot->visible)
158
- curPlot->drawRegions(gr,colourFixer,min,max);
159
- curPlot->drawPlot(gr,colourFixer);
160
+ curPlot->drawRegions(gr,min,max);
161
+ curPlot->drawPlot(gr);
165
//Fake an mgl colour code
166
- char colourCode[2];
167
- colourCode[0]=colourFixer.getNextBestColour(
168
- curPlot->r,curPlot->g,curPlot->b);
169
- colourCode[1]='\0';
170
- gr->AddLegend(curPlot->title.c_str(),colourCode);
171
+ std::string mglColStr;
172
+ mglColStr= mglColourCode(curPlot->r,curPlot->g,curPlot->b);
173
+ gr->AddLegend(curPlot->title.c_str(),mglColStr.c_str());
178
vector<pair<size_t,size_t> > overlapId;
179
vector<pair<float,float> > overlapXCoords;
181
- char colourCode=colourFixer.getNextBestColour(1.0f,0.0f,0.0f);
182
+ string colourCode=mglColourCode(1.0f,0.0f,0.0f);
183
getRegionOverlaps(overlapId,overlapXCoords);
186
@@ -1045,10 +944,10 @@
189
gr->FaceZ(mglPoint(rMinX,rMinY,-1),rMaxX-rMinX,rMaxY-rMinY,
191
+ colourCode.c_str());
193
gr->FaceZ(rMinX,rMinY,-1,rMaxX-rMinX,rMaxY-rMinY,
195
+ colourCode.c_str());
203
- overlays.draw(gr,colourFixer,min,max,haveUsedLog);
204
+ overlays.draw(gr,min,max,haveUsedLog);
207
void PlotWrapper::hideAll()
208
@@ -1405,7 +1304,7 @@
209
return xValues.empty();
212
-void Plot1D::drawPlot(mglGraph *gr,MGLColourFixer &fixer) const
213
+void Plot1D::drawPlot(mglGraph *gr) const
217
@@ -1453,9 +1352,8 @@
219
//Obtain a colour code to use for the plot, based upon
220
// the actual colour we wish to use
221
- char colourCode[2];
222
- colourCode[0]=fixer.getNextBestColour(r,g,b);
223
- colourCode[1]='\0';
225
+ colourCode=mglColourCode(r,g,b);
229
@@ -1467,23 +1365,23 @@
230
//rather than linear interpolating them back along their paths. I have emailed the author.
231
//for now, we shall have to put up with missing lines :( Absolute worst case, I may have to draw them myself.
234
- gr->Plot(xDat,yDat,colourCode);
236
+ gr->Plot(xDat,yDat,colourCode.c_str());
238
- gr->Error(xDat,yDat,eDat,colourCode);
239
+ gr->Error(xDat,yDat,eDat,colourCode.c_str());
242
case PLOT_TRACE_BARS:
243
- gr->Bars(xDat,yDat,colourCode);
244
+ gr->Bars(xDat,yDat,colourCode.c_str());
246
case PLOT_TRACE_STEPS:
247
//Same problem as for line plot.
249
- gr->Step(xDat,yDat,colourCode);
250
+ gr->Step(xDat,yDat,colourCode.c_str());
253
case PLOT_TRACE_STEM:
254
- gr->Stem(xDat,yDat,colourCode);
255
+ gr->Stem(xDat,yDat,colourCode.c_str());
258
case PLOT_TRACE_POINTS:
259
@@ -1557,13 +1455,11 @@
263
-void Plot1D::drawRegions(mglGraph *gr,MGLColourFixer &fixer,
264
+void Plot1D::drawRegions(mglGraph *gr,
265
const mglPoint &min,const mglPoint &max) const
267
//Mathgl palette colour name
268
- char colourCode[2];
269
- colourCode[1]='\0';
273
for(unsigned int uj=0;uj<regionGroup.regions.size();uj++)
275
@@ -1577,16 +1473,15 @@
276
//Prevent drawing inverted regionGroup.regions
277
if(rMaxX > rMinX && rMaxY > rMinY)
279
- colourCode[0] = fixer.getNextBestColour(regionGroup.regions[uj].r,
280
+ colourCode = mglColourCode(regionGroup.regions[uj].r,
281
regionGroup.regions[uj].g,
282
regionGroup.regions[uj].b);
283
- colourCode[1] = '\0';
285
gr->FaceZ(mglPoint(rMinX,rMinY,-1),rMaxX-rMinX,rMaxY-rMinY,
287
+ colourCode.c_str());
289
gr->FaceZ(rMinX,rMinY,-1,rMaxX-rMinX,rMaxY-rMinY,
291
+ colourCode.c_str());
295
@@ -1791,18 +1686,17 @@
299
-void PlotOverlays::draw(mglGraph *gr,MGLColourFixer &fixer,
300
+void PlotOverlays::draw(mglGraph *gr,
301
const mglPoint &boundMin, const mglPoint &boundMax,bool logMode ) const
307
- char colourCode[2];
310
//Draw the overlays in black
311
- colourCode[0] = fixer.getNextBestColour(0.0,0.0,0.0);
312
- colourCode[1]='\0';
313
+ colourCode = mglColourCode(0.0,0.0,0.0);
315
for(size_t ui=0;ui<overlayData.size();ui++)
317
@@ -1841,6 +1735,7 @@
321
+ //TODO: Deprecate me. Upstream now allows single stems
322
//Draw stems. can't use stem plot due to mathgl bug whereby single stems
324
for(size_t uj=0;uj<overlayData[ui].coordData.size();uj++)
325
@@ -1849,7 +1744,7 @@
326
boundMin.y < bufY[uj])
328
gr->Line (mglPoint(bufX[uj],std::max(0.0f,(float)boundMin.y)),
329
- mglPoint(bufX[uj],bufY[uj]),colourCode,100);
330
+ mglPoint(bufX[uj],bufY[uj]),colourCode.c_str(),100);
332
//Print labels near to the text
333
const float STANDOFF_FACTOR=1.05;
334
Index: 3depict-0.0.16/src/backend/plot.h
335
===================================================================
336
--- 3depict-0.0.16.orig/src/backend/plot.h 2014-04-25 00:52:47.042185677 +0200
337
+++ 3depict-0.0.16/src/backend/plot.h 2014-04-25 00:52:47.038185728 +0200
339
//!Return the error mode type, given the human readable string
340
unsigned int plotErrmodeID(const std::string &s);
342
-//!Nasty hack class to change mathgl API from named char palette to rgb specification
343
-class MGLColourFixer
346
- vector<float> rs,gs,bs;
347
- static int maxCols;
349
- //Restore the MGL colour strings
351
- //Return the exact colour, if there is one
352
- char haveExactColour(float r, float g, float b) const;
353
- //Get the best colour that is available
354
- // returns the char to give to mathgl; may be exact,
355
- // maybe nearest match, depending upon number of colours used
356
- // and mgl palette size
357
- char getNextBestColour(float r, float g, float b);
359
- static unsigned int getMaxColours();
363
//!Data class for holding info about non-overlapping
364
// interactive rectilinear "zones" overlaid on plots
366
//Add a new overlay to the plot
367
void add(const OVERLAY_DATA &overlay) {overlayData.push_back(overlay);}
368
//Draw the overlay on the current plot
369
- void draw(mglGraph *g,MGLColourFixer &fixer,
370
+ void draw(mglGraph *g,
371
const mglPoint &boundMin, const mglPoint &boundMax,bool logMode) const;
372
//Enable the specified overlay
373
void setEnabled(size_t offset,bool isEnabled)
375
virtual bool empty() const=0;
377
//Draw the plot onto a given MGL graph
378
- virtual void drawPlot(mglGraph *graph, MGLColourFixer &fixer) const=0;
379
+ virtual void drawPlot(mglGraph *graph) const=0;
381
//!Scan for the data bounds.
382
virtual void getBounds(float &xMin,float &xMax,
383
@@ -309,11 +289,10 @@
386
//Draw the plot onto a given MGL graph
387
- virtual void drawPlot(mglGraph *graph,MGLColourFixer &fixer) const;
388
+ virtual void drawPlot(mglGraph *graph) const;
390
//Draw the associated regions
391
- void drawRegions(mglGraph *graph, MGLColourFixer &fixer,
392
- const mglPoint &min, const mglPoint &max) const;
393
+ void drawRegions(mglGraph *graph,const mglPoint &min, const mglPoint &max) const;
396
//!Retrieve the raw data associated with the currently visible plots.
397
Index: 3depict-0.0.16/src/common/stringFuncs.cpp
398
===================================================================
399
--- 3depict-0.0.16.orig/src/common/stringFuncs.cpp 2014-04-25 00:52:47.042185677 +0200
400
+++ 3depict-0.0.16/src/common/stringFuncs.cpp 2014-04-25 00:52:47.038185728 +0200
405
+std::string uppercase(std::string s)
407
+ for(unsigned int ui=0;ui<s.size();ui++)
409
+ if(isascii(s[ui]) && islower(s[ui]))
410
+ s[ui] = toupper(s[ui]);
415
//Split strings around a delimiter
416
void splitStrsRef(const char *cpStr, const char delim,std::vector<string> &v )
418
Index: 3depict-0.0.16/src/common/stringFuncs.h
419
===================================================================
420
--- 3depict-0.0.16.orig/src/common/stringFuncs.h 2014-04-25 00:52:47.042185677 +0200
421
+++ 3depict-0.0.16/src/common/stringFuncs.h 2014-04-25 00:52:47.038185728 +0200
423
std::string stripChars(const std::string &Str, const char *chars);
424
//!Return a lowercase version for a given string
425
std::string lowercase(std::string s);
426
+//!Return a uppercase version for a given string
427
+std::string uppercase(std::string s);
429
//Drop empty entries from a string of vector
430
void stripZeroEntries(std::vector<std::string> &s);
432
unsigned char &r, unsigned char &g, unsigned char &b, unsigned char &a);
434
//Convert an RGBA 8-bit/channel quadruplet into its hexadecimal colour string
435
+// format is "#rrggbbaa" such as "#11ee00aa"
436
void genColString(unsigned char r, unsigned char g,
437
unsigned char b, unsigned char a, std::string &s);
438
//Convert an RGB 8-bit/channel quadruplet into its hexadecimal colour string
439
+// format is "#rrggbb" such as "#11ee00"
440
void genColString(unsigned char r, unsigned char g,
441
unsigned char b, std::string &s);
443
Index: 3depict-0.0.16/src/gui/dialogs/rangeEditDialog.cpp
444
===================================================================
445
--- 3depict-0.0.16.orig/src/gui/dialogs/rangeEditDialog.cpp 2014-04-25 00:52:47.042185677 +0200
446
+++ 3depict-0.0.16/src/gui/dialogs/rangeEditDialog.cpp 2014-04-25 00:52:47.038185728 +0200
448
EVT_CHECKLISTBOX(ID_LIST_OVERLAY, RangeEditorDialog::OnListOverlayCheck)
449
EVT_BUTTON(wxID_OK, RangeEditorDialog::OnBtnOK)
450
EVT_BUTTON(wxID_CANCEL, RangeEditorDialog::OnBtnCancel)
451
- EVT_SPLITTER_UNSPLIT(ID_SPLIT_LEFTRIGHT, RangeEditorDialog::OnSashVerticalUnsplit)
452
+ EVT_SPLITTER_DCLICK(ID_SPLIT_LEFTRIGHT, RangeEditorDialog::OnSashVerticalDClick)
456
@@ -1438,7 +1438,7 @@
457
plotPanel->Refresh();
460
-void RangeEditorDialog::OnSashVerticalUnsplit(wxSplitterEvent &event)
461
+void RangeEditorDialog::OnSashVerticalDClick(wxSplitterEvent &event)
465
Index: 3depict-0.0.16/src/gui/dialogs/rangeEditDialog.h
466
===================================================================
467
--- 3depict-0.0.16.orig/src/gui/dialogs/rangeEditDialog.h 2014-04-25 00:52:47.042185677 +0200
468
+++ 3depict-0.0.16/src/gui/dialogs/rangeEditDialog.h 2014-04-25 00:52:47.038185728 +0200
470
virtual void OnCheckShowOverlay(wxCommandEvent &event); // wxGlade: <event_handler>
471
virtual void OnBtnOK(wxCommandEvent &event); // wxGlade: <event_handler>
472
virtual void OnBtnCancel(wxCommandEvent &event); // wxGlade: <event_handler>
473
- virtual void OnSashVerticalUnsplit(wxSplitterEvent &event); // wxGlade: <event_handler>
474
+ virtual void OnSashVerticalDClick(wxSplitterEvent &event); // wxGlade: <event_handler>
475
virtual void OnListOverlayCheck(wxCommandEvent &event);
476
virtual void OnListOverlayKeyDown(wxListEvent &event);
477
virtual void OnTextOverlay(wxCommandEvent &event);
478
Index: 3depict-0.0.16/src/gui/mainFrame.cpp
479
===================================================================
480
--- 3depict-0.0.16.orig/src/gui/mainFrame.cpp 2014-04-25 00:52:47.042185677 +0200
481
+++ 3depict-0.0.16/src/gui/mainFrame.cpp 2014-04-25 00:52:47.038185728 +0200
482
@@ -1143,9 +1143,12 @@
483
f->setRangeData(rng);
484
f->setRangeFilename(s.c_str());
486
- //Get the parent filter pointer
487
+ //Add the filter, using the seelcted
488
+ // item as the parent
489
visControl.addFilter(f,false,filterId);
491
+ //update the tree control
492
+ visControl.updateWxTreeCtrl(treeFilters);
496
@@ -1398,6 +1401,10 @@
501
+ //make sure camera is properly centred
502
+ if(visControl.numCams() == 1)
503
+ visControl.ensureSceneVisible(3);
507
--- 3depict-0.0.16.orig/src/common/basics.cpp
508
+++ 3depict-0.0.16/src/common/basics.cpp
509
@@ -1115,6 +1115,28 @@ unsigned int loadTextStringData(const ch
513
+//FIXME: Why negative?
514
+bool isNotDirectory(const char *filename)
516
+#if !defined(__WIN32__) && !defined(__WIN64__)
517
+ struct stat statbuf;
519
+ if(stat(filename,&statbuf) == -1)
522
+ return (statbuf.st_mode !=S_IFDIR);
525
+ WARN(false, "Untested function. calling win api");
527
+ fileAttribs=GetFileAttributes((LPCWSTR)filename);
528
+ if(fileAttribs == INVALID_FILE_ATTRIBUTES)
531
+ return !(fileAttribs & FILE_ATTRIBUTE_DIRECTORY);
536
bool isValidXML(const char *filename)
538
@@ -1147,29 +1169,6 @@ bool isValidXML(const char *filename)
543
-//FIXME: Why negative?
544
-bool isNotDirectory(const char *filename)
546
-#if !defined(__WIN32__) && !defined(__WIN64__)
547
- struct stat statbuf;
549
- if(stat(filename,&statbuf) == -1)
552
- return (statbuf.st_mode !=S_IFDIR);
555
- WARN(false, "Untested function. calling win api");
557
- fileAttribs=GetFileAttributes((LPCWSTR)filename);
558
- if(fileAttribs == INVALID_FILE_ATTRIBUTES)
561
- return !(fileAttribs & FILE_ATTRIBUTE_DIRECTORY);
565
bool rmFile(const std::string &filename)
567
#if !defined(__WIN32__) && !defined(__WIN64__)