Skip to content

Commit 8588d90

Browse files
author
Brig Bagley
committed
improved BBox and CreateColorMap
1 parent 3960f16 commit 8588d90

File tree

8 files changed

+60
-25
lines changed

8 files changed

+60
-25
lines changed

src/Interface/Modules/Render/ES/shaders/ColorMapLegend.fs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,39 @@
2424
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2525
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2626
DEALINGS IN THE SOFTWARE.
27-
*/
27+
*/
2828
#ifdef OPENGL_ES
29-
#ifdef GL_FRAGMENT_PRECISION_HIGH
30-
// Default precision
31-
precision highp float;
32-
#else
33-
precision mediump float;
34-
#endif
29+
#ifdef GL_FRAGMENT_PRECISION_HIGH
30+
// Default precision
31+
precision highp float;
32+
#else
33+
precision mediump float;
34+
#endif
3535
#endif
3636

3737
uniform sampler1D uTX0;
3838

3939
varying float vFieldData;
40+
uniform float uCMInvert;
41+
uniform float uCMShift;
42+
uniform float uCMResolution;
4043

4144
void main()
4245
{
43-
gl_FragColor = texture1D( uTX0, vFieldData );
46+
float param = vFieldData;
47+
float shift = uCMShift;
48+
if (uCMInvert != 0.) {
49+
param = 1. - param;
50+
shift = shift * -1.;
51+
}
52+
//apply the resolution
53+
int res = int(uCMResolution);
54+
param = float(int(param * (float(res)))) / float(res - 1);
55+
// the shift is a gamma.
56+
float bp = 1. / tan((3.14159265359 / 2.) * ( 0.5 - shift * 0.5));
57+
param = pow(param,bp);
58+
59+
vec4 color = texture1D( uTX0, param );
60+
color.a = 1.0;
61+
gl_FragColor = color;
4462
}

src/Interface/Modules/Visualization/CreateBasicColorMapDialog.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ using namespace SCIRun::Dataflow::Networks;
3535
using namespace SCIRun::Core::Algorithms;
3636
using namespace SCIRun::Core::Datatypes;
3737

38+
typedef SCIRun::Modules::Visualization::CreateBasicColorMap CreateBasicColorMapModule;
3839

3940

