18 #include <ColorBar.hpp> 22 #include <MGXViewer/qglviewer.h> 26 #include <ScaleBar.hpp> 28 #include <TransferFunctionDlg.hpp> 29 #include <TransferFunction.hpp> 40 typedef util::Vector<4, vertex> Point4v;
41 typedef util::Vector<3, GLubyte> Point3GLub;
53 static const uint RELOAD_NONE = 0x0;
54 static const uint RELOAD_MAIN = 0x1;
55 static const uint RELOAD_WORK = 0x2;
56 static const uint RELOAD_TRIS = 0x4;
57 static const uint RELOAD_LINES = 0x8;
58 static const uint RELOAD_POS = 0x10;
59 static const uint RELOAD_VBO = 0x20;
60 static const uint UPDATE_SELECTION = 0x40;
68 bool Main16Bit, Work16Bit;
76 std::vector<TransferFunction::Colorf> MainColorMap;
77 std::vector<TransferFunction::Colorf> WorkColorMap;
78 std::vector<TransferFunction::Colorf> SurfColorMap;
79 std::vector<TransferFunction::Colorf> HeatColorMap;
81 bool newMainColorMap, newWorkColorMap, newSurfColorMap, newHeatColorMap;
82 std::vector<double> MainHist;
83 std::vector<double> WorkHist;
84 std::vector<double> SurfHist;
85 std::vector<double> HeatHist;
86 std::pair<double, double> mainBounds;
87 std::pair<double, double> workBounds;
95 GLuint mcmapTexId, wcmapTexId;
98 std::set<uint> selectV;
110 std::vector<vertex> idVA;
111 std::vector<vertex> pidVA;
112 std::unordered_map<vertex, uint> vMap;
115 std::vector<Point3f> posVA;
116 std::vector<Point3f> nrmlVA;
117 std::vector<Point3GLub> selVA;
118 std::vector<Point3f> texVA;
119 std::vector<Point2f> imgVA;
121 std::vector<uint> lineVA;
122 std::vector<uint> lbrdVA;
123 std::vector<uint> lcellVA;
124 std::vector<uint> lselVA;
126 std::vector<uint> pbrdVA;
127 std::vector<uint> pcellVA;
128 std::vector<uint> pselVA;
129 std::vector<Point3f> pntsVA;
130 std::vector<Point3GLub> pcolVA;
131 std::vector<Point3GLub> pselcolVA;
147 std::vector<QString> ImageFiles;
153 float labelWallBordMin;
154 float labelWallBordMax;
178 static int ClearColor;
180 static uint TileCount;
182 static float ZOffset;
184 static float DrawNormals;
185 static float DrawOffset;
186 static float DrawZeroLabels;
187 static float DrawNhbds;
188 static bool DeleteBadVertex;
189 static bool FillWorkData;
190 static bool SeedStack;
191 static int PixelEditRadius;
192 static int PixelEditMaxPix;
193 static std::vector<Colorf> LabelColors;
194 bool LabelColorsChanged;
196 static bool MeshSelect;
200 static float MeshPointSize;
201 static float MeshLineWidth;
214 void setWork16Bit(
bool val);
215 void setMain16Bit(
bool val);
230 return stack->
frame();
235 return stack->
trans();
242 void drawStack(
Shader* shader);
245 void setColorMap(
const QString& pth,
bool work);
248 void updateHeatHistogram();
250 void updateSurfHistogram();
252 void updateWorkHistogram();
254 void updateMainHistogram();
257 void editMainTransferFunction(
QWidget* parent = 0);
258 void editWorkTransferFunction(
QWidget* parent = 0);
259 void editSurfTransferFunction(
QWidget* parent = 0);
260 void editHeatTransferFunction(
QWidget* parent = 0);
263 void updateSurfColorMap() {
264 updateColorMap(newSurfColorMap, SurfColorMap, mesh->
surfFct());
266 void updateHeatColorMap() {
267 updateColorMap(newHeatColorMap, HeatColorMap, mesh->
heatFct());
269 void updateWorkColorMap() {
270 updateColorMap(newWorkColorMap, WorkColorMap, stack->
work()->
transferFct());
272 void updateMainColorMap() {
273 updateColorMap(newMainColorMap, MainColorMap, stack->
main()->
transferFct());
275 void updateColorMap(
bool& newColorMap, std::vector<TransferFunction::Colorf>& ColorMap,
279 void setupSurfColorMap() {
280 setupColorMap(newSurfColorMap, surfTexId, SurfColorMap, Shader::AT_SURF_TEX);
282 void setupHeatColorMap() {
283 setupColorMap(newHeatColorMap, heatTexId, HeatColorMap, Shader::AT_HEAT_TEX);
285 void setupMainColorMap() {
286 setupColorMap(newMainColorMap, mcmapTexId, MainColorMap, Shader::AT_CMAP_TEX);
288 void setupMainColorMap2() {
289 setupColorMap(newMainColorMap, mcmapTexId, MainColorMap, Shader::AT_SECOND_CMAP_TEX);
291 void setupWorkColorMap() {
292 setupColorMap(newWorkColorMap, wcmapTexId, WorkColorMap, Shader::AT_CMAP_TEX);
294 void setupWorkColorMap2() {
295 setupColorMap(newWorkColorMap, wcmapTexId, WorkColorMap, Shader::AT_SECOND_CMAP_TEX);
297 void setupLabelColorMap()
299 std::vector<TransferFunction::Colorf> empty;
301 setupColorMap(nonew, labelTexId, empty, Shader::AT_LABEL_TEX);
303 void setupColorMap(
bool& newColorMap, GLuint& cmapTexId,
const std::vector<TransferFunction::Colorf>& ColorMap,
304 Shader::ActiveTextures activeTex);
307 void drawMesh(
bool select);
310 void drawVertexVertexLine(
ImgData* stack);
319 void setup3DRenderingData(
Shader* shader);
322 void drawSurf(
bool select,
Shader* texture_shader = 0,
Shader* label_shader = 0,
Shader* volume_shader = 0);
324 bool showOpaqueSurface() {
328 bool showTransparentSurface() {
332 void setupVolumeShader(
Shader& shader,
int pos);
335 void markMargin(std::set<vertex>& M,
bool remborders);
344 void markBorder(
float borderSize);
347 void getLabelMaps(
float borderSize);
356 bool clipTest(
const Point3i& ip);
359 void makeNhbd(std::vector<vertex>& vtxs);
373 void initControls(
QWidget* viewer);
381 void reloadLabelTex();
384 void reloadTex(GLuint texId);
387 void bind3DTex(GLuint texId, Shader::ActiveTextures atexId = Shader::AT_TEX3D);
388 void bind2DTex(GLuint texId);
391 void loadImgTex(
const QImage& image);
394 void fillLabel(
int label,
int currlabel);
397 void setParent(
int label,
int parentLabel);
400 void selectLabel(
int label,
int repeat = 0);
403 void unselectLabel(
int label);
406 void selectParent(
int label,
int repeat = 0);
409 void unselectParent(
int label);
412 void selectConnected(std::vector<uint>& vlist,
bool unselect);
415 void addSeed(
int label, std::vector<uint>& vlist);
418 void fillSelect(
int label);
421 void deleteLabel(
int label);
426 void marginNormalsVBOs();
442 void correctSelection(
bool inclusive);
445 void updateSelection();
455 void updPos(std::set<uint>& vlist,
bool points);
458 void findSelectTriangle(uint x, uint y, std::vector<uint>& vlist,
int& label,
bool useParentLabel =
true);
461 int findSelectPoint(uint x, uint y);
467 void clearMeshSelect();
470 void addSelect(
const std::vector<uint>& vlist);
473 void removeSelect(
const std::vector<uint>& vlist);
476 void updColor(
const std::vector<uint>& vlist);
490 bool doCut,
int currentLabel);
493 void pixelEditStop();
495 bool isMainVisible()
const {
496 return stack->main()->isVisible() and mainDataTexId;
498 bool isWorkVisible()
const {
499 return stack->work()->isVisible() and workDataTexId;
501 bool isVisible()
const {
502 return isMainVisible() or isWorkVisible();
505 HVecUS& currentData()
507 if(stack->work()->isVisible())
508 return stack->work()->data();
509 return stack->main()->data();
511 const HVecUS& currentData()
const 513 if(stack->work()->isVisible())
514 return stack->work()->data();
515 return stack->main()->data();
519 uint imageLevel(
Point3d worldpos);
522 GLenum interpolation(GLuint texId)
524 if(texId == workDataTexId)
525 return stack->work()->labels() ? GL_NEAREST : GL_LINEAR;
527 return stack->main()->labels() ? GL_NEAREST : GL_LINEAR;
530 GLenum internalFormat(GLuint texId)
532 if(texId == workDataTexId)
533 return Work16Bit ? GL_ALPHA16 : GL_ALPHA8;
535 return Main16Bit ? GL_ALPHA16 : GL_ALPHA8;
538 GLenum swapTextureBytes(GLuint texId)
540 if(texId == workDataTexId)
541 return stack->work()->labels();
543 return stack->main()->labels();
547 void updateStackSize();
550 void setTexScale(
float s);
553 return stack->storeSize() > 0 and (mainDataTexId or workDataTexId);
558 void updLabel(
int label, std::vector<uint>& vlist);
561 bool addTriangle(std::vector<vertex>& vertices,
Point3i tri);
564 void meshFromTriangles(std::vector<vertex>& vertices, std::vector<Point3i>& triangles);
567 void projSignal(HVecUS& data,
vertex v,
float mindist,
float maxdist);
570 void load3DTexData(
const GLuint texId,
const Point3u size,
const ushort* data);
577 float trimTex(
const float val) {
578 return (trim(val, 0.0f, 1.0f));
582 return (
Point2f(trimTex(val.
x()), trimTex(val.
y())));
598 if(v.
id() <= n.
id() or !S.
edge(v, n))
605 bool testQuad(
float a,
float b,
float c,
float d,
float x)
607 if(a > x and b > x and c > x and d > x)
609 if(a < -x and b < -x and c < -x and d < -x)
626 Point3GLub pColor(
const vertex& v)
631 c = Colors::getColor(MeshSelectColor);
632 else if(v->minb != 0 or v->label < 0)
633 c = Colors::getColor(MeshBorderColor);
635 c = Colors::getColor(MeshColor);
637 return (Point3GLub(255 * c.
x(), 255 * c.
y(), 255 * c.
z()));
652 size_t offset(uint x, uint y, uint z) {
653 return stack->offset(x, y, z);
657 return stack->offset(ipos);
661 bool boundsOK(
int x,
int y,
int z)
663 if(x < 0 or y < 0 or z < 0 or x >=
int(stack->size().x()) or y >=
int(stack->size().y())
664 or z >=
int(stack->size().z()))
683 return worldToImage<float>(a);
686 return worldToImage<int>(a);
689 return worldToImage<uint>(a);
693 int toSliderScale(
float s);
694 float fromSliderScale(
int i);
697 void updateHistogram(std::vector<double>& hist,
const HVecUS& data, std::pair<double, double>& minMaxValues,
698 int max_data = 1 << 16,
int size = 512);
699 void invalidateHistogram(std::vector<double>& hist) {
704 void clearData(HVecUS& data)
706 data.resize(stack->storeSize());
707 memset(&data[0], 0, data.size() *
sizeof(ushort));
720 if(v1->label > 0 and v1->label != label)
722 if(v2->label > 0 and v2->label != label)
724 if(v3->label > 0 and v3->label != label)
739 void changedInterface();
742 void stackUnloaded();
749 void MainShowSlot(
bool val);
750 void MainBrightSlot(
int val);
751 void MainOpacitySlot(
int val);
752 void MainLabelsSlot(
bool val);
753 void Main16BitSlot(
bool val);
755 void WorkShowSlot(
bool val);
756 void WorkBrightSlot(
int val);
757 void WorkOpacitySlot(
int val);
758 void WorkLabelsSlot(
bool val);
759 void Work16BitSlot(
bool val);
761 void SurfShowSlot(
bool val);
762 void SurfBrightSlot(
int val);
763 void SurfOpacitySlot(
int val);
764 void SurfBlendSlot(
bool val);
765 void SurfCullSlot(
bool val);
767 void SurfNormalSlot(
bool val);
768 void SurfLabelSlot(
bool val);
769 void SurfHeatSlot(
bool val);
770 void SurfParentSlot(
bool val);
772 void SurfSignalSlot(
bool val);
773 void SurfTextureSlot(
bool val);
774 void SurfImageSlot(
bool val);
776 void MeshShowSlot(
bool val);
777 void ChangeMeshViewModeSlot(
int mode);
778 void MeshLinesSlot(
bool val);
779 void MeshPointsSlot(
bool val);
781 void CellMapSlot(
bool val);
782 void ShowTransSlot(
bool val);
783 void ShowScaleSlot(
bool val);
784 void ShowBBoxSlot(
bool val);
785 void TieScalesSlot(
bool val);
786 void ScaleSlotX(
int val);
787 void ScaleSlotY(
int val);
788 void ScaleSlotZ(
int val);
803 void updateImgData();
804 void postUpdateImgData(
bool lines,
bool tris);
808 void updateSliderScale();
809 void forceSurfHeat();
identity_t id() const
Return the identifier of a vertex.
Definition: Vertex.hpp:291
MeshView
Enumeration of the possible visualisations for the Mesh.
Definition: Mesh.hpp:194
std::map< int, Point3f > IntPoint3fMap
Map of an integer to a 3D point.
Definition: Mesh.hpp:63
const qglviewer::ManipulatedFrame & frame() const
Returns the manipulated frame.
Definition: Stack.hpp:389
const qglviewer::ManipulatedFrame & trans() const
Returns the transformation frame.
Definition: Stack.hpp:403
This file contains the definition of a clipping region.
TransferFunction surfFct() const
Return the transfer function used to draw the surface in normal mode.
Definition: Mesh.hpp:710
CU_HOST_DEVICE void x(const T &v)
Short access to the first element.
Definition: Vector.hpp:661
qglviewer::ManipulatedFrame & getFrame()
Returns the active frame (i.e.
Definition: Stack.hpp:419
Definition: TransferFunctionDlg.hpp:25
Defines the util::Parms class.
TransferFunction transferFct() const
Retrieve the transfer function used to render the volume.
Definition: Store.hpp:122
mgx_EXPORT bool meshFromTriangles(vvgraph &S, std::vector< vertex > &vertices, std::vector< Point3i > &triangles)
This function creates a graph from a triangle soup.
Class to handle rotatable pair of clipping planes.
Definition: ClipRegion.hpp:38
Definition: Shader.hpp:279
Show only the mesh border.
Definition: Mesh.hpp:196
intptr_t vertex_identity_t
Type of the identifier of a vertex.
Definition: Vertex.hpp:42
This class holds the actual mesh as a VV Graph and all sort of properties for it, including visualiza...
Definition: Mesh.hpp:177
bool blending() const
Return if the surface is rendered blended or not.
Definition: Mesh.hpp:890
Definition: ColorBar.hpp:28
Common definitions and utilities for all geometry algorithms This file is shared by cuda...
util::Vector< 3, T > worldToImage(Point3f wrld) const
Go from world coordinates to image coordinates.
Definition: ImageData.hpp:678
CU_HOST_DEVICE void y(const T &v)
Short access to the second element.
Definition: Vector.hpp:670
This namespace contains all the API of MorphoGraphX.
Definition: Assert.hpp:26
Point3f imageToWorld(const util::Vector< 3, T > &img) const
Go from image coordinates to world coordinates.
Definition: ImageData.hpp:672
A utility class to parse L-Studio like parameter files.
Definition: Parms.hpp:115
MeshView meshView() const
Return the current view mode for the mesh.
Definition: Mesh.hpp:968
mgxBase_EXPORT bool subdivideBisect(vvgraph &S, const vertex &v1, const vertex &v2, const vertex &v3, bool selected, std::vector< vertex > *vs=0)
Subdivide triangle by bi-sections.
File containing the definition of a Process.
mgxBase_EXPORT void markMargin(vvgraph &M, vvgraph &S, bool remborders)
Mark the cells and tissue margin vertices.
Definition: CutSurf.hpp:31
The Stack class represent the dimensions of the 3D data, and the frames transformations.
Definition: Stack.hpp:35
float opacity() const
Get the current opacity level of the surface.
Definition: Mesh.hpp:758
std::pair< int, int > IntIntPair
Element in IntIntMap.
Definition: Mesh.hpp:76
CU_HOST_DEVICE void z(const T &v)
Short access to the third element.
Definition: Vector.hpp:679
const Store * work() const
Access the work store.
Definition: Stack.hpp:103
ColorType
Mesh1 and 2 must have the same order for their colors.
Definition: Colors.hpp:34
Definition: ScaleBar.hpp:31
const Store * main() const
Access the main store.
Definition: Stack.hpp:84
Definition: ImageData.hpp:47
TransferFunction heatFct() const
Return the transfer function used to draw the surface in heat mode.
Definition: Mesh.hpp:734
This files contains the definition of a mesh for the Process API.
bool isSurfaceVisible() const
True if the surface is currently visible to the user.
Definition: Mesh.hpp:795
Class defining a transfer function as linear interpolation between set values.
Definition: TransferFunction.hpp:33
Definition: ImageData.hpp:43
edge_t edge(const vertex_t &src, const vertex_t &tgt)
Returns the edge from src to tgt.
Definition: VVGraph.hpp:1964
Show only the cell borders (i.e. interface between labels)
Definition: Mesh.hpp:197