Commit 73185627 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit Committed by Kitware Robot
Browse files

Merge topic 'scatter-plot-matrix-pc' into pv-master

9cdf34eb Added new API to manipulate path animations
f6d670a7 Added hyperjump to the scatter plot matrix
d49524a9 Store the viewport and tile size in the device
parents 67bf78e3 9cdf34eb
......@@ -220,9 +220,16 @@ int vtkContextActor::RenderOverlay(vtkViewport* viewport)
this->Initialize(viewport);
}
// Pass the viewport details onto the context device.
int size[2];
size[0] = view_viewport_pixels.width();
size[1] = view_viewport_pixels.height();
vtkRecti viewportRect(actual_viewport_pixels.x() - view_viewport_pixels.x(),
actual_viewport_pixels.y() - view_viewport_pixels.y(),
actual_viewport_pixels.width(),
actual_viewport_pixels.height());
this->Context->GetDevice()->SetViewportSize(vtkVector2i(size));
this->Context->GetDevice()->SetViewportRect(viewportRect);
// This is the entry point for all 2D rendering.
// First initialize the drawing device.
......
......@@ -43,12 +43,6 @@ bool vtkContextClip::Paint(vtkContext2D *painter)
// Clip rendering for all child items.
// Check whether the scene has a transform - use it if so
float *clipBy = this->Dims;
float clip[4];
if (this->Scene->HasTransform())
{
this->Scene->GetTransform()->InverseTransformPoints(this->Dims, clip, 2);
clipBy = clip;
}
int clipi[] = { vtkContext2D::FloatToInt(clipBy[0]),
vtkContext2D::FloatToInt(clipBy[1]),
......
......@@ -24,6 +24,8 @@
#define __vtkContextDevice2D_h
#include "vtkObject.h"
#include "vtkVector.h" // For vtkVector2i ivar
#include "vtkRect.h" // For vtkRecti ivar
class vtkWindow;
class vtkViewport;
......@@ -36,7 +38,6 @@ class vtkMatrix3x3;
class vtkAbstractContextBufferId;
class vtkPen;
class vtkBrush;
class vtkRectf;
class VTK_CHARTS_EXPORT vtkContextDevice2D : public vtkObject
{
......@@ -269,6 +270,16 @@ public:
// \post done: !GetBufferIdMode()
virtual void BufferIdModeEnd();
virtual void SetViewportSize(const vtkVector2i &size)
{
this->ViewportSize = size;
}
virtual void SetViewportRect(const vtkRecti &rect)
{
this->ViewportRect = rect;
}
//BTX
protected:
vtkContextDevice2D();
......@@ -278,6 +289,14 @@ protected:
// Store the width and height of the device in pixels.
int Geometry[2];
// Description:
// Store the size of the total viewport.
vtkVector2i ViewportSize;
// Description:
// Store our origin and size in the total viewport.
vtkRecti ViewportRect;
vtkAbstractContextBufferId *BufferId;
vtkPen *Pen; // Outlining
......
......@@ -23,6 +23,7 @@
#include "vtkVector.h"
#include "vtkRect.h"
#include "vtkVectorOperators.h"
#include "vtkPen.h"
#include "vtkBrush.h"
#include "vtkTextProperty.h"
......@@ -1068,11 +1069,25 @@ void vtkOpenGLContextDevice2D::PopMatrix()
}
//-----------------------------------------------------------------------------
void vtkOpenGLContextDevice2D::SetClipping(int *dim)
void vtkOpenGLContextDevice2D::SetClipping(int *d)
{
// Check the bounds, and clamp if necessary
GLint vp[4] = { this->Storage->Offset.GetX(), this->Storage->Offset.GetY(),
this->Storage->Dim.GetX(),this->Storage->Dim.GetY()};
this->Storage->Dim.GetX(),this->Storage->Dim.GetY() };
// Adjust the clipping rectangle for the tiled viewport.
int dim[] = { d[0] - this->ViewportRect.X(),
d[1] - this->ViewportRect.Y(),
d[2] - this->ViewportRect.X(),
d[3] - this->ViewportRect.Y() };
if (this->ViewportRect.X() > 0)
{
dim[2] += d[0];
}
if (this->ViewportRect.Y() > 0)
{
dim[3] += d[1];
}
if (dim[0] > 0 && dim[0] < vp[2] )
{
......
......@@ -606,6 +606,7 @@ void vtkScatterPlotMatrix::AdvanceAnimation()
// 5: Make the new dimensionality active, update BigChart.
// 5: Make BigChart3D invisible and BigChart visible.
// 6: Stop the timer.
this->InvokeEvent(vtkCommand::AnimationCueTickEvent);
switch (this->Private->AnimationPhase)
{
case 0: // Remove decoration from the big chart, load up the 3D chart
......@@ -1098,28 +1099,99 @@ bool vtkScatterPlotMatrix::MouseButtonReleaseEvent(
{
// Work out which scatter plot was clicked - make that one the active plot.
int n = this->GetSize().X();
vtkVector2i pos(0, 0);
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < n; ++j)
{
if (i + j + 1 < n && this->GetChart(vtkVector2i(i, j))->Hit(mouse))
{
vtkVector2i pos(i, j);
this->UpdateAnimationPath(pos);
if(this->Private->AnimationPath.size()>0)
{
this->StartAnimation(mouse.GetInteractor());
}
else
{
this->SetActivePlot(pos);
}
return true;
pos = vtkVector2i(i, j);
}
}
}
return false;
// If the left button was used, hyperjump, if the right was used full path.
if (mouse.GetButton() == vtkContextMouseEvent::LEFT_BUTTON)
{
this->Private->AnimationPath.clear();
if (pos[0] != this->ActivePlot[0])
{
this->Private->AnimationPath.push_back(vtkVector2i(pos[0],
this->ActivePlot[1]));
}
if (pos[1] != this->ActivePlot[1])
{
this->Private->AnimationPath.push_back(pos);
}
if (this->Private->AnimationPath.size() > 0)
{
this->InvokeEvent(vtkCommand::CreateTimerEvent);
this->StartAnimation(mouse.GetInteractor());
}
}
else if (mouse.GetButton() == vtkContextMouseEvent::RIGHT_BUTTON)
{
this->UpdateAnimationPath(pos);
if (this->Private->AnimationPath.size() > 0)
{
this->InvokeEvent(vtkCommand::CreateTimerEvent);
this->StartAnimation(mouse.GetInteractor());
}
else
{
this->SetActivePlot(pos);
}
}
return true;
}
void vtkScatterPlotMatrix::ClearAnimationPath()
{
this->Private->AnimationPath.clear();
}
vtkIdType vtkScatterPlotMatrix::GetNumberOfAnimationPathElements()
{
return static_cast<vtkIdType>(this->Private->AnimationPath.size());
}
vtkVector2i vtkScatterPlotMatrix::GetAnimationPathElement(vtkIdType i)
{
return this->Private->AnimationPath.at(i);
}
bool vtkScatterPlotMatrix::AddAnimationPath(const vtkVector2i &move)
{
vtkVector2i pos = this->ActivePlot;
if (this->Private->AnimationPath.size())
{
pos = this->Private->AnimationPath.back();
}
if (move.X() != pos.X() && move.Y() != pos.Y())
{
// Can only move in x or y, not both. Do not append the element.
return false;
}
else
{
this->Private->AnimationPath.push_back(move);
return true;
}
}
bool vtkScatterPlotMatrix::BeginAnimationPath(vtkRenderWindowInteractor* interactor)
{
if (interactor && this->Private->AnimationPath.size())
{
this->StartAnimation(interactor);
return true;
}
else
{
return false;
}
}
int vtkScatterPlotMatrix::GetPlotType(const vtkVector2i &pos)
......
......@@ -275,6 +275,33 @@ public:
// Get the column name for the supplied index.
vtkStdString GetRowName(int row);
// Description:
// Clear the animation path.
void ClearAnimationPath();
// Description:
// Add a move to the animation path. Note that a move can only change i or j,
// not both. If the proposed move does not satisfy those criteria it will
// be rejected and the animation path will not be extended.
bool AddAnimationPath(const vtkVector2i &move);
// Description:
// Get the number of elements (transitions) in the animation path.
vtkIdType GetNumberOfAnimationPathElements();
// Description:
// Get the element specified from the animation path.
vtkVector2i GetAnimationPathElement(vtkIdType i);
// Description:
// Trigger the animation of the scatter plot matrix to begin.
bool BeginAnimationPath(vtkRenderWindowInteractor* interactor);
// Description:
// Advance the animation in response to the timer events. This is public to
// allow the animation to be manually advanced when timers are not a
virtual void AdvanceAnimation();
protected:
vtkScatterPlotMatrix();
~vtkScatterPlotMatrix();
......@@ -304,10 +331,6 @@ protected:
// animation path calculated above.
virtual void StartAnimation(vtkRenderWindowInteractor* interactor);
// Description:
// Advance the animation in response to the timer events.
virtual void AdvanceAnimation();
// Description:
// Process events and dispatch to the appropriate member functions.
static void ProcessEvents(vtkObject *caller, unsigned long event,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment