MorphoGraphX  2.0-1-227
ImageData.hpp
Go to the documentation of this file.
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2015 Richard S. Smith and collaborators.
4 //
5 // If you use MorphoGraphX in your work, please cite:
6 // http://dx.doi.org/10.7554/eLife.05864
7 //
8 // MorphoGraphX is free software, and is licensed under under the terms of the
9 // GNU General (GPL) Public License version 2.0, http://www.gnu.org/licenses.
10 //
11 #ifndef IMAGE_DATA_H
12 #define IMAGE_DATA_H
13 
14 #include <Config.hpp>
15 
16 #include <ClipRegion.hpp>
17 #include <ColorBar.hpp>
18 #include <Colors.hpp>
19 #include <ColorMap.hpp>
20 #include <Geometry.hpp>
21 #include <Mesh.hpp>
22 #include <MGXViewer/qglviewer.h>
23 #include <Misc.hpp>
24 #include <Parms.hpp>
25 #include <Process.hpp>
26 #include <ScaleBar.hpp>
27 #include <Shader.hpp>
28 #include <TransferFunction.hpp>
29 #include <ColorEditDlg.hpp>
30 #include <GraphUtils.hpp>
31 #include <string>
32 #include <string.h>
33 
34 #include <CImg.h>
35 
36 
37 namespace mgx
38 {
39  class CutSurf;
41 
42  typedef Vector<4, vertex> Point4v;
44 
45  class mgx_EXPORT ImgData : public QObject
46  {
47  Q_OBJECT
48  public:
49  static const uint RELOAD_NONE = 0x0;
50  static const uint RELOAD_MAIN = 0x1;
51  static const uint RELOAD_WORK = 0x2;
52  static const uint RELOAD_TRIS = 0x4;
53  static const uint RELOAD_LINES = 0x8;
54  static const uint RELOAD_POS = 0x10;
55  static const uint RELOAD_VBO = 0x20;
56  static const uint UPDATE_SELECTION = 0x40;
57 
58  int StackId;
59 
62 
63  // Main and stack paramters
64  bool Main16Bit, Work16Bit;
65 
66  // General
68  TransferFunctionDlg* workTransferDlg, *mainTransferDlg, *surfTransferDlg, *heatTransferDlg;
69  // Function defining the color of the pixels
70  std::vector<TransferFunction::Colorf> MainColorMap; // Color map for the main data
71  std::vector<TransferFunction::Colorf> WorkColorMap; // Color map for the work data
72  std::vector<TransferFunction::Colorf> SurfColorMap; // Color map for the surface
73  std::vector<TransferFunction::Colorf> HeatColorMap; // Color map for the heatmap
74  // If true, a new texture need to be sent for the colormap
75  bool newMainColorMap, newWorkColorMap, newSurfColorMap, newHeatColorMap;
76  std::vector<double> MainHist; // Histogram of the main data
77  std::vector<double> WorkHist; // Histogram of the working data
78  std::vector<double> SurfHist; // Histogram of the surface data
79  std::vector<double> HeatHist; // Histogram of the surface data
80  std::pair<double, double> mainBounds;
81  std::pair<double, double> workBounds;
82 
83  GLuint mainDataTexId; // 3D texture Id for main stack
84  GLuint workDataTexId; // 3D texture Id for work stack
85  GLuint dataTexColor; // 3D texture color
86  GLuint surfTexId; // 1D texture map for surface colors.
87  GLuint heatTexId; // 1D texture map for heatmap colors.
88  GLuint colorMapTexId; // 1D texture map for colormaps
89  GLuint imgTexId; // 2D texture map for surface from an image
90  GLuint mcmapTexId, wcmapTexId; // 1D texture map for volume colors.
91  GLuint labelTexId; // 1D texture map to color indexed texture for labels
92  vertex_identity_t lineId; // Last id when drawing lines
93  VtxVec selectV; // List of selected vertices
94 
95  GLuint selFboId; // ID of selection buffer;
96  GLuint selFboColor; // Texture for colors
97  GLuint selFboDepth; // Texture for depth
98 
101  // Colors::ColorType MeshPointColor;
103 
104  // Helper arrays for vertex buffer obejects
105  std::vector<vertex> idVA; // Vertex ids
106  std::vector<cell> triCell; // Cell list to go with triangles for 3D cells
107 
108  // VBO arrays
109  std::vector<Point3f> posVA; // Vertex positions
110  std::vector<Point3f> nrmlVA; // Vertex normals
111  std::vector<Point3GLub> selVA; // Unique colors for triangle selection
112  std::vector<Point3f> texVA; // Mesh labels, signal, and heat
113  std::vector<Point2f> imgVA; // Image texture coordinates
114  std::vector<Colorb> triangleColorVA;
115  std::vector<Colorb> cellColorVA; // Array for cell colors
116 
117  std::vector<Point3f> pntsVA; // Vertices for drawing points
118  std::vector<Point3GLub> pcolVA; // Colors for points
119  std::vector<uint> pbrdVA; // Indices for drawing border points
120  std::vector<uint> pcellVA; // Indices for drawing cell border points
121  std::vector<uint> pselVA; // Indices for drawing selected points
122 
123  std::vector<uint> lineVA; // Indices for drawing lines
124  std::vector<uint> lbrdVA; // Indices for drawing border lines
125  std::vector<uint> lcellVA; // Indices for drawing cell border lines
126  std::vector<uint> lselVA; // Indices for drawing selected lines
127 
128  std::vector<Point3f> cellGraphPosVA; // Cell graph centers
129  std::vector<Point3GLub> cellGraphColorVA; // Cell Graph colors for centers
130  std::vector<uint> cellGraphPointVA; // Indices for drawing cell centers
131  std::vector<uint> cellGraphLineVA; // Indices for drawing lines that connect cell centers
132 
133  std::vector<Point3f> axisPosVA;
134  std::vector<Point3GLub> axisColorVA;
135 
136  GLuint posVAid; // VBO object ids
137  GLuint nrmlVAid;
138  GLuint selVAid;
139  GLuint texVAid;
140  GLuint imgVAid;
143 
144  GLuint pntsVAid;
145  GLuint pcolVAid;
146  GLuint pselVAid;
147 
150 
151  GLuint axisPosVAid;
153 
154  GLubyte* texMap; // Texture map to memory
155 
156  // Parameters from stack file
157  QString Section;
158  std::vector<QString> ImageFiles;
159 
160  QWidget* parent; // Parent widget
161  float min, max;
162 
163  // Vectors to make heat maps
166  QString sigStr; // Description of heat map
167  Point3u clipDo; // Which clipping planes are selected
168  Point4f pn[6]; // Clip planes tranformed into frame coordinates
169  HVec4F Hpn; // Host vector for planes for cuda
170  Matrix4d frm; // Frame matrix
171  Matrix4d clm[3]; // Clip plane matrices
172  float pixelRadius; // Radius in frame coordinates of pixel edit tool
173  BoundingBox3f bBox; // Bounding box
174  BoundingBox3i bBoxTex; // Bounding box for texture update
175  int marchLabel; // Label for maching cubes on segmented stack
176 
177  float meshShift; // Shift for the mesh, relative to the scene radius
178 
179  // Variables to marching cubes (for eval)
181 
182  // Parameters shared by all instances
183  static int ClearColor;
184  static uint Slices;
185  static uint TileCount;
187  static float SurfOffset;
188 
189  static float DrawNormals;
190  static float DrawOffset;
191  static float DrawZeroLabels;
192  static float DrawNhbds;
193  static bool DeleteBadVertex;
194  static bool FillWorkData;
195  static bool SeedStack;
196  static int VoxelEditRadius;
197  static int VoxelEditMaxPix;
198  static std::vector<Colorf> LabelColors;
200 
201  static bool MeshSelect;
204 
205  static float MeshPointSize;
206  static float MeshLineWidth;
207 
208  bool changed; // Has the stack (mesh) changed
209  bool pixelsChanged; // Changed flag for pixel editing
210 
211  public:
212  ImgData(int id, QWidget* _parent = 0);
213 
214  ~ImgData();
215 
216  void init(Stack* s, Mesh* m);
217 
218  // Set the internal format of the data
219  void setWork16Bit(bool val);
220  void setMain16Bit(bool val);
221 
222  // Set parameters for function
223  void readParms(Parms& parms, QString section);
224 
225  // Set parameters for function
226  void writeParms(QTextStream& pout, QString section);
227 
228  // Get the frame with or without additional transform
230 
231  // Get the main frame
233 
234  // Get the transform frame
236 
237  // Marching cubes evaluation function
238  int eval(Point3f p);
239 
240  // Draw stack data
241  void drawStack(Shader* shader);
242 
243  // Set the file containing the current color map
244  void setColorMap(const QString& pth, bool work);
245 
246  // Update heat histogram
247  void updateHeatHistogram();
248  // Update surface histogram
249  void updateSurfHistogram();
250  // Update work histogram
251  void updateWorkHistogram();
252  // Update main histogram
253  void updateMainHistogram();
254 
255  // Edit the transfer function
256  void editMainTransferFunction();
257  void editWorkTransferFunction();
258  void editSurfTransferFunction();
259  void editHeatTransferFunction();
260 
261  // Update the color map texture
263  {
264  updateColorMap(newSurfColorMap, SurfColorMap, mesh->surfFct());
265  }
267  {
268  updateColorMap(newHeatColorMap, HeatColorMap, mesh->heatFct());
269  }
271  {
272  updateColorMap(newWorkColorMap, WorkColorMap, stack->work()->transferFct());
273  }
275  {
276  updateColorMap(newMainColorMap, MainColorMap, stack->main()->transferFct());
277  }
278  void updateColorMap(bool& newColorMap, std::vector<TransferFunction::Colorf>& ColorMap,
279  const TransferFunction& transferFct);
280 
281  // Setup color map to use in draw
283  {
284  setupColorMap(newSurfColorMap, surfTexId, SurfColorMap, Shader::AT_SURF_TEX);
285  }
287  {
288  setupColorMap(newHeatColorMap, heatTexId, HeatColorMap, Shader::AT_HEAT_TEX);
289  }
291  {
292  setupColorMap(newMainColorMap, mcmapTexId, MainColorMap, Shader::AT_CMAP_TEX);
293  }
295  {
296  setupColorMap(newMainColorMap, mcmapTexId, MainColorMap, Shader::AT_SECOND_CMAP_TEX);
297  }
299  {
300  setupColorMap(newWorkColorMap, wcmapTexId, WorkColorMap, Shader::AT_CMAP_TEX);
301  }
303  {
304  setupColorMap(newWorkColorMap, wcmapTexId, WorkColorMap, Shader::AT_SECOND_CMAP_TEX);
305  }
307  {
308  std::vector<TransferFunction::Colorf> empty;
309  bool nonew = false;
310  setupColorMap(nonew, labelTexId, empty, Shader::AT_LABEL_TEX);
311  }
312  void setupColorMap(bool& newColorMap, GLuint& cmapTexId,
313  const std::vector<TransferFunction::Colorf>& ColorMap, Shader::ActiveTextures activeTex);
314 
315  // Setup a 1D texture from a color map vector
316  bool setupTexFromColorMap(GLuint &texId, const ColorbVec &colorVec);
317 
318  // Draw mesh wireframe
319  void drawMesh();
320 
321  // Draw lines joining corresponding vertices
322  void drawVertexVertexLine(ImgData* stack);
323 
324  // Draw cell axis
325  void drawAxis();
326 
327  // Draw Bounding Box around the stack
328  void drawBBox();
329 
330  // Setup the uniforms and textures to render 3D data
331  void setup3DRenderingData(Shader* shader);
332 
333  // Draw mesh shaded
334  // - select renders unique colors in select frame buffer
335  // - optionally pass shaders (not needed for select mode)
336  void drawSurf(bool select, Shader* textureShader = 0, Shader* labelShader = 0,
337  Shader *colorShader = 0, Shader* volumeShader = 0);
338 
340  {
341  return mesh->showSurface() and !mesh->blending();
342  }
343 
345  {
346  return mesh->showSurface() && mesh->blending() && (mesh->opacity() > 0.0);
347  }
348 
349  void setupVolumeShader(Shader& shader, int pos);
350 
351  // Setup data for clipping test
352  void getClipTestData(ClipRegion& clip1, ClipRegion& clip2, ClipRegion& clip3);
353 
354  // Test if a point (in image coordinates) is inside clipping planes
355  bool clipTest(const Point3i& ip);
356 
357  // Reset stack data
358  void resetStack();
359 
360  // Reset mesh data
361  void resetMesh();
362 
363  // Initialize controls
364  void initControls(QWidget* viewer);
365 
366  // Texture management
367  void unloadTex();
368  void loadTex();
369  void reloadLabelTex();
370  void reloadMainTex(const BoundingBox3i& bbox = BoundingBox3i());
371  void reloadWorkTex(const BoundingBox3i& bbox = BoundingBox3i());
372  void reloadTex(GLuint texId);
373  void updateTex(GLuint texId, BoundingBox3i bBox);
374  void initTex();
375  void bind3DTex(GLuint texId, Shader::ActiveTextures atexId = Shader::AT_TEX3D);
376  void bind2DTex(GLuint texId);
377  void unbind3DTex();
378  void unbind2DTex();
379  void loadImgTex(const QImage& image);
380 
381  // Fill selected color with current label (bucket icon)
382  void fillLabel(const IntSet &label, int currlabel);
383 
384  // Set parent label
385  void setParent(int label, int parentLabel);
386  void setParent(const IntSet &labels, int parentLabel);
387 
388  // Select the vertices for given label
389  void selectLabel(int label, int repeat = 0);
390  void selectLabel(const IntSet &labels);
391 
392  // Unselect the vertices for given label
393  void unselectLabel(const IntSet &labels);
394 
395  // Select the vertices for given parent
396  void selectParent(int label, int repeat = 0);
397  void selectParent(const IntSet &labels);
398 
399  // Unselect the vertices for given parent
400  void unselectParent(const IntSet &parents);
401 
402  // Select connected vertices
403  void selectConnected(std::vector<uint>& vlist, bool unselect);
404 
405  // Select vertices
406  void selectVertices(std::vector<uint>& vlist, bool unselect);
407 
408  // Put label on a list of vertices (a triangle)
409  void addSeed(int label, std::vector<uint>& vlist);
410 
411  // Fill selection with current
412  void fillSelect(int label);
413 
414  // Delete selected vertices
415  void deleteLabel(int label);
416 
417  // Update points, set save ids, and count triangles for VBOs
418  void updatePoints(uint &VCount, uint &LCount, uint &TCount);
419 
420  // Update only the position for points and lines
421  void updatePos();
422 
423  // Search through the mesh and increase the next label if required
424  void updateNextLabel();
425 
426  // Update triangle texture coords
427  void updateTriColor();
428 
429  // Update points and lines and the selection
430  void updateLines();
431 
432  // Update positions
433  void updateTriPos();
434 
435  // Update the colors for selection
436  void updateSelectTris();
437 
438  // Update the texture for height map (Keyence) data
439  void updateImageTex2d();
440 
441  // Update the cell graph
442  void updateCellGraph();
443 
444  // Update the cell graph
445  void updateAxis();
446 
447  // Fill the vertex array
448  void fillVBOs();
449 
450  // Start select framebuffer
451  bool startSelectFbo();
452 
453  // Stop select framebuffer
454  bool stopSelectFbo();
455 
456  // Stop select framebuffer
457  bool readSelectFbo();
458 
459  // Correct the selection
460  void correctSelection(bool inclusive);
461 
462  // Update the selection array
463  void updateSelection();
464 
465  // Update Color and texture vertex array
466  void updColorVBOs();
467 
468  // Find selected triangle in triangle select mode (!MeshSelect)
469  void findSelectTriangle(uint x, uint y, std::vector<uint>& vlist, int& label,
470  bool useParentLabel = true);
471  // Average a list of vertices to find select point
472  bool findSeedPoint(uint x, uint y, CutSurf& cutSurf, Point3f& p);
473 
474  // Clear mesh selection
475  void clearMeshSelect();
476 
477  // Add point to selection
478  void addSelect(const VtxVec &vList);
479 
480  // Remove points from selection
481  void removeSelect(const VtxVec &vlist);
482 
483  // Apply a single clip plane to the bounding box
484  void bBoxClip(BoundingBox3f& bBox, Point3f p, Point3f n);
485 
486  // Make a bounding box from the clipping planes
487  void bBoxFromClip();
488 
489  // Start pixel editing
490  void voxelEditStart(ClipRegion& clip1, ClipRegion& clip2, ClipRegion& clip3);
491 
492  // Pixel editing operations
493  // p, px, py and pz should be in world coordinates
494  void voxelEdit(float pixelRadius, const Point3f& p, const Point3f& px, const Point3f& py,
495  const Point3f& pz, bool doCut, int currentLabel);
496 
497  // Stop pixel editing
498  void voxelEditStop();
499 
500  bool isMainVisible() const
501  {
502  return stack->main()->isVisible() and mainDataTexId;
503  }
504  bool isWorkVisible() const
505  {
506  return stack->work()->isVisible() and workDataTexId;
507  }
508  bool isVisible() const
509  {
510  return isMainVisible() or isWorkVisible();
511  }
512 
514  {
515  if(stack->work()->isVisible())
516  return stack->work()->data();
517  return stack->main()->data();
518  }
519  const HVecUS& currentData() const
520  {
521  if(stack->work()->isVisible())
522  return stack->work()->data();
523  return stack->main()->data();
524  }
525  Point3f imageGradientW(Point3d worldpos);
526  Point3f imageGradientI(Point3i ipos);
527  uint imageLevel(Point3d worldpos);
528  Point2i imageMinMax();
529 
530  GLenum interpolation(GLuint texId)
531  {
532  if(texId == workDataTexId)
533  return stack->work()->labels() ? GL_NEAREST : GL_LINEAR;
534  else
535  return stack->main()->labels() ? GL_NEAREST : GL_LINEAR;
536  }
537 
538  GLenum internalFormat(GLuint texId)
539  {
540  if(texId == workDataTexId)
541  return Work16Bit ? GL_ALPHA16 : GL_ALPHA8;
542  else
543  return Main16Bit ? GL_ALPHA16 : GL_ALPHA8;
544  }
545 
546  GLenum swapTextureBytes(GLuint texId)
547  {
548  if(texId == workDataTexId)
549  return stack->work()->labels();
550  else
551  return stack->main()->labels();
552  }
553 
554  // Set stack sizes
555  void updateStackSize();
556 
557  // Change the texture scale of the stack
558  void setTexScale(float s);
559 
560  bool valid() const
561  {
562  return stack->storeSize() > 0 and (mainDataTexId or workDataTexId);
563  }
564 
565  protected:
566  // Update a list of vertex labels
567  void updLabel(int label, std::vector<uint>& vlist);
568 
569  // Load 3D texture data, possibly downsampling.
570  void load3DTexData(const GLuint texId, const Point3u size, const ushort* data);
571 
572  // Get step for texture decimation
573  Point3u getTexStep();
574 
575  public:
576  // Clip texture coordinates
577  float trimTex(const float val) { return (trim(val, 0.0f, 1.0f)); }
578 
579  Point2f trimTex(const Point2f& val) { return (Point2f(trimTex(val.x()), trimTex(val.y()))); }
580 
581  protected:
582 
583  // Test if quad out of bounds, used for clipping 3D data
584  bool testQuad(float a, float b, float c, float d, float x)
585  {
586  if(a > x and b > x and c > x and d > x)
587  return (true);
588  if(a < -x and b < -x and c < -x and d < -x)
589  return (true);
590  return (false);
591  }
592 
593  // Get point color
595  {
596  // Get the color
597  Color3f c;
598  if(v->selected)
599  c = Colors::getColor(MeshSelectColor);
600  else if(v->minb != 0 or v->label < 0)
601  c = Colors::getColor(MeshBorderColor);
602  else
603  c = Colors::getColor(MeshColor);
604 
605  return (Point3GLub(255 * c.x(), 255 * c.y(), 255 * c.z()));
606  }
607 
608  // Get line color, and if it should be drawn
609  bool lDraw(const vertex& a, const vertex& b)
610  {
611  // Choose which line to draw
612  if(mesh->meshView() == "Border" and !(a->margin and b->margin))
613  return false;
614  if(mesh->meshView() == "Cells" and !(a->label == -1 and b->label == -1))
615  return false;
616  return true;
617  }
618 
619  // Compute offset for image data including border
620  size_t offset(uint x, uint y, uint z) { return stack->offset(x, y, z); }
621 
622  size_t offset(Point3i ipos) { return stack->offset(ipos); }
623 
624  // Check if in bounds
625  bool boundsOK(int x, int y, int z)
626  {
627  if(x < 0 or y < 0 or z < 0 or x >= int(stack->size().x()) or y >= int(stack->size().y())
628  or z >= int(stack->size().z()))
629  return (false);
630  else
631  return (true);
632  }
633 
634  public:
636  template <typename T> Point3f imageToWorld(const Vector<3, T>& img) const
637  {
638  return stack->imageToWorld<T>(img);
639  }
640 
642  template<typename T> Vector<3, T>worldToImage(Point3f wrld) const { return stack->worldToImage<T>(wrld); }
643  Point3f worldToImagef(const Point3f& a) const { return worldToImage<float>(a); }
644  Point3i worldToImagei(const Point3f& a) const { return worldToImage<int>(a); }
645  Point3u worldToImageu(const Point3f& a) const { return worldToImage<uint>(a); }
646 
647  // Map scale slider values
648  int toSliderScale(float s);
649  float fromSliderScale(int i);
650 
651  protected:
652  void updateHistogram(std::vector<double>& hist, const HVecUS& data, std::pair<double, double>& minMaxValues,
653  int max_data = 1 << 16, int size = 512);
654  void invalidateHistogram(std::vector<double>& hist) { hist.clear(); }
655 
656  // Clear 3D stack texture
657  void clearData(HVecUS& data)
658  {
659  data.resize(stack->storeSize());
660  memset(&data[0], 0, data.size() * sizeof(ushort));
661  }
662 
663  // Return texture info for a vertex with label-based heat
664  Point3f texCoordLabels(int label, const vertex & v, const IntFloatAttr & labelHeat);
665 
666  // Return texture info for a vertex with wall-based heat
667  Point3f texCoordWalls(int label, const vertex & v, const vertex & a, const vertex & b,
668  const vertex & c, const IntIntFloatAttr & wallHeat);
669 
670  // Set label on triangle
671  bool setLabel(vertex v1, vertex v2, vertex v3, int label)
672  {
673  bool ok = true;
674  if(v1->label > 0 and v1->label != label)
675  ok = false;
676  if(v2->label > 0 and v2->label != label)
677  ok = false;
678  if(v3->label > 0 and v3->label != label)
679  ok = false;
680 
681  if(ok) {
682  if(v1->label == 0)
683  v1->label = label;
684  if(v2->label == 0)
685  v2->label = label;
686  if(v3->label == 0)
687  v3->label = label;
688  }
689  return (ok);
690  }
691 
692  signals:
693  void changedInterface();
694  void changeSize(const Point3u& size, const Point3f& step, const Point3f& origin);
695  void stackUnloaded();
696 
697  public slots:
698  // Update the colors of all points in the mesh
699  void updateLineColor();
700 
701  // Slots for controls
702  void MainShowSlot(bool val);
703  void MainBrightSlot(int val);
704  void MainOpacitySlot(int val);
705  void MainLabelsSlot(bool val);
706  void Main16BitSlot(bool val);
707  void MainColorMapSlot();
708 
709  void WorkShowSlot(bool val);
710  void WorkBrightSlot(int val);
711  void WorkOpacitySlot(int val);
712  void WorkLabelsSlot(bool val);
713  void Work16BitSlot(bool val);
714  void WorkColorMapSlot();
715 
716  void SurfShowSlot(bool val);
717  void SurfBrightSlot(int val);
718  void SurfOpacitySlot(int val);
719  void SurfBlendSlot(bool val);
720  void SurfCullSlot(bool val);
721 
722  void SurfVertexSlot(bool val);
723  void SurfTriangleSlot(bool val);
724  void SurfLabelSlot(bool val);
725 
726  void VertexViewSlot(const QString &s);
727  void TriangleViewSlot(const QString &s);
728  void LabelViewSlot(const QString &s);
729 
730  void VertexColorMapSlot();
731  void TriangleColorMapSlot();
732  void LabelColorMapSlot();
733 
734  void SurfParentSlot(bool val);
735 
736  void MeshShowSlot(bool val);
737  void ChangeMeshViewModeSlot(const QString &s);
738  void AxisShowSlot(bool val);
739  void ChangeAxisViewModeSlot(const QString &s);
740  void MeshLinesSlot(bool val);
741  void MeshPointsSlot(bool val);
742 
743  void ViewerUpdateSlot(void);
744  void UpdateColorMapSlot(void);
745 
746  void CellMapSlot(bool val);
747  void ShowTransSlot(bool val);
748  void ShowScaleSlot(bool val);
749  void ShowBBoxSlot(bool val);
750  void TieScalesSlot(bool val); // ALR
751  void ScaleSlotX(int val);
752  void ScaleSlotY(int val);
753  void ScaleSlotZ(int val);
754 
755  // Slots to change transfer functions
756  void setSurfColorMap(const TransferFunction& fct);
757  void setHeatColorMap(const TransferFunction& fct);
758  void setWorkColorMap(const TransferFunction& fct);
759  void setMainColorMap(const TransferFunction& fct);
760 
761  // Slots to detect changes in transfer fct dialog boxes
762  void updateSurfColorMap(const TransferFunction& fct);
763  void updateHeatColorMap(const TransferFunction& fct);
764  void updateWorkColorMap(const TransferFunction& fct);
765  void updateMainColorMap(const TransferFunction& fct);
766 
767  signals:
768  void viewerUpdate();
769  void updateSliderScale();
770  void forceSurfHeat();
771  void toggleEditLabels();
772  };
773 }
774 #endif
mgx::ImgData::stack
Stack * stack
Definition: ImageData.hpp:60
mgx::ImgData::setupMainColorMap
void setupMainColorMap()
Definition: ImageData.hpp:290
mgx::ImgData::imgTexId
GLuint imgTexId
Definition: ImageData.hpp:89
ColorEditDlg.hpp
mgx::Shader::AT_SECOND_CMAP_TEX
@ AT_SECOND_CMAP_TEX
Definition: Shader.hpp:286
mgx::ImgData::internalFormat
GLenum internalFormat(GLuint texId)
Definition: ImageData.hpp:538
mgx::ImgData::sigStr
QString sigStr
Definition: ImageData.hpp:166
mgx::ImgData::showTransparentSurface
bool showTransparentSurface()
Definition: ImageData.hpp:344
mgx::ImgData::updateMainColorMap
void updateMainColorMap()
Definition: ImageData.hpp:274
mgx::uint
unsigned int uint
Definition: Geometry.hpp:41
mgx::ImgData::WorkHist
std::vector< double > WorkHist
Definition: ImageData.hpp:77
mgx::ImgData::MeshLineWidth
static float MeshLineWidth
Definition: ImageData.hpp:206
mgx::ImgData::StackId
int StackId
Definition: ImageData.hpp:58
mgx::Shader::AT_HEAT_TEX
@ AT_HEAT_TEX
Definition: Shader.hpp:283
Process.hpp
mgx::ImgData::FillWorkData
static bool FillWorkData
Definition: ImageData.hpp:194
mgx::ImgData::Section
QString Section
Definition: ImageData.hpp:157
mgx::VtxVec
std::vector< vertex > VtxVec
Vector of vertices.
Definition: Types.hpp:135
mgx::ImgData::cellGraphLineVA
std::vector< uint > cellGraphLineVA
Definition: ImageData.hpp:131
mgx::Stack::size
Point3u size() const
Returns the size, in voxels, of the stores.
Definition: Stack.hpp:133
TransferFunction.hpp
mgx::Stack::worldToImage
Matrix4f worldToImage() const
Matrix transforming a world point to an image one.
mgx::Colors::getColor
static Colorf getColor(ColorType type)
Definition: Colors.hpp:122
mgx::ScaleBar
Definition: ScaleBar.hpp:31
mgx::ImgData::updateHeatColorMap
void updateHeatColorMap()
Definition: ImageData.hpp:266
mgx::ImgData::imgVAid
GLuint imgVAid
Definition: ImageData.hpp:140
mgx::Mesh::heatFct
TransferFunction heatFct() const
Return the transfer function used to draw the surface in heat mode.
Definition: Mesh.hpp:533
mgx::ImgData::workDataTexId
GLuint workDataTexId
Definition: ImageData.hpp:84
mgx::Point4v
Vector< 4, vertex > Point4v
Definition: ImageData.hpp:40
mgx::Mesh::meshView
QString meshView() const
Return the current view mode for the mesh.
Definition: Mesh.hpp:738
mgx::ImgData::cellGraphPointVA
std::vector< uint > cellGraphPointVA
Definition: ImageData.hpp:130
mgx::ImgData::SurfColorMap
std::vector< TransferFunction::Colorf > SurfColorMap
Definition: ImageData.hpp:72
mgx::Stack::work
const Store * work() const
Access the work store.
Definition: Stack.hpp:101
mgx::ImgData::pixelRadius
float pixelRadius
Definition: ImageData.hpp:172
mgx::ImgData::selFboColor
GLuint selFboColor
Definition: ImageData.hpp:96
mgx::ImgData::setupWorkColorMap2
void setupWorkColorMap2()
Definition: ImageData.hpp:302
GraphUtils.hpp
mgx::Mesh::showSurface
bool showSurface() const
True if the surface is currently visible to the user.
Definition: Mesh.hpp:589
mgx::ImgData::cellGraphPosVAid
GLuint cellGraphPosVAid
Definition: ImageData.hpp:148
mgx::ImgData::selVA
std::vector< Point3GLub > selVA
Definition: ImageData.hpp:111
mgx::ImgData::lDraw
bool lDraw(const vertex &a, const vertex &b)
Definition: ImageData.hpp:609
mgx::ImgData::MainHist
std::vector< double > MainHist
Definition: ImageData.hpp:76
mgx::Store::labels
bool labels() const
Returns true if the data is to be interpreted as labels rather than intensities.
Definition: Store.hpp:70
qglviewer::ManipulatedFrame
mgx::ImgData::workBounds
std::pair< double, double > workBounds
Definition: ImageData.hpp:81
n
#define n
Definition: Eigenvalues.hpp:36
mgx::ImgData::texVAid
GLuint texVAid
Definition: ImageData.hpp:139
mgx::ImgData::MeshSelect
static bool MeshSelect
Definition: ImageData.hpp:201
mgx::Vector::z
CU_HOST_DEVICE void z(const T &v)
Short access to the third element.
Definition: Vector.hpp:739
ColorEditDlg
Definition: ColorEditDlg.hpp:64
mgx::ImgData::mainBounds
std::pair< double, double > mainBounds
Definition: ImageData.hpp:80
mgx::ImgData::MeshBorderColor
Colors::ColorType MeshBorderColor
Definition: ImageData.hpp:100
mgx::ImgData::Slices
static uint Slices
Definition: ImageData.hpp:184
Colors.hpp
mgx::TransferFunction
Definition: TransferFunction.hpp:34
mgx::ImgData::pntsVA
std::vector< Point3f > pntsVA
Definition: ImageData.hpp:117
mgx::HVecUS
thrust::host_vector< ushort > HVecUS
Definition: CudaExport.hpp:23
mgx::ImgData::setLabel
bool setLabel(vertex v1, vertex v2, vertex v3, int label)
Definition: ImageData.hpp:671
mgx::ImgData::VoxelEditRadius
static int VoxelEditRadius
Definition: ImageData.hpp:196
mgx::ImgData::pcellVA
std::vector< uint > pcellVA
Definition: ImageData.hpp:120
mgx::ImgData::worldToImagef
Point3f worldToImagef(const Point3f &a) const
Definition: ImageData.hpp:643
mgx::ImgData::heatTexId
GLuint heatTexId
Definition: ImageData.hpp:87
mgx::ImgData::lbrdVA
std::vector< uint > lbrdVA
Definition: ImageData.hpp:124
mgx::ImgData::selectV
VtxVec selectV
Definition: ImageData.hpp:93
mgx::ushort
unsigned short ushort
Simpler names for the various containers and iterators.
Definition: Geometry.hpp:42
mgx::ImgData::MeshSelectColor
Colors::ColorType MeshSelectColor
Definition: ImageData.hpp:102
ScaleBar.hpp
mgx::ImgData::bBox
BoundingBox3f bBox
Definition: ImageData.hpp:173
mgx::ImgData::cellGraphColorVAid
GLuint cellGraphColorVAid
Definition: ImageData.hpp:149
mgx::Stack::main
const Store * main() const
Access the main store.
Definition: Stack.hpp:82
mgx::ImgData::isMainVisible
bool isMainVisible() const
Definition: ImageData.hpp:500
mgx::ImgData::selFboId
GLuint selFboId
Definition: ImageData.hpp:95
mgx::ImgData::clipDo
Point3u clipDo
Definition: ImageData.hpp:167
mgx::ImgData::lcellVA
std::vector< uint > lcellVA
Definition: ImageData.hpp:125
mgx::Mesh::opacity
float opacity() const
Get the current opacity level of the surface.
Definition: Mesh.hpp:554
mgx::ImgData::mainDataTexId
GLuint mainDataTexId
Definition: ImageData.hpp:83
mgx::Colors::ColorType
ColorType
Mesh1 and 2 must have the same order for their colors.
Definition: Colors.hpp:35
mgx::ImgData::texVA
std::vector< Point3f > texVA
Definition: ImageData.hpp:112
mgx::vertex_identity_t
intptr_t vertex_identity_t
Type of the identifier of a vertex.
Definition: Vertex.hpp:40
mgx::Stack
Definition: Stack.hpp:33
mgx::Shader
Definition: Shader.hpp:274
Mesh.hpp
Geometry.hpp
mgx::ImgData::showOpaqueSurface
bool showOpaqueSurface()
Definition: ImageData.hpp:339
mgx::ImgData::cellGraphPosVA
std::vector< Point3f > cellGraphPosVA
Definition: ImageData.hpp:128
mgx::ImgData::scaleBar
static ScaleBar scaleBar
Definition: ImageData.hpp:202
mgx::Information::init
mgx_EXPORT void init(QMainWindow *wnd)
mgx::ImgData::lineId
vertex_identity_t lineId
Definition: ImageData.hpp:92
mgx
Distributed matrix library.
Definition: Assert.hpp:26
mgx::ImgData::selFboDepth
GLuint selFboDepth
Definition: ImageData.hpp:97
mgx::ImgData::offset
size_t offset(Point3i ipos)
Definition: ImageData.hpp:622
mgx::ImgData::nrmlVA
std::vector< Point3f > nrmlVA
Definition: ImageData.hpp:110
mgx::Shader::ActiveTextures
ActiveTextures
Definition: Shader.hpp:276
mgx::ImgData::pbrdVA
std::vector< uint > pbrdVA
Definition: ImageData.hpp:119
mgx::ImgData::getTransFrame
qglviewer::ManipulatedFrame & getTransFrame()
Definition: ImageData.hpp:235
mgx::ClipRegion
Definition: ClipRegion.hpp:39
mgx::Point3GLub
Vector< 3, GLubyte > Point3GLub
Definition: ImageData.hpp:43
mgx::Stack::storeSize
size_t storeSize() const
Returns the size, in number of elements, of the stores.
Definition: Stack.hpp:154
mgx::ColorMap
Definition: ColorMap.hpp:22
mgx::ImgData::imgVA
std::vector< Point2f > imgVA
Definition: ImageData.hpp:113
mgx::ImgData::DeleteBadVertex
static bool DeleteBadVertex
Definition: ImageData.hpp:193
mgx::Store::transferFct
TransferFunction transferFct() const
Retrieve the transfer function used to render the volume.
Definition: Store.hpp:116
mgx::ImgData::VoxelEditMaxPix
static int VoxelEditMaxPix
Definition: ImageData.hpp:197
mgx::ImgData::texMap
GLubyte * texMap
Definition: ImageData.hpp:154
mgx::ImgData::lineVA
std::vector< uint > lineVA
Definition: ImageData.hpp:123
mgx::Mesh::surfFct
TransferFunction surfFct() const
Return the transfer function used to draw the surface in normal mode.
Definition: Mesh.hpp:512
mgx::ImgData::workTransferDlg
TransferFunctionDlg * workTransferDlg
Definition: ImageData.hpp:68
mgx::ImgData::parent
QWidget * parent
Definition: ImageData.hpp:160
mgx::ImgData::worldToImagei
Point3i worldToImagei(const Point3f &a) const
Definition: ImageData.hpp:644
mgx::ImgData::labelWallBordMax
float labelWallBordMax
Definition: ImageData.hpp:165
mgx::ImgData::DrawNormals
static float DrawNormals
Definition: ImageData.hpp:189
mgx::ImgData::posVA
std::vector< Point3f > posVA
Definition: ImageData.hpp:109
Parms.hpp
mgx::ImgData::cellColorVAid
GLuint cellColorVAid
Definition: ImageData.hpp:142
mgx::BoundingBox3i
BoundingBox< 3, int > BoundingBox3i
Definition: Geometry.hpp:141
mgx::ImgData::setupWorkColorMap
void setupWorkColorMap()
Definition: ImageData.hpp:298
mgx::ImgData::setupSurfColorMap
void setupSurfColorMap()
Definition: ImageData.hpp:282
mgx::ImgData::idVA
std::vector< vertex > idVA
Definition: ImageData.hpp:105
mgx::ImgData::Work16Bit
bool Work16Bit
Definition: ImageData.hpp:64
mgx::max
T CU_HOST_DEVICE max(const T a, const T b)
Definition: Util.hpp:34
mgx::trim
CU_HOST_DEVICE T trim(const T x, const T minx, const T maxx)
Definition: Util.hpp:42
mgx::Shader::AT_TEX3D
@ AT_TEX3D
Definition: Shader.hpp:278
mgx::ImgData::isVisible
bool isVisible() const
Definition: ImageData.hpp:508
mgx::ImgData::pcolVA
std::vector< Point3GLub > pcolVA
Definition: ImageData.hpp:118
mgx::ImgData::triCell
std::vector< cell > triCell
Definition: ImageData.hpp:106
mgx::ImgData::axisColorVAid
GLuint axisColorVAid
Definition: ImageData.hpp:152
mgx::ImgData::trimTex
float trimTex(const float val)
Definition: ImageData.hpp:577
mgx::ImgData::axisPosVAid
GLuint axisPosVAid
Definition: ImageData.hpp:151
mgx::ImgData::trimTex
Point2f trimTex(const Point2f &val)
Definition: ImageData.hpp:579
mgx::ImgData::offset
size_t offset(uint x, uint y, uint z)
Definition: ImageData.hpp:620
mgx::ImgData::nrmlVAid
GLuint nrmlVAid
Definition: ImageData.hpp:137
mgx::ImgData::setupLabelColorMap
void setupLabelColorMap()
Definition: ImageData.hpp:306
mgx::ImgData::ImageFiles
std::vector< QString > ImageFiles
Definition: ImageData.hpp:158
mgx::ImgData::DrawZeroLabels
static float DrawZeroLabels
Definition: ImageData.hpp:191
mgx::ImgData::worldToImageu
Point3u worldToImageu(const Point3f &a) const
Definition: ImageData.hpp:645
mgx::Vector::y
CU_HOST_DEVICE void y(const T &v)
Short access to the second element.
Definition: Vector.hpp:730
mgx::ImgData::triangleColorEditDlg
ColorEditDlg * triangleColorEditDlg
Definition: ImageData.hpp:67
mgx::ColorbVec
std::vector< Colorb > ColorbVec
Definition: Color.hpp:319
ClipRegion.hpp
mgx::ImgData::invalidateHistogram
void invalidateHistogram(std::vector< double > &hist)
Definition: ImageData.hpp:654
mgx::ImgData::MaxTexSize
static Point3u MaxTexSize
Definition: ImageData.hpp:186
mgx::ImgData::SurfOffset
static float SurfOffset
Definition: ImageData.hpp:187
Shader.hpp
mgx::ImgData::cellGraphColorVA
std::vector< Point3GLub > cellGraphColorVA
Definition: ImageData.hpp:129
mgx::ImgData::cellColorVA
std::vector< Colorb > cellColorVA
Definition: ImageData.hpp:115
mgx::ImgData::labelTexId
GLuint labelTexId
Definition: ImageData.hpp:91
mgx::IntSet
std::set< int > IntSet
Set of integers.
Definition: Types.hpp:78
mgx::ImgData::min
float min
Definition: ImageData.hpp:161
mgx::ImgData::DrawNhbds
static float DrawNhbds
Definition: ImageData.hpp:192
mgx::ImgData::axisPosVA
std::vector< Point3f > axisPosVA
Definition: ImageData.hpp:133
mgx::ImgData::triangleColorVA
std::vector< Colorb > triangleColorVA
Definition: ImageData.hpp:114
mgx::ImgData::WorkColorMap
std::vector< TransferFunction::Colorf > WorkColorMap
Definition: ImageData.hpp:71
mgx::ImgData::axisColorVA
std::vector< Point3GLub > axisColorVA
Definition: ImageData.hpp:134
mgx::Stack::frame
const qglviewer::ManipulatedFrame & frame() const
Returns the manipulated frame.
Definition: Stack.hpp:386
mgx::ImgData::worldToImage
Vector< 3, T > worldToImage(Point3f wrld) const
Go from world coordinates to image coordinates.
Definition: ImageData.hpp:642
mgx::ImgData::LabelColorsChanged
bool LabelColorsChanged
Definition: ImageData.hpp:199
mgx::ImgData::mesh
Mesh * mesh
Definition: ImageData.hpp:61
mgx::ImgData::MeshPointSize
static float MeshPointSize
Definition: ImageData.hpp:205
mgx::ImgData::isWorkVisible
bool isWorkVisible() const
Definition: ImageData.hpp:504
mgx::ImgData::pselVAid
GLuint pselVAid
Definition: ImageData.hpp:146
mgx::ImgData::colorBar
static Colorbar colorBar
Definition: ImageData.hpp:203
ColorBar.hpp
mgx::ImgData::bBoxTex
BoundingBox3i bBoxTex
Definition: ImageData.hpp:174
mgx::TransferFunctionDlg
Definition: TransferFunctionDlg.hpp:24
mgx::ImgData::interpolation
GLenum interpolation(GLuint texId)
Definition: ImageData.hpp:530
mgx::Stack::offset
size_t offset(uint x, uint y, uint z) const
Compute offset for image data.
Definition: Stack.hpp:357
mgx::Store::isVisible
bool isVisible() const
Is the store currently visible.
Definition: Store.hpp:172
mgx::ImgData::selVAid
GLuint selVAid
Definition: ImageData.hpp:138
mgx::Shader::AT_LABEL_TEX
@ AT_LABEL_TEX
Definition: Shader.hpp:281
mgx::Mesh
Definition: Mesh.hpp:54
mgx::ImgData::triangleColorVAid
GLuint triangleColorVAid
Definition: ImageData.hpp:141
mgx::ImgData::MeshColor
Colors::ColorType MeshColor
Definition: ImageData.hpp:99
mgx::ImgData::frm
Matrix4d frm
Definition: ImageData.hpp:170
mgx::Stack::imageToWorld
Matrix4f imageToWorld() const
Matrix transforming an image point to a world one.
ColorMap.hpp
mgx::ImgData::TileCount
static uint TileCount
Definition: ImageData.hpp:185
mgx::ImgData::getFrame
qglviewer::ManipulatedFrame & getFrame()
Definition: ImageData.hpp:229
mgx::ImgData::posVAid
GLuint posVAid
Definition: ImageData.hpp:136
mgx::ImgData::surfTexId
GLuint surfTexId
Definition: ImageData.hpp:86
mgx::ImgData::DrawOffset
static float DrawOffset
Definition: ImageData.hpp:190
mgx::Point2f
Vector< 2, float > Point2f
Definition: ColorMap.hpp:19
Misc.hpp
mgx::ImgData::currentData
HVecUS & currentData()
Definition: ImageData.hpp:513
mgx::HVec4F
thrust::host_vector< Point4f > HVec4F
Definition: CudaExport.hpp:27
mgx::ImgData::SeedStack
static bool SeedStack
Definition: ImageData.hpp:195
mgx::Mesh::blending
bool blending() const
Return if the surface is rendered blended or not.
Definition: Mesh.hpp:642
mgx::ImgData
Definition: ImageData.hpp:45
mgx::ImgData::MainColorMap
std::vector< TransferFunction::Colorf > MainColorMap
Definition: ImageData.hpp:70
mgx::Stack::trans
const qglviewer::ManipulatedFrame & trans() const
Returns the transformation frame.
Definition: Stack.hpp:400
mgx::ImgData::valid
bool valid() const
Definition: ImageData.hpp:560
mgx::Vector
Namespace containing all the utility classes.
Definition: Vector.hpp:48
mgx::ImgData::imageToWorld
Point3f imageToWorld(const Vector< 3, T > &img) const
Go from image coordinates to world coordinates.
Definition: ImageData.hpp:636
mgx::ImgData::boundsOK
bool boundsOK(int x, int y, int z)
Definition: ImageData.hpp:625
mgx::ImgData::lselVA
std::vector< uint > lselVA
Definition: ImageData.hpp:126
mgx::ImgData::currentData
const HVecUS & currentData() const
Definition: ImageData.hpp:519
mgx::ImgData::testQuad
bool testQuad(float a, float b, float c, float d, float x)
Definition: ImageData.hpp:584
mgx::ImgData::dataTexColor
GLuint dataTexColor
Definition: ImageData.hpp:85
mgx::ImgData::SurfHist
std::vector< double > SurfHist
Definition: ImageData.hpp:78
mgx::Shader::AT_CMAP_TEX
@ AT_CMAP_TEX
Definition: Shader.hpp:285
mgx::ImgData::pixelsChanged
bool pixelsChanged
Definition: ImageData.hpp:209
mgx::Color< float >
mgx::ImgData::updateSurfColorMap
void updateSurfColorMap()
Definition: ImageData.hpp:262
mgx::ImgData::pntsVAid
GLuint pntsVAid
Definition: ImageData.hpp:144
mgx::ImgData::getMainFrame
qglviewer::ManipulatedFrame & getMainFrame()
Definition: ImageData.hpp:232
mgx::ImgData::meshShift
float meshShift
Definition: ImageData.hpp:177
mgx::ImgData::changed
bool changed
Definition: ImageData.hpp:208
mgx::ImgData::swapTextureBytes
GLenum swapTextureBytes(GLuint texId)
Definition: ImageData.hpp:546
mgx::ImgData::labelWallBordMin
float labelWallBordMin
Definition: ImageData.hpp:164
mgx::ImgData::marchLabel
int marchLabel
Definition: ImageData.hpp:175
mgx::CutSurf
Definition: CutSurf.hpp:34
mgx::ImgData::clearData
void clearData(HVecUS &data)
Definition: ImageData.hpp:657
mgx::ImgData::colorMapTexId
GLuint colorMapTexId
Definition: ImageData.hpp:88
mgx::ImgData::LabelColors
static std::vector< Colorf > LabelColors
Definition: ImageData.hpp:198
mgx::Vector::x
CU_HOST_DEVICE void x(const T &v)
Short access to the first element.
Definition: Vector.hpp:721
mgx::ImgData::HeatHist
std::vector< double > HeatHist
Definition: ImageData.hpp:79
mgx::Matrix< 4, 4, double >
mgx::Colorbar
Definition: ColorBar.hpp:29
mgx::Store::data
HVecUS & data()
Actual 3D data store linearly in a host vector.
Definition: Store.hpp:58
mgx::ImgData::marchData
HVecUS * marchData
Definition: ImageData.hpp:180
mgx::Shader::AT_SURF_TEX
@ AT_SURF_TEX
Definition: Shader.hpp:282
mgx::Parms
A utility class to parse L-Studio like parameter files.
Definition: Parms.hpp:116
mgx::ImgData::setupHeatColorMap
void setupHeatColorMap()
Definition: ImageData.hpp:286
mgx::ImgData::HeatColorMap
std::vector< TransferFunction::Colorf > HeatColorMap
Definition: ImageData.hpp:73
mgx::ImgData::pcolVAid
GLuint pcolVAid
Definition: ImageData.hpp:145
mgx::ImgData::newWorkColorMap
bool newWorkColorMap
Definition: ImageData.hpp:75
mgx::Stack::getFrame
qglviewer::ManipulatedFrame & getFrame()
Returns the active frame (i.e.
Definition: Stack.hpp:416
mgx::ImgData::updateWorkColorMap
void updateWorkColorMap()
Definition: ImageData.hpp:270
mgx::ImgData::pselVA
std::vector< uint > pselVA
Definition: ImageData.hpp:121
mgx::BoundingBox< 3, float >
mgx::AttrMap< int, float >
mgx::ImgData::wcmapTexId
GLuint wcmapTexId
Definition: ImageData.hpp:90
mgx::ImgData::pColor
Point3GLub pColor(const vertex &v)
Definition: ImageData.hpp:594
mgx::ImgData::Hpn
HVec4F Hpn
Definition: ImageData.hpp:169
mgx::ImgData::ClearColor
static int ClearColor
Definition: ImageData.hpp:183
mgx::Vertex
Definition: Vertex.hpp:58
mgx::ImgData::setupMainColorMap2
void setupMainColorMap2()
Definition: ImageData.hpp:294