Skip to content

Commit

Permalink
Release version 1.11
Browse files Browse the repository at this point in the history
Using tarball (with SHA1):
531cd9202e19e08c362d10f49b7edf242fd9a003 *3DVisualizer-1.11.tar.gz
  • Loading branch information
Doc-Ok authored and daBrado committed Mar 13, 2013
1 parent fc7bf4b commit fa61819
Show file tree
Hide file tree
Showing 84 changed files with 2,062 additions and 819 deletions.
4 changes: 2 additions & 2 deletions Abstract/DataSetRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ void DataSetRenderer::setRenderingMode(int renderingModeIndex)
Misc::throwStdErr("DataSetRenderer::setRenderingMode: invalid rendering mode index %d",renderingModeIndex);
}

void DataSetRenderer::glRenderAction(GLContextData& contextData) const
void DataSetRenderer::glRenderAction(GLRenderState& renderState) const
{
}

void DataSetRenderer::highlightLocator(const DataSet::Locator* locator,GLContextData& contextData) const
void DataSetRenderer::highlightLocator(const DataSet::Locator* locator,GLRenderState& renderState) const
{
}

Expand Down
8 changes: 4 additions & 4 deletions Abstract/DataSetRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ DataSetRenderer - Abstract base class to render the structure of data
sets using OpenGL.
Part of the abstract interface to the templatized visualization
components.
Copyright (c) 2005-2007 Oliver Kreylos
Copyright (c) 2005-2012 Oliver Kreylos
This file is part of the 3D Data Visualizer (Visualizer).
Expand All @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include <Abstract/DataSet.h>

/* Forward declarations: */
class GLContextData;
class GLRenderState;

namespace Visualization {

Expand Down Expand Up @@ -58,8 +58,8 @@ class DataSetRenderer
virtual const char* getRenderingModeName(int renderingModeIndex) const; // Returns the name of a supported rendering mode
virtual int getRenderingMode(void) const; // Returns the current rendering mode
virtual void setRenderingMode(int renderingModeIndex); // Sets the given rendering mode for future rendering
virtual void glRenderAction(GLContextData& contextData) const; // Renders into the given OpenGL context
virtual void highlightLocator(const DataSet::Locator* locator,GLContextData& contextData) const; // Highlights the given data set locator
virtual void glRenderAction(GLRenderState& renderState) const; // Renders into the given OpenGL context
virtual void highlightLocator(const DataSet::Locator* locator,GLRenderState& renderState) const; // Highlights the given data set locator
};

}
Expand Down
10 changes: 9 additions & 1 deletion Abstract/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ data sets. Elements use thread-safe reference counting for automatic
garbage collection.
Part of the abstract interface to the templatized visualization
components.
Copyright (c) 2005-2009 Oliver Kreylos
Copyright (c) 2005-2012 Oliver Kreylos
This file is part of the 3D Data Visualizer (Visualizer).
Expand All @@ -25,6 +25,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#include <Abstract/Element.h>

#include <Abstract/Parameters.h>

