-
Notifications
You must be signed in to change notification settings - Fork 122
/
ThreesliceView.cpp
154 lines (130 loc) · 4.01 KB
/
ThreesliceView.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#include "MantidVatesSimpleGuiViewWidgets/ThreesliceView.h"
#include "MantidVatesSimpleGuiViewWidgets/LibHelper.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/Logger.h"
#include <Poco/Path.h>
#if defined(__INTEL_COMPILER)
#pragma warning disable 1170
#endif
#include <pqActiveObjects.h>
#include <pqApplicationCore.h>
#include <pqDataRepresentation.h>
#include <pqObjectBuilder.h>
#include <pqPipelineRepresentation.h>
#include <pqPipelineSource.h>
#include <pqPluginManager.h>
#include <pqRenderView.h>
#include <vtkSMPropertyHelper.h>
#include <vtkSMProxy.h>
#if defined(__INTEL_COMPILER)
#pragma warning enable 1170
#endif
#include <QMessageBox>
#include <iostream>
#include <string>
namespace Mantid
{
namespace Vates
{
namespace SimpleGui
{
namespace
{
/// Static logger
Kernel::Logger g_log("ThreeSliceView");
}
ThreeSliceView::ThreeSliceView(QWidget *parent) : ViewBase(parent)
{
this->ui.setupUi(this);
// We need to load the QuadView plugin
QString quadViewLibrary;
#ifdef Q_OS_WIN32
// Windows requires the full
// path information. The DLL is located in the apropriate executeable path of paraview.
const Poco::Path paraviewPath(Mantid::Kernel::ConfigService::Instance().getParaViewPath());
Poco::Path quadViewFullPath(paraviewPath, QUADVIEW_LIBRARY.toStdString());
quadViewLibrary = quadViewFullPath.toString().c_str();
#else
quadViewLibrary = QUADVIEW_LIBRARY;
#endif
// Need to load plugin
pqPluginManager* pm = pqApplicationCore::instance()->getPluginManager();
QString error;
pm->loadExtension(pqActiveObjects::instance().activeServer(),
quadViewLibrary, &error, false);
g_log.debug() << "Loading QuadView library from " << quadViewLibrary.toStdString() << "\n";
this->mainView = this->createRenderView(this->ui.mainRenderFrame,
QString("pqQuadView"));
pqActiveObjects::instance().setActiveView(this->mainView);
}
ThreeSliceView::~ThreeSliceView()
{
}
void ThreeSliceView::destroyView()
{
pqObjectBuilder *builder = pqApplicationCore::instance()->getObjectBuilder();
// Active source disappears in only this view, so set it from the
// internal source before destroying view.
pqActiveObjects::instance().setActiveSource(this->origSrc);
builder->destroy(this->mainView);
}
pqRenderView* ThreeSliceView::getView()
{
return this->mainView.data();
}
void ThreeSliceView::render()
{
this->makeThreeSlice();
this->resetDisplay();
emit this->triggerAccept();
}
void ThreeSliceView::makeThreeSlice()
{
pqPipelineSource *src = NULL;
src = pqActiveObjects::instance().activeSource();
pqObjectBuilder* builder = pqApplicationCore::instance()->getObjectBuilder();
// Do not allow overplotting PeaksWorkspaces
if (this->isPeaksWorkspace(src))
{
QMessageBox::warning(this, QApplication::tr("Overplotting Warning"),
QApplication::tr("Threeslice mode does not allow "\
"overlay of PeaksWorkspaces"));
// Need to destroy source since we tried to load it and set the active
// back to something. In this case we'll choose the original source
builder->destroy(src);
pqActiveObjects::instance().setActiveSource(this->origSrc);
return;
}
this->origSrc = src;
pqDataRepresentation *drep = builder->createDataRepresentation(\
this->origSrc->getOutputPort(0), this->mainView);
vtkSMPropertyHelper(drep->getProxy(), "Representation").Set("Slices");
drep->getProxy()->UpdateVTKObjects();
this->origRep = qobject_cast<pqPipelineRepresentation*>(drep);
}
void ThreeSliceView::renderAll()
{
this->mainView->render();
}
void ThreeSliceView::resetDisplay()
{
this->mainView->resetDisplay();
}
/*
void ThreeSliceView::correctVisibility()
{
//this->correctColorScaleRange();
}
*/
void ThreeSliceView::correctColorScaleRange()
{
QPair<double, double> range = this->origRep->getColorFieldRange();
emit this->dataRange(range.first, range.second);
}
void ThreeSliceView::resetCamera()
{
this->mainView->resetCamera();
}
}
}
}