8 #include <ColorBar.hpp>
12 #include <MGXViewer/qglviewer.h>
16 #include <ScaleBar.hpp>
18 #include <TransferFunctionDlg.hpp>
19 #include <TransferFunction.hpp>
30 typedef util::Vector<4, vertex> Point4v;
31 typedef util::Vector<3, GLubyte> Point3GLub;
43 static const uint RELOAD_NONE = 0x0;
44 static const uint RELOAD_MAIN = 0x1;
45 static const uint RELOAD_WORK = 0x2;
46 static const uint RELOAD_TRIS = 0x4;
47 static const uint RELOAD_LINES = 0x8;
48 static const uint RELOAD_POS = 0x10;
49 static const uint RELOAD_VBO = 0x20;
50 static const uint UPDATE_SELECTION = 0x40;
58 bool Main16Bit, Work16Bit;
66 std::vector<TransferFunction::Colorf> MainColorMap;
67 std::vector<TransferFunction::Colorf> WorkColorMap;
68 std::vector<TransferFunction::Colorf> SurfColorMap;
69 std::vector<TransferFunction::Colorf> HeatColorMap;
71 bool newMainColorMap, newWorkColorMap, newSurfColorMap, newHeatColorMap;
72 std::vector<double> MainHist;
73 std::vector<double> WorkHist;
74 std::vector<double> SurfHist;
75 std::vector<double> HeatHist;
76 std::pair<double, double> mainBounds;
77 std::pair<double, double> workBounds;
85 GLuint mcmapTexId, wcmapTexId;
87 graph::vertex_identity_t lineId;
88 std::set<uint> selectV;
100 std::vector<vertex> idVA;
101 std::vector<vertex> pidVA;
102 std::unordered_map<vertex, uint> vMap;
105 std::vector<Point3f> posVA;
106 std::vector<Point3f> nrmlVA;
107 std::vector<Point3GLub> selVA;
108 std::vector<Point3f> texVA;
109 std::vector<Point2f> imgVA;
111 std::vector<uint> lineVA;
112 std::vector<uint> lbrdVA;
113 std::vector<uint> lcellVA;
114 std::vector<uint> lselVA;
116 std::vector<uint> pbrdVA;
117 std::vector<uint> pcellVA;
118 std::vector<uint> pselVA;
119 std::vector<Point3f> pntsVA;
120 std::vector<Point3GLub> pcolVA;
121 std::vector<Point3GLub> pselcolVA;
137 std::vector<QString> ImageFiles;
143 float labelWallBordMin;
144 float labelWallBordMax;
168 static int ClearColor;
170 static uint TileCount;
172 static float ZOffset;
174 static float DrawNormals;
175 static float DrawOffset;
176 static float DrawZeroLabels;
177 static float DrawNhbds;
178 static bool DeleteBadVertex;
179 static bool FillWorkData;
180 static bool SeedStack;
181 static int PixelEditRadius;
182 static int PixelEditMaxPix;
183 static std::vector<Colorf> LabelColors;
184 bool LabelColorsChanged;
186 static bool MeshSelect;
190 static float MeshPointSize;
191 static float MeshLineWidth;
204 void setWork16Bit(
bool val);
205 void setMain16Bit(
bool val);
215 return stack->getFrame();
220 return stack->frame();
225 return stack->trans();
232 void drawStack(
Shader* shader);
235 void setColorMap(
const QString& pth,
bool work);
238 void updateHeatHistogram();
240 void updateSurfHistogram();
242 void updateWorkHistogram();
244 void updateMainHistogram();
247 void editMainTransferFunction(
QWidget* parent = 0);
248 void editWorkTransferFunction(
QWidget* parent = 0);
249 void editSurfTransferFunction(
QWidget* parent = 0);
250 void editHeatTransferFunction(
QWidget* parent = 0);
253 void updateSurfColorMap() {
254 updateColorMap(newSurfColorMap, SurfColorMap, mesh->surfFct());
256 void updateHeatColorMap() {
257 updateColorMap(newHeatColorMap, HeatColorMap, mesh->heatFct());
259 void updateWorkColorMap() {
260 updateColorMap(newWorkColorMap, WorkColorMap, stack->work()->transferFct());
262 void updateMainColorMap() {
263 updateColorMap(newMainColorMap, MainColorMap, stack->main()->transferFct());
265 void updateColorMap(
bool& newColorMap, std::vector<TransferFunction::Colorf>& ColorMap,
269 void setupSurfColorMap() {
270 setupColorMap(newSurfColorMap, surfTexId, SurfColorMap, Shader::AT_SURF_TEX);
272 void setupHeatColorMap() {
273 setupColorMap(newHeatColorMap, heatTexId, HeatColorMap, Shader::AT_HEAT_TEX);
275 void setupMainColorMap() {
276 setupColorMap(newMainColorMap, mcmapTexId, MainColorMap, Shader::AT_CMAP_TEX);
278 void setupMainColorMap2() {
279 setupColorMap(newMainColorMap, mcmapTexId, MainColorMap, Shader::AT_SECOND_CMAP_TEX);
281 void setupWorkColorMap() {
282 setupColorMap(newWorkColorMap, wcmapTexId, WorkColorMap, Shader::AT_CMAP_TEX);
284 void setupWorkColorMap2() {
285 setupColorMap(newWorkColorMap, wcmapTexId, WorkColorMap, Shader::AT_SECOND_CMAP_TEX);
287 void setupLabelColorMap()
289 std::vector<TransferFunction::Colorf> empty;
291 setupColorMap(nonew, labelTexId, empty, Shader::AT_LABEL_TEX);
293 void setupColorMap(
bool& newColorMap, GLuint& cmapTexId,
const std::vector<TransferFunction::Colorf>& ColorMap,
294 Shader::ActiveTextures activeTex);
297 void drawMesh(
bool select);
300 void drawVertexVertexLine(
ImgData* stack);
309 void setup3DRenderingData(
Shader* shader);
312 void drawSurf(
bool select,
Shader* texture_shader = 0,
Shader* label_shader = 0,
Shader* volume_shader = 0);
314 bool showOpaqueSurface() {
315 return mesh->isSurfaceVisible() and !mesh->blending();
318 bool showTransparentSurface() {
319 return mesh->isSurfaceVisible() && mesh->blending() && (mesh->opacity() > 0.0);
322 void setupVolumeShader(
Shader& shader,
int pos);
325 void markMargin(std::set<vertex>& M,
bool remborders);
334 void markBorder(
float borderSize);
337 void getLabelMaps(
float borderSize);
346 bool clipTest(
const Point3i& ip);
349 void makeNhbd(std::vector<vertex>& vtxs);
363 void initControls(
QWidget* viewer);
371 void reloadLabelTex();
374 void reloadTex(GLuint texId);
377 void bind3DTex(GLuint texId, Shader::ActiveTextures atexId = Shader::AT_TEX3D);
378 void bind2DTex(GLuint texId);
381 void loadImgTex(
const QImage& image);
384 void fillLabel(
int label,
int currlabel);
387 void setParent(
int label,
int parentLabel);
390 void selectLabel(
int label,
int repeat = 0);
393 void unselectLabel(
int label);
396 void selectParent(
int label,
int repeat = 0);
399 void unselectParent(
int label);
402 void selectConnected(std::vector<uint>& vlist,
bool unselect);
405 void addSeed(
int label, std::vector<uint>& vlist);
408 void fillSelect(
int label);
411 void deleteLabel(
int label);
416 void marginNormalsVBOs();
432 void correctSelection(
bool inclusive);
435 void updateSelection();
445 void updPos(std::set<uint>& vlist,
bool points);
448 void findSelectTriangle(uint x, uint y, std::vector<uint>& vlist,
int& label,
bool useParentLabel =
true);
451 int findSelectPoint(uint x, uint y);
457 void clearMeshSelect();
460 void addSelect(
const std::vector<uint>& vlist);
463 void removeSelect(
const std::vector<uint>& vlist);
466 void updColor(
const std::vector<uint>& vlist);
480 bool doCut,
int currentLabel);
483 void pixelEditStop();
485 bool isMainVisible()
const {
486 return stack->main()->isVisible() and mainDataTexId;
488 bool isWorkVisible()
const {
489 return stack->work()->isVisible() and workDataTexId;
491 bool isVisible()
const {
492 return isMainVisible() or isWorkVisible();
495 HVecUS& currentData()
497 if(stack->work()->isVisible())
498 return stack->work()->data();
499 return stack->main()->data();
501 const HVecUS& currentData()
const
503 if(stack->work()->isVisible())
504 return stack->work()->data();
505 return stack->main()->data();
509 uint imageLevel(
Point3d worldpos);
512 GLenum interpolation(GLuint texId)
514 if(texId == workDataTexId)
515 return stack->work()->labels() ? GL_NEAREST : GL_LINEAR;
517 return stack->main()->labels() ? GL_NEAREST : GL_LINEAR;
520 GLenum internalFormat(GLuint texId)
522 if(texId == workDataTexId)
523 return Work16Bit ? GL_ALPHA16 : GL_ALPHA8;
525 return Main16Bit ? GL_ALPHA16 : GL_ALPHA8;
528 GLenum swapTextureBytes(GLuint texId)
530 if(texId == workDataTexId)
531 return stack->work()->labels();
533 return stack->main()->labels();
537 void updateStackSize();
540 void setTexScale(
float s);
543 return stack->storeSize() > 0 and (mainDataTexId or workDataTexId);
548 void updLabel(
int label, std::vector<uint>& vlist);
551 bool addTriangle(std::vector<vertex>& vertices,
Point3i tri);
554 void meshFromTriangles(std::vector<vertex>& vertices, std::vector<Point3i>& triangles);
557 void projSignal(HVecUS& data,
vertex v,
float mindist,
float maxdist);
560 void load3DTexData(
const GLuint texId,
const Point3u size,
const ushort* data);
567 float trimTex(
const float val) {
568 return (trim(val, 0.0f, 1.0f));
572 return (
Point2f(trimTex(val.
x()), trimTex(val.
y())));
588 if(v.
id() <= n.
id() or !S.
edge(v, n))
595 bool testQuad(
float a,
float b,
float c,
float d,
float x)
597 if(a > x and b > x and c > x and d > x)
599 if(a < -x and b < -x and c < -x and d < -x)
621 c = Colors::getColor(MeshSelectColor);
622 else if(v->minb != 0 or v->label < 0)
623 c = Colors::getColor(MeshBorderColor);
625 c = Colors::getColor(MeshColor);
636 if((mesh->meshView() ==
Mesh::CELL_MESH)and !(a->label == -1 and b->label == -1))
642 size_t offset(uint x, uint y, uint z) {
643 return stack->offset(x, y, z);
647 return stack->offset(ipos);
651 bool boundsOK(
int x,
int y,
int z)
653 if(x < 0 or y < 0 or z < 0 or x >=
int(stack->size().x()) or y >=
int(stack->size().y())
654 or z >=
int(stack->size().z()))
673 return worldToImage<float>(a);
675 Point3i worldToImagei(
const Point3f& a)
const {
676 return worldToImage<int>(a);
678 Point3u worldToImageu(
const Point3f& a)
const {
679 return worldToImage<uint>(a);
683 int toSliderScale(
float s);
684 float fromSliderScale(
int i);
687 void updateHistogram(std::vector<double>& hist,
const HVecUS& data, std::pair<double, double>& minMaxValues,
688 int max_data = 1 << 16,
int size = 512);
689 void invalidateHistogram(std::vector<double>& hist) {
694 void clearData(HVecUS& data)
696 data.resize(stack->storeSize());
697 memset(&data[0], 0, data.size() *
sizeof(ushort));
701 Point3f texCoord(
int label,
vertex v);
710 if(v1->label > 0 and v1->label != label)
712 if(v2->label > 0 and v2->label != label)
714 if(v3->label > 0 and v3->label != label)
729 void changedInterface();
731 void changeSize(
const Point3u& size,
const Point3f& step,
const Point3f& origin);
732 void stackUnloaded();
739 void MainShowSlot(
bool val);
740 void MainBrightSlot(
int val);
741 void MainOpacitySlot(
int val);
742 void MainLabelsSlot(
bool val);
743 void Main16BitSlot(
bool val);
745 void WorkShowSlot(
bool val);
746 void WorkBrightSlot(
int val);
747 void WorkOpacitySlot(
int val);
748 void WorkLabelsSlot(
bool val);
749 void Work16BitSlot(
bool val);
751 void SurfShowSlot(
bool val);
752 void SurfBrightSlot(
int val);
753 void SurfOpacitySlot(
int val);
754 void SurfBlendSlot(
bool val);
755 void SurfCullSlot(
bool val);
757 void SurfNormalSlot(
bool val);
758 void SurfLabelSlot(
bool val);
759 void SurfHeatSlot(
bool val);
760 void SurfParentSlot(
bool val);
762 void SurfSignalSlot(
bool val);
763 void SurfTextureSlot(
bool val);
764 void SurfImageSlot(
bool val);
766 void MeshShowSlot(
bool val);
767 void ChangeMeshViewModeSlot(
int mode);
768 void MeshLinesSlot(
bool val);
769 void MeshPointsSlot(
bool val);
771 void CellMapSlot(
bool val);
772 void ShowTransSlot(
bool val);
773 void ShowScaleSlot(
bool val);
774 void ShowBBoxSlot(
bool val);
775 void TieScalesSlot(
bool val);
776 void ScaleSlotX(
int val);
777 void ScaleSlotY(
int val);
778 void ScaleSlotZ(
int val);
781 void setSurfColorMap(
const TransferFunction& fct);
782 void setHeatColorMap(
const TransferFunction& fct);
783 void setWorkColorMap(
const TransferFunction& fct);
784 void setMainColorMap(
const TransferFunction& fct);
787 void updateSurfColorMap(
const TransferFunction& fct);
788 void updateHeatColorMap(
const TransferFunction& fct);
789 void updateWorkColorMap(
const TransferFunction& fct);
790 void updateMainColorMap(
const TransferFunction& fct);
793 void updateImgData();
794 void postUpdateImgData(
bool lines,
bool tris);
798 void updateSliderScale();
799 void forceSurfHeat();
identity_t id() const
Return the identifier of a vertex.
Definition: Vertex.hpp:281
MeshView
Enumeration of the possible visualisations for the Mesh.
Definition: Mesh.hpp:184
std::map< int, Point3f > IntPoint3fMap
Map of an integer to a 3D point.
Definition: Mesh.hpp:53
This file contains the definition of a clipping region.
CU_HOST_DEVICE void x(const T &v)
Short access to the first element.
Definition: Vector.hpp:651
Definition: TransferFunctionDlg.hpp:15
Defines the util::Parms class.
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:28
Definition: Shader.hpp:269
Show only the mesh border.
Definition: Mesh.hpp:186
This class holds the actual mesh as a VV Graph and all sort of properties for it, including visualiza...
Definition: Mesh.hpp:167
Definition: ColorBar.hpp:18
vvgraph::vertex_t vertex
Type of a vertex.
Definition: Mesh.hpp:39
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:668
CU_HOST_DEVICE void y(const T &v)
Short access to the second element.
Definition: Vector.hpp:660
Point3f imageToWorld(const util::Vector< 3, T > &img) const
Go from image coordinates to world coordinates.
Definition: ImageData.hpp:662
A utility class to parse L-Studio like parameter files.
Definition: Parms.hpp:105
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:21
The Stack class represent the dimensions of the 3D data, and the frames transformations.
Definition: Stack.hpp:25
std::pair< int, int > IntIntPair
Element in IntIntMap.
Definition: Mesh.hpp:66
CU_HOST_DEVICE void z(const T &v)
Short access to the third element.
Definition: Vector.hpp:669
ColorType
Mesh1 and 2 must have the same order for their colors.
Definition: Colors.hpp:24
Definition: ScaleBar.hpp:21
Definition: ImageData.hpp:37
This files contains the definition of a mesh for the Process API.
Class defining a transfer function as linear interpolation between set values.
Definition: TransferFunction.hpp:23
Definition: ImageData.hpp:33
edge_t edge(const vertex_t &src, const vertex_t &tgt)
Returns the edge from src to tgt.
Definition: VVGraph.hpp:1954
Show only the cell borders (i.e. interface between labels)
Definition: Mesh.hpp:187