namespace Visualization {

namespace Abstract {
Expand All @@ -33,6 +35,12 @@ namespace Abstract {
Methods of class Element:
************************/

Element::~Element(void)
{
/* Delete the parameter object: */
delete parameters;
}

bool Element::usesTransparency(void) const
{
return false;
Expand Down
20 changes: 8 additions & 12 deletions Abstract/Element.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ data sets. Elements use thread-safe reference counting for automatic
garbage collection.
Part of the abstract interface to the templatized visualization
components.
Copyright (c) 2005-2009 Oliver Kreylos
Copyright (c) 2005-2012 Oliver Kreylos
This file is part of the 3D Data Visualizer (Visualizer).
Expand All @@ -29,22 +29,21 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include <string>
#include <Threads/RefCounted.h>

#include <Abstract/Parameters.h>

/* Forward declarations: */
namespace Misc {
class File;
}
class GLContextData;
namespace GLMotif {
class WidgetManager;
class Widget;
}
namespace Visualization {
namespace Abstract {
class VariableManager;
class Parameters;
}
}
class GLRenderState;

namespace Visualization {

Expand All @@ -54,23 +53,20 @@ class Element:public Threads::RefCounted
{
/* Elements: */
protected:
VariableManager* variableManager; // Pointer to the variable manager
Parameters* parameters; // Pointer to the parameters that were used to create this visualization element

/* Constructors and destructors: */
public:
Element(Parameters* sParameters) // Creates an "empty" visualization element that will inherit the given parameter object
:parameters(sParameters)
Element(VariableManager* sVariableManager,Parameters* sParameters) // Creates an "empty" visualization element that will inherit the given parameter object
:variableManager(sVariableManager),parameters(sParameters)
{
}
private:
Element(const Element& source); // Prohibit copy constructor
Element& operator=(const Element& source); // Prohibit assignment operator
public:
virtual ~Element(void) // Destroys the visualization element
{
/* Delete the parameter object: */
delete parameters;
}
virtual ~Element(void); // Destroys the visualization element

/* Methods: */
const Parameters* getParameters(void) const // Returns pointer to parameter object
Expand All @@ -85,7 +81,7 @@ class Element:public Threads::RefCounted
virtual size_t getSize(void) const =0; // Returns some size value for the visualization element to compare it to other elements of the same type (number of triangles, points, etc.)
virtual bool usesTransparency(void) const; // Returns true if the visualization element uses transparency (and needs to be rendered last)
virtual GLMotif::Widget* createSettingsDialog(GLMotif::WidgetManager* widgetManager); // Returns a new UI widget to change internal settings of the element
virtual void glRenderAction(GLContextData& contextData) const =0; // Renders a visualization element into the current OpenGL context
virtual void glRenderAction(GLRenderState& renderState) const =0; // Renders a visualization element into the given OpenGL context
};

}
Expand Down
127 changes: 124 additions & 3 deletions Abstract/VariableManager.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/***********************************************************************
VariableManager - Helper class to manage the scalar and vector variables
that can be extracted from a data set.
Copyright (c) 2008 Oliver Kreylos
Copyright (c) 2008-2012 Oliver Kreylos
This file is part of the 3D Data Visualizer (Visualizer).
Expand All @@ -20,10 +20,14 @@ with the 3D Data Visualizer; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***********************************************************************/

#include <Abstract/VariableManager.h>

#include <string.h>
#include <stdio.h>
#include <stdexcept>
#include <Misc/CreateNumberedFileName.h>
#include <GL/gl.h>
#include <GL/GLContextData.h>
#include <GL/GLColorMap.h>
#include <GLMotif/StyleSheet.h>
#include <GLMotif/WidgetManager.h>
Expand All @@ -33,11 +37,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include <Abstract/ScalarExtractor.h>
#include <Abstract/VectorExtractor.h>

#include <GLRenderState.h>
#include <ColorBar.h>
#include <ColorMap.h>

#include <Abstract/VariableManager.h>

namespace Visualization {

namespace Abstract {
Expand All @@ -49,6 +52,7 @@ Methods of class VariableManager::ScalarVariable:
VariableManager::ScalarVariable::ScalarVariable(void)
:scalarExtractor(0),
colorMap(0),
colorMapVersion(0),
palette(0)
{
}
Expand All @@ -60,6 +64,29 @@ VariableManager::ScalarVariable::~ScalarVariable(void)
delete palette;
}

/******************************************
Methods of class VariableManager::DataItem:
******************************************/

VariableManager::DataItem::DataItem(unsigned int sNumScalarVariables)
:numScalarVariables(sNumScalarVariables),
colorMapTextureIds(new GLuint[numScalarVariables]),
colorMapVersions(new unsigned int[numScalarVariables])
{
/* Initialize the color map texture array: */
glGenTextures(numScalarVariables,colorMapTextureIds);
for(unsigned int i=0;i<numScalarVariables;++i)
colorMapVersions[i]=0;
}

VariableManager::DataItem::~DataItem(void)
{
/* Delete the color map texture array: */
glDeleteTextures(numScalarVariables,colorMapTextureIds);
delete[] colorMapTextureIds;
delete[] colorMapVersions;
}

/********************************
Methods of class VariableManager:
********************************/
Expand All @@ -76,12 +103,17 @@ void VariableManager::prepareScalarVariable(int scalarVariableIndex)

/* Create a 256-entry OpenGL color map for rendering: */
sv.colorMap=new GLColorMap(GLColorMap::GREYSCALE|GLColorMap::RAMP_ALPHA,1.0f,1.0f,sv.valueRange.first,sv.valueRange.second);
++sv.colorMapVersion;

/* Initialize the color map range to the variable's full scalar range: */
sv.colorMapRange=sv.valueRange;
}

void VariableManager::colorMapChangedCallback(Misc::CallbackData* cbData)
{
/* Export the changed palette to the current color map: */
paletteEditor->exportColorMap(*scalarVariables[currentScalarVariableIndex].colorMap);
++scalarVariables[currentScalarVariableIndex].colorMapVersion;

Vrui::requestUpdate();
}
Expand Down Expand Up @@ -168,6 +200,13 @@ VariableManager::~VariableManager(void)
delete paletteEditor;
}

void VariableManager::initContext(GLContextData& contextData) const
{
/* Create a data item and register it with the OpenGL context: */
DataItem* dataItem=new DataItem(numScalarVariables);
contextData.addDataItem(this,dataItem);
}

const DataSet* VariableManager::getDataSetByScalarVariable(int scalarVariableIndex) const
{
if(scalarVariableIndex<0||scalarVariableIndex>=numScalarVariables)
Expand Down Expand Up @@ -319,6 +358,18 @@ const GLColorMap* VariableManager::getColorMap(int scalarVariableIndex)
return scalarVariables[scalarVariableIndex].colorMap;
}

const DataSet::VScalarRange& VariableManager::getScalarColorMapRange(int scalarVariableIndex)
{
if(scalarVariableIndex<0||scalarVariableIndex>=numScalarVariables)
return scalarVariables[currentScalarVariableIndex].colorMapRange;

/* Check if the scalar variable has not been requested before: */
if(scalarVariables[scalarVariableIndex].scalarExtractor==0)
prepareScalarVariable(scalarVariableIndex);

return scalarVariables[scalarVariableIndex].colorMapRange;
}

const VectorExtractor* VariableManager::getVectorExtractor(int vectorVariableIndex)
{
if(vectorVariableIndex<0||vectorVariableIndex>=numVectorVariables)
Expand Down Expand Up @@ -485,6 +536,76 @@ void VariableManager::insertPaletteEditorControlPoint(double newControlPoint)
paletteEditor->getColorMap()->insertControlPoint(newControlPoint);
}

void VariableManager::beginRenderPass(GLRenderState& renderState) const
{
/* Get the context data item: */
DataItem* dataItem=renderState.getContextData().retrieveDataItem<DataItem>(this);

/* Initialize the scalar variable tracker: */
dataItem->lastBoundScalarVariableIndex=-1;

/* Save the OpenGL texture matrix: */
renderState.setMatrixMode(2);
glPushMatrix();
dataItem->textureMatrixVersion=renderState.getMatrixVersion();
}

void VariableManager::bindColorMap(int scalarVariableIndex,GLRenderState& renderState) const
{
/* Get the context data item: */
DataItem* dataItem=renderState.getContextData().retrieveDataItem<DataItem>(this);

/* Set up 1D texture mapping: */
renderState.setTextureLevel(1);

/* Bind the color texture object: */
renderState.bindTexture(dataItem->colorMapTextureIds[scalarVariableIndex]);

/* Check if the texture object is outdated: */
const ScalarVariable& sv=scalarVariables[scalarVariableIndex];
if(dataItem->colorMapVersions[scalarVariableIndex]!=sv.colorMapVersion)
{
/* Set the texture object's parameters: */
glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_BASE_LEVEL,0);
glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_MAX_LEVEL,0);
glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

/* Upload the changed color map into the texture object: */
glPixelStorei(GL_UNPACK_SKIP_PIXELS,0);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glTexImage1D(GL_TEXTURE_1D,0,GL_RGBA8,256,0,GL_RGBA,GL_FLOAT,sv.colorMap->getColors());

/* Mark the texture object as up-to-date: */
dataItem->colorMapVersions[scalarVariableIndex]=sv.colorMapVersion;
}

/* Set up the texture matrix to convert scalar variable values to color map indices: */
renderState.setMatrixMode(2);
if(dataItem->lastBoundScalarVariableIndex!=scalarVariableIndex||dataItem->textureMatrixVersion!=renderState.getMatrixVersion())
{
glLoadIdentity();
double mapMin=double(sv.colorMapRange.first);
double mapRange=double(sv.colorMapRange.second)-mapMin;
glScaled(1.0/mapRange,1.0,1.0);
glTranslated(-mapMin,0.0,0.0);
renderState.updateMatrix();

/* Mark the texture matrix as up to date: */
dataItem->lastBoundScalarVariableIndex=scalarVariableIndex;
dataItem->textureMatrixVersion=renderState.getMatrixVersion();
}
}

void VariableManager::endRenderPass(GLRenderState& renderState) const
{
/* Restore the OpenGL texture matrix: */
renderState.setMatrixMode(2);
glPopMatrix();
renderState.updateMatrix();
}

}

}
Loading

0 comments on commit fa61819

Please sign in to comment.