Commit 6dfe3be1 authored by mlarsen's avatar mlarsen

Adding the infastructure to highlight zone picks.



git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@28934 18c085ea-50e0-402c-830e-de6fd14e8384
parent 57604fb6
......@@ -41,6 +41,7 @@
#include <vtkActor.h>
#include <vtkFollower.h>
#include <vtkLineSource.h>
#include <vtkMultiLineSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderer.h>
......@@ -65,12 +66,21 @@
// Brad Whitlock, Fri Aug 27 10:59:33 PDT 2010
// Initialize designator.
//
// Matt Larsen, Fri July 1 09:41:01 PDT 2016
// Added initialization for highlight for zone highlight
// actor, mapper and source
//
// Matt Larsen, Tues July 18 08:11:01 PDT 2016
// Added initialization for showPickLetter
//
// ****************************************************************************
avtPickActor:: avtPickActor()
{
mode3D = true;
useGlyph = false;
showPickLetter = true;
attach[0] = attach[1] = attach[2] = 0.;
designator = "";
......@@ -110,7 +120,11 @@ avtPickActor:: avtPickActor()
glyphActor->GetProperty()->SetColor(0., 0., 0.);
glyphActor->GetProperty()->SetAmbient(1.);
glyphActor->GetProperty()->SetDiffuse(0.);
// Only create highlights if they exist
highlightSource = NULL;
highlightMapper = NULL;
highlightActor = NULL;
renderer = NULL;
}
......@@ -126,6 +140,9 @@ avtPickActor:: avtPickActor()
// Kathleen Bonnell, Fri Jun 27 16:57:45 PDT 2003
// Delete glyphActor, glyphMapper, glyphSource
//
// Matt Larsen, Fri July 1 09:41:01 PDT 2016
// Delete highlightActor, highlightSource,highlightMapper
//
// ****************************************************************************
avtPickActor::~avtPickActor()
......@@ -166,6 +183,21 @@ avtPickActor::~avtPickActor()
lineSource->Delete();
lineSource = NULL;
}
if (highlightSource != NULL)
{
highlightSource->Delete();
highlightSource = NULL;
}
if (highlightMapper != NULL)
{
highlightMapper->Delete();
highlightMapper = NULL;
}
if (highlightActor != NULL)
{
highlightActor->Delete();
highlightActor = NULL;
}
}
......@@ -185,6 +217,9 @@ avtPickActor::~avtPickActor()
// Kathleen Bonnell, Fri Jun 27 16:57:45 PDT 2003
// Add glyphActor to renderer when required.
//
// Matt Larsen, Fri July 1 09:41:01 PDT 2016
// Add highlightActor to renderer.
//
// ****************************************************************************
void
......@@ -194,6 +229,8 @@ avtPickActor::Add(vtkRenderer *ren)
letterActor->SetCamera(renderer->GetActiveCamera());
renderer->AddActor(letterActor);
renderer->AddActor(lineActor);
if(highlightSource != NULL) renderer->AddActor(highlightActor);
if (useGlyph)
{
glyphActor->SetCamera(renderer->GetActiveCamera());
......@@ -214,6 +251,9 @@ avtPickActor::Add(vtkRenderer *ren)
// Kathleen Bonnell, Fri Jun 27 16:57:45 PDT 2003
// Remove glyphActor from renderer when required.
//
// Matt Larsen, Fri July 1 09:41:01 PDT 2016
// Remove highlightActor
//
// ****************************************************************************
void
......@@ -225,6 +265,7 @@ avtPickActor::Remove()
renderer->RemoveActor(glyphActor);
renderer->RemoveActor(lineActor);
renderer->RemoveActor(letterActor);
if(highlightSource != NULL) renderer->RemoveActor(highlightActor);
renderer = NULL;
}
}
......@@ -249,11 +290,13 @@ avtPickActor::Remove()
// Kathleen Bonnell, Tue Jun 8 17:42:59 PDT 2004
// For 2d, use correct vec components.
//
// Matt Larsen, Fri July 1 09:41:01 PDT 2016
// Added highlightSource shift.
// ****************************************************************************
void
avtPickActor::Shift(const double vec[3])
{
{
double newPos[3], newGlyphPos[3], shiftFactor ;
if (mode3D)
{
......@@ -266,7 +309,7 @@ avtPickActor::Shift(const double vec[3])
newGlyphPos[2] = attach[2] + vec[2] *0.25;
glyphActor->SetPosition(newGlyphPos[0], newGlyphPos[1], newGlyphPos[2]);
if(highlightSource != NULL) highlightSource->Shift3d(vec, .7);
}
else
{
......@@ -274,12 +317,16 @@ avtPickActor::Shift(const double vec[3])
newPos[0] = attach[0] + vec[0] *shiftFactor;
newPos[1] = attach[1] + vec[1] *shiftFactor;
newPos[2] = attach[2];
double vec2[3];
vec2[0] = 0.;
vec2[1] = 0.;
vec2[2] = vec[2];
if(highlightSource != NULL) highlightSource->Shift2d(.1);
}
lineSource->SetPoint2(newPos[0], newPos[1], newPos[2]);
letterActor->SetPosition(newPos[0], newPos[1], newPos[2]);
}
// ****************************************************************************
// Method: avtPickActor::SetMode3D
//
......@@ -471,6 +518,8 @@ avtPickActor::SetForegroundColor(double r, double g, double b)
// Kathleen Bonnell, Fri Jun 27 16:57:45 PDT 2003
// Hide glyphActor.
//
// Matt Larsen, Fri July 1 09:41:01 PDT 2016
// hide highlightActor.
// ****************************************************************************
void
......@@ -479,6 +528,7 @@ avtPickActor::Hide()
letterActor->VisibilityOff();
lineActor->VisibilityOff();
glyphActor->VisibilityOff();
if(highlightSource != NULL) highlightActor->VisibilityOff();
}
......@@ -494,14 +544,25 @@ avtPickActor::Hide()
// Kathleen Bonnell, Fri Jun 27 16:57:45 PDT 2003
// Unhide glyphActor.
//
// Matt Larsen, Fri July 1 09:41:01 PDT 2016
// Unhide highlightActor.
//
// Matt Larsen, Tues July 18 09:08:01 PDT 2016
// set visibility on only if pick letter is to be shown
//
// ****************************************************************************
void
avtPickActor::UnHide()
{
letterActor->VisibilityOn();
lineActor->VisibilityOn();
if(showPickLetter)
{
letterActor->VisibilityOn();
lineActor->VisibilityOn();
}
glyphActor->VisibilityOn();
if(highlightSource != NULL) highlightActor->VisibilityOn();
}
......@@ -639,3 +700,82 @@ avtPickActor::GetLetterPosition()
{
return letterActor->GetPosition();
}
// ****************************************************************************
// Method: avtPickActor::AddLine
//
// Purpose: Adds a line for a zone highlight
//
//
// Programmer: Matt Larsen
// Creation: June 30, 2016
//
// Modifications:
//
// ****************************************************************************
void
avtPickActor::AddLine(double p0[3], double p1[3])
{
if(highlightSource == NULL)
{
highlightSource = vtkMultiLineSource::New();
highlightMapper = vtkPolyDataMapper::New();
highlightMapper->SetInputConnection(highlightSource->GetOutputPort());
highlightActor = vtkActor::New();
highlightActor->SetMapper(highlightMapper);
highlightActor->PickableOff();
highlightActor->GetProperty()->SetColor(1., 0., 0.);
highlightActor->GetProperty()->SetAmbient(1.);
highlightActor->GetProperty()->SetDiffuse(0.);
highlightActor->GetProperty()->SetLineWidth(3.);
}
highlightSource->AddLine(p0,p1);
}
// ****************************************************************************
// Method: avtPickActor::GetShowPickLetter
//
// Purpose: returns a boolean indicating if rhe pick letter is show
//
//
// Programmer: Matt Larsen
// Creation: July 18, 2016
//
// Modifications:
//
// ****************************************************************************
bool
avtPickActor::GetShowPickLetter() const
{
return showPickLetter;
}
// ****************************************************************************
// Method: avtPickActor::SetShowPickLetter
//
// Purpose: Sets whether the pick letter is to be shown. It is possilbe to be
// off if highlights are on and letters are off. In the past, if the
// letter was not shown, then no actor was ever created.
//
//
// Programmer: Matt Larsen
// Creation: July 18, 2016
//
// Modifications:
//
// ****************************************************************************
void
avtPickActor::SetShowPickLetter(const bool val)
{
showPickLetter = val;
if(!showPickLetter)
{
letterActor->VisibilityOff();
lineActor->VisibilityOff();
}
}
......@@ -45,11 +45,11 @@
class vtkActor;
class vtkFollower;
class vtkLineSource;
class vtkMultiLineSource;
class vtkPolyDataMapper;
class vtkRenderer;
class vtkGlyphSource2D;
// ****************************************************************************
// Class: avtPickActor
//
......@@ -81,6 +81,13 @@ class vtkGlyphSource2D;
// Burlen Loring, Thu Oct 8 10:36:25 PDT 2015
// fix a compliler warning
//
// Matt Larsen, Thu June 30 08:16:11 PDT 2016
// Adding support for zone highlights.
// Added members for Highlight source, mapper, and actor
// Added method 'AddLine'
// Added methods 'GetShowPickLetter' 'SetShowPickLetter'
// Added member variable showPickLetter
//
// ****************************************************************************
class PLOTTER_API avtPickActor
......@@ -110,10 +117,13 @@ class PLOTTER_API avtPickActor
void Translate(const double vec[3]);
void ResetPosition(const double vec[3]);
void UseGlyph(const bool v) { useGlyph = v; } ;
void AddLine(double p0[3], double p1[3]);
bool GetShowPickLetter() const;
void SetShowPickLetter(const bool);
protected:
bool mode3D;
bool useGlyph;
bool showPickLetter;
double attach[3];
std::string designator;
vtkFollower *letterActor;
......@@ -126,8 +136,11 @@ class PLOTTER_API avtPickActor
vtkGlyphSource2D *glyphSource;
vtkPolyDataMapper *glyphMapper;
vtkRenderer *renderer;
vtkMultiLineSource *highlightSource;
vtkPolyDataMapper *highlightMapper;
vtkActor *highlightActor;
vtkRenderer *renderer;
private:
};
......
......@@ -44,6 +44,7 @@
#include <vtkCell.h>
#include <vtkCellData.h>
#include <vtkDataSet.h>
#include <vtkFieldData.h>
#include <vtkIntArray.h>
......@@ -58,7 +59,6 @@
#include <BadCellException.h>
// ****************************************************************************
// Method: avtPickByZoneQuery constructor
//
......@@ -136,6 +136,10 @@ avtPickByZoneQuery::~avtPickByZoneQuery()
// Use the center found by the DB when available. Fixes a PickByZone bug
// where the returned 'point' didn't match the zone center.
//
// Matt Larsen, Fri Jul 8 08:15:00 PDT 2016
// Added call to base class ExtractZonePickHighlights to support
// zone highlights
//
// ****************************************************************************
void
......@@ -311,6 +315,9 @@ avtPickByZoneQuery::Execute(vtkDataSet *ds, const int dom)
{
pickAtts.SetPickPoint(center);
}
// By this point, the zoneId should be the original zone
// if it was decomposed.
this->ExtractZonePickHighlights(zoneid, ds, dom);
}
......
......@@ -46,8 +46,10 @@
#include <float.h>
#include <snprintf.h>
#include <vtkCell.h>
#include <vtkCellData.h>
#include <vtkDataSet.h>
#include <vtkEdgeTable.h>
#include <vtkIdList.h>
#include <vtkIntArray.h>
#include <vtkMath.h>
......@@ -71,7 +73,6 @@
using std::string;
// ****************************************************************************
// Method: avtPickQuery constructor
//
......@@ -1876,3 +1877,108 @@ avtPickQuery::SetPickAttsForTimeQuery(const PickAttributes *pa)
pickAtts.SetElementIsGlobal(pa->GetElementIsGlobal());
}
// ****************************************************************************
// Method: avtPickQuery::ExtractZonePickHighlights
//
// Purpose:
// Extract the zone edges for pick highlighting. If the data set, has been
// decomposed from something like arbitrary polyhedra, the zone id should
// be the original zone id.
//
// Programmer: Matt Larsen
// Creation: July 8, 2016
//
// ****************************************************************************
void
avtPickQuery::ExtractZonePickHighlights(const int &zoneId,
vtkDataSet *ds,
const int &dom)
{
// Clear anything left over
pickAtts.ClearLines();
// Bail if highlights are not on
if(!pickAtts.GetShowPickHighlight()) return;
// Check to see if the cells were decomposed in some way
vtkDataArray* origCellsArr = ds->GetCellData()->
GetArray("avtOriginalCellNumbers");
if ( (!origCellsArr) || (origCellsArr->GetDataType() != VTK_UNSIGNED_INT)
|| (origCellsArr->GetNumberOfComponents() != 2))
{
// this is a normal cell or could not find the proper
// original cell information. Just extract the lines from the edges
vtkCell *cell = ds->GetCell(zoneId);
const int numEdges = cell->GetNumberOfEdges();
for(int i = 0; i < numEdges; ++i)
{
vtkCell *edge = cell->GetEdge(i);
vtkPoints *edgePoints = edge->GetPoints();
const int numPoints = edgePoints->GetNumberOfPoints();
if(numPoints != 2) continue;
double p1[3];
double p2[3];
edgePoints->GetPoint(0, p1);
edgePoints->GetPoint(1, p2);
pickAtts.AddLine(p1, p2,i);
}
return;
}
else
{
// Find the cells that make up the original cell
const int numCells = ds->GetNumberOfCells();
unsigned int* origCellNums =
((vtkUnsignedIntArray*)origCellsArr)->GetPointer(0);
std::vector<int> relatedCells;
const unsigned int origCell = zoneId;
const unsigned int origDom = dom;
for(int i = 0; i < numCells; ++i)
{
if(origCell == origCellNums[i*2+1] &&
origDom == origCellNums[i*2+0])
relatedCells.push_back(i);
}
// loop over related cells and eliminate duplicate egdes
vtkEdgeTable *edgeTable = vtkEdgeTable::New();
const int numRelated = relatedCells.size();
for(int i = 0; i < numRelated; ++i)
{
const int cellId = relatedCells[i];
vtkCell *cell = ds->GetCell(cellId);
const int numEdges = cell->GetNumberOfEdges();
// estimate some space requirements
if(i == 0) edgeTable->InitEdgeInsertion(numEdges*numRelated);
for(int j = 0; j < numEdges; ++j)
{
vtkCell *edge = cell->GetEdge(j);
vtkPoints *edgePoints = edge->GetPoints();
const int numPoints = edgePoints->GetNumberOfPoints();
if(numPoints != 2) continue;
vtkIdType p1 = edge->GetPointIds()->GetId(0);
vtkIdType p2 = edge->GetPointIds()->GetId(1);
vtkIdType idx = edgeTable->IsEdge(p1,p2);
if(idx == -1) edgeTable->InsertEdge(p1,p2);
}
}
// Iterate through the table and set the points in pictAtts
const int totEdges = edgeTable->GetNumberOfEdges();
edgeTable->InitTraversal();
for(int i = 0; i < totEdges; ++i)
{
vtkIdType p1Id,p2Id;
edgeTable->GetNextEdge(p1Id,p2Id);
double p1[3],p2[2];
ds->GetPoint(p1Id, p1);
ds->GetPoint(p2Id, p2);
pickAtts.AddLine(p1, p2,i);
}
// cleanup
edgeTable->Delete();
}
}
......@@ -141,6 +141,10 @@ class avtExpressionEvaluatorFilter;
// Burlen Loring, Thu Oct 8 12:46:02 PDT 2015
// Fix a couple of warnings
//
// Matt Larsen, Fri Jul 8 08:15:00 PDT 2016
// Added method ExtractZonePickHighlights to support
// zone highlights
//
// ****************************************************************************
class QUERY_API avtPickQuery : public avtDatasetQuery
......@@ -210,6 +214,10 @@ class QUERY_API avtPickQuery : public avtDatasetQuery
void ConvertElNamesToGlobal(void);
void SetRealIds(vtkDataSet *);
void ExtractZonePickHighlights(const int &,
vtkDataSet *,
const int &);
PickAttributes pickAtts;
avtExpressionEvaluatorFilter *eef;
avtQueryableSource *src;
......
......@@ -143,6 +143,10 @@ avtZonePickQuery::SetInvTransform(const avtMatrix *m)
// Kathleen Bonnell, Fri Jul 8 14:15:21 PDT 2005
// Modified test for determining if 'real' id needs to be calculated.
//
// Matt Larsen, Fri Jul 8 08:15:00 PDT 2016
// Added call to base class ExtractZonePickHighlights to support
// zone highlights
//
// ****************************************************************************
void
......@@ -321,6 +325,9 @@ avtZonePickQuery::Execute(vtkDataSet *ds, const int dom)
//
pickAtts.SetCellPoint(pickAtts.GetPickPoint());
}
//By this point, the element Id should be the original zone
//if it was decomposed.
this->ExtractZonePickHighlights(pickAtts.GetElementNumber(), ds, dom);
}
......
......@@ -432,6 +432,9 @@ VisWinQuery::QueryIsValid(const VisualCueInfo *vqPoint, const VisualCueInfo *vqL
// the maximum amount that any plot has been shifted in z. (otherwise
// pick letters may not be visible).
//
// Matt Larsen, Tue Jul 19 12:00:12 PDT 2016
// Added line extracting from visual q for pick highlights.
//
// ****************************************************************************
void
......@@ -464,6 +467,24 @@ VisWinQuery::Pick(const VisualCueInfo *vq)
mediator.GetForegroundColor(fg);
pp->SetForegroundColor(fg);
// Get PickHighlihgt lines if they exist
// first point is the attatchment point
const int numPoints = vq->GetPoints().size() / 3 - 1;
bool linesExist = false;
if(numPoints > 1 && (numPoints % 2 == 0))
linesExist = true;
const int numLines = numPoints / 2;
if(linesExist)
{
for(int i = 0; i < numLines; ++i)
{
double p1[3], p2[3];
// First point is the attactment
vq->GetPointD(i*2+1, p1);
vq->GetPointD(i*2+2, p2);
pp->AddLine(p1, p2);
}
}
//
// Pull the pick actors a little closer to the camera to make sure
// there are no z-buffer errors. Note that canvas issues are hidden
......@@ -493,6 +514,7 @@ VisWinQuery::Pick(const VisualCueInfo *vq)
pp->Shift(shiftVec);
}
pp->SetShowPickLetter(vq->GetShowLabel());
//
// Add the pickpoint to the renderer.
......
This diff is collapsed.
......@@ -1208,6 +1208,60 @@ PickAttributes::SetRayPoint2(const doubleVector &_v)
rayPoint2[2] = _v[2];
}
Function: AddLine
Declaration: void AddLine(const double *_c0, const double *_c1, const int &pos);
Definition:
// ****************************************************************************
// Method: PickAttributes::AddLine
//
// Purpose:
// Add the a line to the pick. This highlights the cell
//
// Programmer: Matt Larsen
// Creation:
//
// Modifications:
//
// ****************************************************************************
void
PickAttributes::AddLine(const double *_c0, const double *_c1, const int &pos)
{
if(!_c0 || !_c1) return; //TODO: is there error checking here?
// extend vector of points as necessary
while ((int)cellCoordinates.size() < 6*(pos+1))
cellCoordinates.push_back(0.0);
cellCoordinates[pos*6+0] = _c0[0];
cellCoordinates[pos*6+1] = _c0[1];
cellCoordinates[pos*6+2] = _c0[2];
cellCoordinates[pos*6+3] = _c1[0];
cellCoordinates[pos*6+4] = _c1[1];
cellCoordinates[pos*6+5] = _c1[2];
}
Function: ClearLines
Declaration: void ClearLines();
Definition:
// ****************************************************************************
// Method: PickAttributes::ClearLines
//
// Purpose:
// Clear the vector of lines for cell highlights
//
// Programmer: Matt Larsen
// Creation:
//
// Modifications:
//
// ****************************************************************************
void
PickAttributes::ClearLines()
{
cellCoordinates.clear();
}
Function: CreateOutputMapNode
Declaration: void CreateOutputMapNode(MapNode &m, bool withLetter);
......@@ -1368,7 +1422,6 @@ PickAttributes::CreateOutputMapNode(MapNode &m, bool withLetter)
}
}
Function: CreateXMLString
Declaration: void CreateXMLString(std::string &os, bool withLetter = true);
Definition:
......@@ -1419,7 +1472,6 @@ PyPickAttributes_GetLogString()
return s;
}
Function: PyPickAttributes_CallLogRoutine
Declaration: static void PyPickAttributes_CallLogRoutine(Subject *subj, void *data)
Definition:
......
......@@ -112,6 +112,7 @@ public:
void SelectVariables();
void SelectPickLetter();
void SelectIncidentElements();
void SelectCellCoordinates();
void SelectDatabaseName();
void SelectActiveVariable();
void SelectPickPoint();
......@@ -156,6 +157,7 @@ public:
void SetDomain(int domain_);
void SetElementNumber(int elementNumber_);
void SetIncidentElements(const intVector &incidentElements_);
void SetCellCoordinates(const doubleVector &cellCoordinates_);
void SetTimeStep(int timeStep_);
void SetDimension(int dimension_);
void SetDatabaseName(const std::string &databaseName_);
......@@ -200,6 +202,7 @@ public:
void SetGhostType(int ghostType_);
void SetHasMixedGhostTypes(int hasMixedGhostTypes_);
void SetLinesData(bool linesData_);
void SetShowPickHighlight(bool showPickHighlight_);
void SetInputTopoDim(int inputTopoDim_);
void SetMeshCoordType(CoordinateType meshCoordType_);
void SetCreateSpreadsheet(bool createSpreadsheet_);
......@@ -230,6 +233,8 @@ public:
int GetElementNumber() const;
const intVector &GetIncidentElements() const;
intVector &GetIncidentElements();
const doubleVector &GetCellCoordinates() const;
doubleVector &GetCellCoordinates();
int GetTimeStep() const;
int GetDimension() const;
const std::string &GetDatabaseName() const;
......@@ -297,6 +302,7 @@ public:
int GetGhostType() const;
int GetHasMixedGhostTypes() const;
bool GetLinesData() const;
bool GetShowPickHighlight() const;
int GetInputTopoDim() const;
CoordinateType GetMeshCoordType() const;
bool GetCreateSpreadsheet() const;
......@@ -357,6 +363,8 @@ public:
void CreateConciseOutputString(std::string &os, bool withLetter = true);
void SetRayPoint1(const doubleVector &);
void SetRayPoint2(const doubleVector &);
void AddLine(const double *_c0, const double *_c1, const int &pos);
void ClearLines();
void CreateOutputMapNode(MapNode &m, bool withLetter);
void CreateXMLString(std::string &os, bool withLetter = true);
......@@ -378,6 +386,7 @@ public:
ID_domain,
ID_elementNumber,
ID_incidentElements,
ID_cellCoordinates,
ID_timeStep,
ID_dimension,
ID_databaseName,
......@@ -423,6 +432,7 @@ public:
ID_ghostType,
ID_hasMixedGhostTypes,
ID_linesData,
ID_showPickHighlight,
ID_inputTopoDim,
ID_meshCoordType,
ID_createSpreadsheet,
......@@ -454,6 +464,7 @@ private:
int domain;
int elementNumber;
intVector incidentElements;
doubleVector cellCoordinates;
int timeStep;
int dimension;
std::string databaseName;
......@@ -499,6 +510,7 @@ private:
int ghostType;
int hasMixedGhostTypes;
bool linesData;
bool showPickHighlight;
int inputTopoDim;
int meshCoordType;
bool createSpreadsheet;
......@@ -513,6 +525,6 @@ private:
static const char *TypeMapFormatString;
static const private_tmfs_t TmfsStruct;
};
#define PICKATTRIBUTES_TMFS "s*bbbbbbbbbsbiiii*iissDDDd*DDsii*s*s*s*s*s*ba*s*bsbbbbbbssi*bbbbbii*bbbiibiibssbimm"
#define PICKATTRIBUTES_TMFS "s*bbbbbbbbbsbiiii*d*iissDDDd*DDsii*s*s*s*s*s*ba*s*bsbbbbbbssi*bbbbbii*bbbiibbiibssbimm"
#endif
......@@ -63,6 +63,8 @@
</Field>
<Field name="incidentElements" label="incidentElements" type="intVector" internal="true" persistent="false">