4041
CreateBasicColorMapDialog::CreateBasicColorMapDialog(const std::string& name, ModuleStateHandle state,
@@ -46,7 +47,6 @@ CreateBasicColorMapDialog::CreateBasicColorMapDialog(const std::string& name, Mo
4647
ColorMap cm("Rainbow");
4748
previewColorMap_->setStyleSheet(buildGradientString(cm));
4849

49-
typedef SCIRun::Modules::Visualization::CreateBasicColorMap CreateBasicColorMapModule;
5050
resolutionSpin_->setValue(256);
5151
shiftSpin_->setValue(0.0);
5252
invertCheck_->setChecked(false);
@@ -67,6 +67,17 @@ CreateBasicColorMapDialog::CreateBasicColorMapDialog(const std::string& name, Mo
6767
void CreateBasicColorMapDialog::pull()
6868
{
6969
pull_newVersionToReplaceOld();
70+
Pulling p(this);
71+
std::string cm_name(state_->getValue(CreateBasicColorMapModule::ColorMapName).toString());
72+
double cm_shift(state_->getValue(CreateBasicColorMapModule::ColorMapShift).toDouble());
73+
int cm_res(state_->getValue(CreateBasicColorMapModule::ColorMapResolution).toInt());
74+
bool cm_inv(state_->getValue(CreateBasicColorMapModule::ColorMapInvert).toBool());
75+
colorMapNameComboBox_->setCurrentIndex(colorMapNameComboBox_->findText(QString::fromStdString(cm_name)));
76+
shiftSpin_->setValue(cm_shift);
77+
shiftSlider_->setValue(static_cast<int>(cm_shift * 100.));
78+
resolutionSlider_->setValue(cm_res);
79+
resolutionSpin_->setValue(cm_res);
80+
invertCheck_->setChecked(cm_inv);
7081
}
7182

7283
void CreateBasicColorMapDialog::updateColorMapPreview(QString s) {

src/Interface/Modules/Visualization/ShowField.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@
358358
</widget>
359359
<widget class="QGroupBox" name="groupBox_6">
360360
<property name="enabled">
361-
<bool>false</bool>
361+
<bool>true</bool>
362362
</property>
363363
<property name="geometry">
364364
<rect>

src/Interface/Modules/Visualization/ShowFieldDialog.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ ShowFieldDialog::ShowFieldDialog(const std::string& name, ModuleStateHandle stat
9090
groupBox_4->setVisible(false); //Node Display Type Group Box
9191

9292
//Edges Tab
93-
groupBox_7->setVisible(false);//Edge Display Type Group Box
94-
label_9->setVisible(false); //resolution label
95-
cylinder_res_spin->setVisible(false); //resolution spinbox
96-
label_8->setVisible(false); //scale label
97-
cylinder_rad_spin->setVisible(false); //cylinder scale spinbox
98-
groupBox_6->setVisible(false); //edge coloring
93+
//groupBox_7->setVisible(false);//Edge Display Type Group Box
94+
//label_9->setVisible(false); //resolution label
95+
//cylinder_res_spin->setVisible(false); //resolution spinbox
96+
//label_8->setVisible(false); //scale label
97+
//cylinder_rad_spin->setVisible(false); //cylinder scale spinbox
98+
//groupBox_6->setVisible(false); //edge coloring
9999

100100
//Faces Tab
101101
groupBox_5->setVisible(false); //face coloring

src/Modules/Fields/EditMeshBoundingBox.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ Core::Datatypes::GeometryHandle EditMeshBoundingBox::buildGeometryObject() {
296296
auto state = get_state();
297297
double scale = state->getValue(Scale).toDouble();
298298
scale = std::max(scale,0.01);
299-
int num_strips = int(100. * scale);
299+
int num_strips = 50.;
300300
std::vector<Vector> tri_points;
301301
std::vector<Vector> tri_normals;
302302
std::vector<uint32_t> tri_indices;

src/Modules/Visualization/CreateBasicColorMap.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ void CreateBasicColorMap::execute()
6767
}
6868
}
6969

70+
7071
const AlgorithmParameterName CreateBasicColorMap::ColorMapName("ColorMapName");
7172
const AlgorithmParameterName CreateBasicColorMap::ColorMapInvert("ColorMapInvert");
7273
const AlgorithmParameterName CreateBasicColorMap::ColorMapShift("ColorMapShift");

src/Modules/Visualization/ShowColorMapModule.cc

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@ void ShowColorMapModule::execute()
6767
boost::shared_ptr<SCIRun::Core::Datatypes::ColorMap> colorMap = getRequiredInput(ColorMapObject);
6868
if (needToExecute())
6969
{
70-
GeometryHandle geom = buildGeometryObject(colorMap, get_state(), get_id());
70+
std::ostringstream ostr;
71+
ostr << get_id() << "_" << colorMap.get();
72+
GeometryHandle geom = buildGeometryObject(colorMap, get_state(), ostr.str());
7173
sendOutput(GeometryOutput, geom);
7274
}
73-
7475
}
7576

7677
SCIRun::Core::Datatypes::GeometryHandle
@@ -86,19 +87,19 @@ ShowColorMapModule::buildGeometryObject(boost::shared_ptr<SCIRun::Core::Datatype
8687
std::vector<double> colors;
8788
std::vector<uint32_t> indices;
8889
int32_t numVBOElements = 0;
89-
ColorMap *map = cm.get();
90+
ColorMap * map = cm.get();
9091
double resolution = 1. / static_cast<double>(map->getColorMapResolution());
9192

9293
for (double i = 0.; i < 1.0; i+=resolution) {
9394
uint32_t offset = (uint32_t)points.size();
9495
points.push_back(Vector(0.,i,0.));
95-
colors.push_back(map->getTransformedColor(i));
96+
colors.push_back(i);
9697
points.push_back(Vector(1.,i,0.));
97-
colors.push_back(map->getTransformedColor(i));
98+
colors.push_back(i);
9899
points.push_back(Vector(0.,i+resolution,0.));
99-
colors.push_back(map->getTransformedColor(i));
100+
colors.push_back(i);
100101
points.push_back(Vector(1.,i+resolution,0.));
101-
colors.push_back(map->getTransformedColor(i));
102+
colors.push_back(i);
102103
numVBOElements+=2;
103104
indices.push_back(offset + 0);
104105
indices.push_back(offset + 1);
@@ -153,6 +154,10 @@ ShowColorMapModule::buildGeometryObject(boost::shared_ptr<SCIRun::Core::Datatype
153154
uniforms.push_back(GeometryObject::SpireSubPass::Uniform("uDisplayLength",static_cast<float>(displayLength)));
154155
GeometryObject::SpireVBO geomVBO = GeometryObject::SpireVBO(vboName, attribs, vboBufferSPtr,
155156
numVBOElements,Core::Geometry::BBox(),true);
157+
//push the color map parameters
158+
uniforms.push_back(GeometryObject::SpireSubPass::Uniform("uCMInvert",map->getColorMapInvert()?1.f:0.f));
159+
uniforms.push_back(GeometryObject::SpireSubPass::Uniform("uCMShift",static_cast<float>(map->getColorMapShift())));
160+
uniforms.push_back(GeometryObject::SpireSubPass::Uniform("uCMResolution",static_cast<float>(map->getColorMapResolution())));
156161

157162
geom->mVBOs.push_back(geomVBO);
158163

src/Modules/Visualization/Tests/ShowFieldTests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ INSTANTIATE_TEST_CASE_P(
7474
ConstructLatVolGeometry,
7575
ShowFieldScalingTest,
7676
Values(20, 40, 60, 80
77-
//, 100, 120, 150, 200 //to speed up make test
77+
, 100, 120, 150, //200 //to speed up make test
7878
//, 256 // probably runs out of memory
7979
)
8080
);

0 commit comments

Comments
 (0)