or [-] keyboard buttons.</li>
<li><b>Modification Mode</b> - allows choosing between \b Arithmetic
and \b Geometrical progression used for zooming</li>
+<li><b>Show static trihedron</b> - allows to show/hide static trihedron
+located in the bottom-left corner of the viewer.
</ul>
<li><b>Spacemouse</b> - a mouse-like manipulator device specially designed
for working with 3D presentations, objects, etc. You can reassign the
vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) );
vm->setTrihedronSize( resMgr->doubleValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ),
resMgr->booleanValue( "VTKViewer", "relative_size", vm->trihedronRelative() ) );
+ vm->setStaticTrihedronVisible( resMgr->booleanValue( "VTKViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
vm->setInteractionStyle( resMgr->integerValue( "VTKViewer", "navigation_mode", vm->interactionStyle() ) );
vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
pref->setItemProperty( "strings", aSpeedModeList, vtkSpeedMode );
pref->setItemProperty( "indexes", aModeIndexesList, vtkSpeedMode );
+ pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), vtkGen, LightApp_Preferences::Bool, "VTKViewer", "show_static_trihedron" );
+
int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
pref->setItemProperty( "columns", 2, vtkSM );
int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
}
#endif
+#ifndef DISABLE_VTKVIEWER
+ if ( sec == QString( "VTKViewer" ) && param == QString( "show_static_trihedron" ) )
+ {
+ bool isVisible = resMgr->booleanValue( "VTKViewer", "show_static_trihedron", true );
+ QList<SUIT_ViewManager*> lst;
+#ifndef DISABLE_SALOMEOBJECT
+ viewManagers( SVTK_Viewer::Type(), lst );
+ QListIterator<SUIT_ViewManager*> it( lst );
+ while ( it.hasNext() )
+ {
+ SUIT_ViewModel* vm = it.next()->getViewModel();
+ if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
+ continue;
+
+ SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
+ if( vtkVM )
+ {
+ vtkVM->setStaticTrihedronVisible( isVisible );
+ vtkVM->Repaint();
+ }
+ }
+#endif
+ }
+#endif
+
#ifndef DISABLE_VTKVIEWER
if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
param == QString( "spacemouse_func2_btn" ) ||
<parameter name="navigation_mode" value="0" />
<parameter name="speed_value" value="10" />
<parameter name="speed_mode" value="0" />
+ <parameter name="show_static_trihedron" value="true" />
<parameter name="spacemouse_func1_btn" value="1" />
<parameter name="spacemouse_func2_btn" value="2" />
<parameter name="spacemouse_func5_btn" value="9" />
<source>PREF_FRAME_SPACEMOUSE</source>
<translation>Spacemouse</translation>
</message>
+ <message>
+ <source>PREF_SHOW_STATIC_TRIHEDRON</source>
+ <translation>Show static trihedron</translation>
+ </message>
<message>
<source>PREF_SPACEMOUSE_FUNC_1</source>
<translation>Decrease speed increment</translation>
SVTK_Recorder.cxx \
SVTK_RecorderDlg.cxx \
SVTK_ImageWriter.cxx \
- SVTK_ImageWriterMgr.cxx
+ SVTK_ImageWriterMgr.cxx \
+ vtkPVAxesActor.cxx \
+ vtkPVAxesWidget.cxx
# internal headers
{
myTrihedronSize = 105;
myTrihedronRelative = true;
+ myIsStaticTrihedronVisible = true;
myIncrementSpeed = 10;
myIncrementMode = 0;
myProjMode = 0;
aViewWindow->setBackgroundColor( backgroundColor() );
aViewWindow->SetTrihedronSize( trihedronSize(), trihedronRelative() );
+ aViewWindow->SetStaticTrihedronVisible( isStaticTrihedronVisible() );
aViewWindow->SetProjectionMode( projectionMode() );
aViewWindow->SetInteractionStyle( interactionStyle() );
aViewWindow->SetIncrementalSpeed( incrementalSpeed(), incrementalSpeedMode() );
}
}
+/*!
+ \return visibility status of the static trihedron
+*/
+bool SVTK_Viewer::isStaticTrihedronVisible() const
+{
+ return myIsStaticTrihedronVisible;
+}
+
+/*!
+ Sets visibility status of the static trihedron
+ \param theIsVisible - new visibility status
+*/
+void SVTK_Viewer::setStaticTrihedronVisible( const bool theIsVisible )
+{
+ myIsStaticTrihedronVisible = theIsVisible;
+
+ if (SUIT_ViewManager* aViewManager = getViewManager()) {
+ QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+ for ( uint i = 0; i < aViews.count(); i++ )
+ {
+ if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
+ aView->SetStaticTrihedronVisible( theIsVisible );
+ }
+ }
+}
/*!
\return projection mode
//! Set size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize)
void setTrihedronSize( const vtkFloatingPointType, const bool = true );
+ //! Get visibility status of the static trihedron
+ bool isStaticTrihedronVisible() const;
+
+ //! Set visibility status of the static trihedron
+ void setStaticTrihedronVisible( const bool );
+
//! Gets projection mode
int projectionMode() const;
QColor myBgColor;
vtkFloatingPointType myTrihedronSize;
bool myTrihedronRelative;
+ bool myIsStaticTrihedronVisible;
bool mySelectionEnabled;
bool myMultiSelectionEnabled;
int myIncrementSpeed;
#include <vtkAxisActor2D.h>
#include <vtkGL2PSExporter.h>
#include <vtkInteractorStyle.h>
+#include <vtkProperty.h>
#include "QtxAction.h"
#include "SVTK_Recorder.h"
#include "SVTK_RecorderDlg.h"
+#include "vtkPVAxesWidget.h"
+#include "vtkPVAxesActor.h"
+
#include "SALOME_ListIteratorOfListIO.hxx"
#include "VTKViewer_Algorithm.h"
setCentralWidget(myInteractor);
+ myAxesWidget = vtkPVAxesWidget::New();
+ myAxesWidget->SetParentRenderer(aRenderer->GetDevice());
+ myAxesWidget->SetViewport(0, 0, 0.25, 0.25);
+ myAxesWidget->SetInteractor(myInteractor->GetDevice());
+ myAxesWidget->SetEnabled(1);
+ myAxesWidget->SetInteractive(0);
+
+ vtkPVAxesActor* anAxesActor = myAxesWidget->GetAxesActor();
+ anAxesActor->GetXAxisTipProperty()->SetColor( 1.0, 0.0, 0.0 );
+ anAxesActor->GetXAxisShaftProperty()->SetColor( 1.0, 0.0, 0.0 );
+ anAxesActor->GetXAxisLabelProperty()->SetColor( 1.0, 0.0, 0.0 );
+ anAxesActor->GetYAxisTipProperty()->SetColor( 0.0, 1.0, 0.0 );
+ anAxesActor->GetYAxisShaftProperty()->SetColor( 0.0, 1.0, 0.0 );
+ anAxesActor->GetYAxisLabelProperty()->SetColor( 0.0, 1.0, 0.0 );
+ anAxesActor->GetZAxisTipProperty()->SetColor( 0.0, 0.0, 1.0 );
+ anAxesActor->GetZAxisShaftProperty()->SetColor( 0.0, 0.0, 1.0 );
+ anAxesActor->GetZAxisLabelProperty()->SetColor( 0.0, 0.0, 1.0 );
+
myView = new SVTK_View(this);
Initialize(myView,theModel);
myView->SetSelectionTolerance(theTolNodes, theTolItems, theTolObjects);
}
+/*!
+ Get visibility status of the static trihedron
+*/
+bool SVTK_ViewWindow::IsStaticTrihedronVisible() const
+{
+ return (bool)myAxesWidget->GetEnabled();
+}
+
+/*!
+ Set visibility status of the static trihedron
+*/
+void SVTK_ViewWindow::SetStaticTrihedronVisible( const bool theIsVisible )
+{
+ myAxesWidget->SetEnabled( (int)theIsVisible );
+}
+
/*!
Performs action
\param accelAction - action
class SVTK_ViewParameterDlg;
class SVTK_Recorder;
+class vtkPVAxesWidget;
+
class vtkObject;
class QtxAction;
const double& theTolCell = 0.001,
const double& theTolObjects = 0.025);
+ //! Get visibility status of the static trihedron
+ bool IsStaticTrihedronVisible() const;
+
+ //! Set visibility status of the static trihedron
+ virtual void SetStaticTrihedronVisible( const bool );
+
//! Methods to save/restore visual parameters of a view (pan, zoom, etc.)
virtual QString getVisualParameters();
int myToolBar;
int myRecordingToolBar;
+ vtkPVAxesWidget* myAxesWidget;
+
private:
QImage myDumpImage;
};
--- /dev/null
+/*=========================================================================
+
+ Program: ParaView
+ Module: $RCSfile$
+
+ Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
+ All rights reserved.
+
+ ParaView is a free software; you can redistribute it and/or modify it
+ under the terms of the ParaView license version 1.2.
+
+ See License_v1.2.txt for the full ParaView license.
+ A copy of this license can be obtained by contacting
+ Kitware Inc.
+ 28 Corporate Drive
+ Clifton Park, NY 12065
+ USA
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=========================================================================*/
+#include "vtkPVAxesActor.h"
+#include "vtkObject.h"
+#include "vtkObjectFactory.h"
+
+#include "vtkActor.h"
+#include "vtkPropCollection.h"
+#include "vtkProperty.h"
+#include "vtkRenderWindow.h"
+#include "vtkTransform.h"
+#include "vtkCylinderSource.h"
+#include "vtkPolyDataMapper.h"
+#include "vtkLineSource.h"
+#include "vtkPolyData.h"
+#include "vtkConeSource.h"
+#include "vtkSphereSource.h"
+#include "vtkVectorText.h"
+#include "vtkFollower.h"
+#include "vtkRenderer.h"
+
+#include <math.h>
+
+vtkCxxRevisionMacro(vtkPVAxesActor, "$Revision$");
+vtkStandardNewMacro(vtkPVAxesActor);
+
+vtkCxxSetObjectMacro( vtkPVAxesActor, UserDefinedTip, vtkPolyData );
+vtkCxxSetObjectMacro( vtkPVAxesActor, UserDefinedShaft, vtkPolyData );
+
+//-----------------------------------------------------------------------------
+vtkPVAxesActor::vtkPVAxesActor()
+{
+ this->XAxisLabelText = NULL;
+ this->YAxisLabelText = NULL;
+ this->ZAxisLabelText = NULL;
+
+ this->SetXAxisLabelText("X");
+ this->SetYAxisLabelText("Y");
+ this->SetZAxisLabelText("Z");
+
+ //colors chosen to match the output of vtkAxes.cxx's LUT.
+ this->XAxisShaft = vtkActor::New();
+ this->XAxisShaft->GetProperty()->SetColor(1, 0, 0);
+ this->YAxisShaft = vtkActor::New();
+ this->YAxisShaft->GetProperty()->SetColor(1, 1, 0);
+ this->ZAxisShaft = vtkActor::New();
+ this->ZAxisShaft->GetProperty()->SetColor(0, 1, 0);
+
+ this->XAxisTip = vtkActor::New();
+ this->XAxisTip->GetProperty()->SetColor(1, 0, 0);
+ this->YAxisTip = vtkActor::New();
+ this->YAxisTip->GetProperty()->SetColor(1, 1, 0);
+ this->ZAxisTip = vtkActor::New();
+ this->ZAxisTip->GetProperty()->SetColor(0, 1, 0);
+
+ this->CylinderSource = vtkCylinderSource::New();
+ this->CylinderSource->SetHeight(1.0);
+
+ this->LineSource = vtkLineSource::New();
+ this->LineSource->SetPoint1( 0.0, 0.0, 0.0 );
+ this->LineSource->SetPoint2( 0.0, 1.0, 0.0 );
+
+ this->ConeSource = vtkConeSource::New();
+ this->ConeSource->SetDirection( 0, 1, 0 );
+ this->ConeSource->SetHeight( 1.0 );
+
+ this->SphereSource = vtkSphereSource::New();
+
+ vtkPolyDataMapper *shaftMapper = vtkPolyDataMapper::New();
+
+ this->XAxisShaft->SetMapper( shaftMapper );
+ this->YAxisShaft->SetMapper( shaftMapper );
+ this->ZAxisShaft->SetMapper( shaftMapper );
+
+ shaftMapper->Delete();
+
+ vtkPolyDataMapper *tipMapper = vtkPolyDataMapper::New();
+
+ this->XAxisTip->SetMapper( tipMapper );
+ this->YAxisTip->SetMapper( tipMapper );
+ this->ZAxisTip->SetMapper( tipMapper );
+
+ tipMapper->Delete();
+
+ this->TotalLength[0] = 1.0;
+ this->TotalLength[1] = 1.0;
+ this->TotalLength[2] = 1.0;
+
+ this->NormalizedShaftLength[0] = 0.8;
+ this->NormalizedShaftLength[1] = 0.8;
+ this->NormalizedShaftLength[2] = 0.8;
+
+ this->NormalizedTipLength[0] = 0.2;
+ this->NormalizedTipLength[1] = 0.2;
+ this->NormalizedTipLength[2] = 0.2;
+
+ this->ConeResolution = 16;
+ this->SphereResolution = 16;
+ this->CylinderResolution = 16;
+
+ this->ConeRadius = 0.4;
+ this->SphereRadius = 0.5;
+ this->CylinderRadius = 0.05;
+
+ this->XAxisLabelPosition = 1;
+ this->YAxisLabelPosition = 1;
+ this->ZAxisLabelPosition = 1;
+
+ this->ShaftType = vtkPVAxesActor::LINE_SHAFT;
+ this->TipType = vtkPVAxesActor::CONE_TIP;
+
+ this->UserDefinedTip = NULL;
+ this->UserDefinedShaft = NULL;
+
+ this->XAxisVectorText = vtkVectorText::New();
+ this->YAxisVectorText = vtkVectorText::New();
+ this->ZAxisVectorText = vtkVectorText::New();
+
+ this->XAxisLabel = vtkFollower::New();
+ this->YAxisLabel = vtkFollower::New();
+ this->ZAxisLabel = vtkFollower::New();
+
+ vtkPolyDataMapper *xmapper = vtkPolyDataMapper::New();
+ vtkPolyDataMapper *ymapper = vtkPolyDataMapper::New();
+ vtkPolyDataMapper *zmapper = vtkPolyDataMapper::New();
+
+ xmapper->SetInput( this->XAxisVectorText->GetOutput() );
+ ymapper->SetInput( this->YAxisVectorText->GetOutput() );
+ zmapper->SetInput( this->ZAxisVectorText->GetOutput() );
+
+ this->XAxisLabel->SetMapper( xmapper );
+ this->YAxisLabel->SetMapper( ymapper );
+ this->ZAxisLabel->SetMapper( zmapper );
+
+ xmapper->Delete();
+ ymapper->Delete();
+ zmapper->Delete();
+
+ this->UpdateProps();
+}
+
+//-----------------------------------------------------------------------------
+vtkPVAxesActor::~vtkPVAxesActor()
+{
+ this->CylinderSource->Delete();
+ this->LineSource->Delete();
+ this->ConeSource->Delete();
+ this->SphereSource->Delete();
+
+ this->XAxisShaft->Delete();
+ this->YAxisShaft->Delete();
+ this->ZAxisShaft->Delete();
+
+ this->XAxisTip->Delete();
+ this->YAxisTip->Delete();
+ this->ZAxisTip->Delete();
+
+ this->SetUserDefinedTip( NULL );
+ this->SetUserDefinedShaft( NULL );
+
+ this->SetXAxisLabelText( NULL );
+ this->SetYAxisLabelText( NULL );
+ this->SetZAxisLabelText( NULL );
+
+ this->XAxisVectorText->Delete();
+ this->YAxisVectorText->Delete();
+ this->ZAxisVectorText->Delete();
+
+ this->XAxisLabel->Delete();
+ this->YAxisLabel->Delete();
+ this->ZAxisLabel->Delete();
+}
+
+//-----------------------------------------------------------------------------
+// Shallow copy of an actor.
+void vtkPVAxesActor::ShallowCopy(vtkProp *prop)
+{
+ vtkPVAxesActor *a = vtkPVAxesActor::SafeDownCast(prop);
+ if ( a != NULL )
+ {
+ }
+
+ // Now do superclass
+ this->vtkProp3D::ShallowCopy(prop);
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVAxesActor::GetActors(vtkPropCollection *ac)
+{
+ ac->AddItem(this->XAxisShaft);
+ ac->AddItem(this->YAxisShaft);
+ ac->AddItem(this->ZAxisShaft);
+ ac->AddItem(this->XAxisTip);
+ ac->AddItem(this->YAxisTip);
+ ac->AddItem(this->ZAxisTip);
+ ac->AddItem(this->XAxisLabel);
+ ac->AddItem(this->YAxisLabel);
+ ac->AddItem(this->ZAxisLabel);
+
+}
+
+//-----------------------------------------------------------------------------
+int vtkPVAxesActor::RenderOpaqueGeometry(vtkViewport *vp)
+{
+ int renderedSomething = 0;
+
+ vtkRenderer *ren = vtkRenderer::SafeDownCast( vp );
+
+ this->UpdateProps();
+
+ this->XAxisLabel->SetCamera( ren->GetActiveCamera() );
+ this->YAxisLabel->SetCamera( ren->GetActiveCamera() );
+ this->ZAxisLabel->SetCamera( ren->GetActiveCamera() );
+
+ this->XAxisShaft->RenderOpaqueGeometry(vp);
+ this->YAxisShaft->RenderOpaqueGeometry(vp);
+ this->ZAxisShaft->RenderOpaqueGeometry(vp);
+
+ this->XAxisTip->RenderOpaqueGeometry(vp);
+ this->YAxisTip->RenderOpaqueGeometry(vp);
+ this->ZAxisTip->RenderOpaqueGeometry(vp);
+
+ this->XAxisLabel->RenderOpaqueGeometry(vp);
+ this->YAxisLabel->RenderOpaqueGeometry(vp);
+ this->ZAxisLabel->RenderOpaqueGeometry(vp);
+
+ return renderedSomething;
+}
+
+//-----------------------------------------------------------------------------
+// porting to VTK 5.0.x
+/*
+int vtkPVAxesActor::RenderTranslucentPolygonalGeometry(vtkViewport *vp)
+{
+ int renderedSomething=0;
+
+ this->UpdateProps();
+
+ renderedSomething += this->XAxisShaft->RenderTranslucentPolygonalGeometry(vp);
+ renderedSomething += this->YAxisShaft->RenderTranslucentPolygonalGeometry(vp);
+ renderedSomething += this->ZAxisShaft->RenderTranslucentPolygonalGeometry(vp);
+
+ renderedSomething += this->XAxisTip->RenderTranslucentPolygonalGeometry(vp);
+ renderedSomething += this->YAxisTip->RenderTranslucentPolygonalGeometry(vp);
+ renderedSomething += this->ZAxisTip->RenderTranslucentPolygonalGeometry(vp);
+
+ renderedSomething += this->XAxisLabel->RenderTranslucentPolygonalGeometry(vp);
+ renderedSomething += this->YAxisLabel->RenderTranslucentPolygonalGeometry(vp);
+ renderedSomething += this->ZAxisLabel->RenderTranslucentPolygonalGeometry(vp);
+
+ return renderedSomething;
+}
+*/
+
+//-----------------------------------------------------------------------------
+// porting to VTK 5.0.x
+/*
+int vtkPVAxesActor::HasTranslucentPolygonalGeometry()
+{
+ int result = 0;
+
+ this->UpdateProps();
+
+ result |= this->XAxisShaft->HasTranslucentPolygonalGeometry();
+ result |= this->YAxisShaft->HasTranslucentPolygonalGeometry();
+ result |= this->ZAxisShaft->HasTranslucentPolygonalGeometry();
+
+ result |= this->XAxisTip->HasTranslucentPolygonalGeometry();
+ result |= this->YAxisTip->HasTranslucentPolygonalGeometry();
+ result |= this->ZAxisTip->HasTranslucentPolygonalGeometry();
+
+ result |= this->XAxisLabel->HasTranslucentPolygonalGeometry();
+ result |= this->YAxisLabel->HasTranslucentPolygonalGeometry();
+ result |= this->ZAxisLabel->HasTranslucentPolygonalGeometry();
+
+ return result;
+}
+*/
+
+//-----------------------------------------------------------------------------
+// porting to VTK 5.0.x
+int vtkPVAxesActor::RenderTranslucentGeometry(vtkViewport *vp)
+{
+ int renderedSomething=0;
+
+ this->UpdateProps();
+
+ renderedSomething += this->XAxisShaft->RenderTranslucentGeometry(vp);
+ renderedSomething += this->YAxisShaft->RenderTranslucentGeometry(vp);
+ renderedSomething += this->ZAxisShaft->RenderTranslucentGeometry(vp);
+
+ renderedSomething += this->XAxisTip->RenderTranslucentGeometry(vp);
+ renderedSomething += this->YAxisTip->RenderTranslucentGeometry(vp);
+ renderedSomething += this->ZAxisTip->RenderTranslucentGeometry(vp);
+
+ renderedSomething += this->XAxisLabel->RenderTranslucentGeometry(vp);
+ renderedSomething += this->YAxisLabel->RenderTranslucentGeometry(vp);
+ renderedSomething += this->ZAxisLabel->RenderTranslucentGeometry(vp);
+
+ return renderedSomething;
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVAxesActor::ReleaseGraphicsResources(vtkWindow *win)
+{
+ this->XAxisShaft->ReleaseGraphicsResources( win );
+ this->YAxisShaft->ReleaseGraphicsResources( win );
+ this->ZAxisShaft->ReleaseGraphicsResources( win );
+
+ this->XAxisTip->ReleaseGraphicsResources( win );
+ this->YAxisTip->ReleaseGraphicsResources( win );
+ this->ZAxisTip->ReleaseGraphicsResources( win );
+
+ this->XAxisLabel->ReleaseGraphicsResources( win );
+ this->YAxisLabel->ReleaseGraphicsResources( win );
+ this->ZAxisLabel->ReleaseGraphicsResources( win );
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVAxesActor::GetBounds(double bounds[6])
+{
+ double *bds = this->GetBounds();
+ bounds[0] = bds[0];
+ bounds[1] = bds[1];
+ bounds[2] = bds[2];
+ bounds[3] = bds[3];
+ bounds[4] = bds[4];
+ bounds[5] = bds[5];
+}
+
+//-----------------------------------------------------------------------------
+// Get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
+double *vtkPVAxesActor::GetBounds()
+{
+ double bounds[6];
+ int i;
+
+ this->XAxisShaft->GetBounds(this->Bounds);
+
+ this->YAxisShaft->GetBounds(bounds);
+ for (i=0; i<3; i++)
+ {
+ this->Bounds[2*i+1] =
+ (bounds[2*i+1]>this->Bounds[2*i+1])?(bounds[2*i+1]):(this->Bounds[2*i+1]);
+ }
+
+ this->ZAxisShaft->GetBounds(bounds);
+ for (i=0; i<3; i++)
+ {
+ this->Bounds[2*i+1] =
+ (bounds[2*i+1]>this->Bounds[2*i+1])?(bounds[2*i+1]):(this->Bounds[2*i+1]);
+ }
+
+ this->XAxisTip->GetBounds(bounds);
+ for (i=0; i<3; i++)
+ {
+ this->Bounds[2*i+1] =
+ (bounds[2*i+1]>this->Bounds[2*i+1])?(bounds[2*i+1]):(this->Bounds[2*i+1]);
+ }
+
+ this->YAxisTip->GetBounds(bounds);
+ for (i=0; i<3; i++)
+ {
+ this->Bounds[2*i+1] =
+ (bounds[2*i+1]>this->Bounds[2*i+1])?(bounds[2*i+1]):(this->Bounds[2*i+1]);
+ }
+
+ this->ZAxisTip->GetBounds(bounds);
+ for (i=0; i<3; i++)
+ {
+ this->Bounds[2*i+1] =
+ (bounds[2*i+1]>this->Bounds[2*i+1])?(bounds[2*i+1]):(this->Bounds[2*i+1]);
+ }
+
+ double dbounds[6];
+ (vtkPolyDataMapper::SafeDownCast(this->YAxisShaft->GetMapper()))->
+ GetInput()->GetBounds( dbounds );
+
+ for (i=0; i<3; i++)
+ {
+ this->Bounds[2*i+1] =
+ (dbounds[2*i+1]>this->Bounds[2*i+1])?(dbounds[2*i+1]):(this->Bounds[2*i+1]);
+ }
+
+ // We want this actor to rotate / re-center about the origin, so give it
+ // the bounds it would have if the axes were symmetrical.
+ for (i = 0; i < 3; i++)
+ {
+ this->Bounds[2*i] = -this->Bounds[2*i+1];
+ }
+
+ return this->Bounds;
+}
+
+//-----------------------------------------------------------------------------
+unsigned long int vtkPVAxesActor::GetMTime()
+{
+ unsigned long mTime=this->Superclass::GetMTime();
+
+
+ return mTime;
+}
+
+//-----------------------------------------------------------------------------
+unsigned long int vtkPVAxesActor::GetRedrawMTime()
+{
+ unsigned long mTime=this->GetMTime();
+
+ return mTime;
+}
+
+//-----------------------------------------------------------------------------
+vtkProperty *vtkPVAxesActor::GetXAxisTipProperty()
+{
+ return this->XAxisTip->GetProperty();
+}
+
+//-----------------------------------------------------------------------------
+vtkProperty *vtkPVAxesActor::GetYAxisTipProperty()
+{
+ return this->YAxisTip->GetProperty();
+}
+
+//-----------------------------------------------------------------------------
+vtkProperty *vtkPVAxesActor::GetZAxisTipProperty()
+{
+ return this->ZAxisTip->GetProperty();
+}
+
+//-----------------------------------------------------------------------------
+vtkProperty *vtkPVAxesActor::GetXAxisShaftProperty()
+{
+ return this->XAxisShaft->GetProperty();
+}
+
+//-----------------------------------------------------------------------------
+vtkProperty *vtkPVAxesActor::GetYAxisShaftProperty()
+{
+ return this->YAxisShaft->GetProperty();
+}
+
+//-----------------------------------------------------------------------------
+vtkProperty *vtkPVAxesActor::GetZAxisShaftProperty()
+{
+ return this->ZAxisShaft->GetProperty();
+}
+
+//-----------------------------------------------------------------------------
+vtkProperty *vtkPVAxesActor::GetXAxisLabelProperty()
+{
+ return this->XAxisLabel->GetProperty();
+}
+
+//-----------------------------------------------------------------------------
+vtkProperty *vtkPVAxesActor::GetYAxisLabelProperty()
+{
+ return this->YAxisLabel->GetProperty();
+}
+
+//-----------------------------------------------------------------------------
+vtkProperty *vtkPVAxesActor::GetZAxisLabelProperty()
+{
+ return this->ZAxisLabel->GetProperty();
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVAxesActor::SetTotalLength( float x, float y, float z )
+{
+ if ( this->TotalLength[0] != x ||
+ this->TotalLength[1] != y ||
+ this->TotalLength[2] != z )
+ {
+ this->TotalLength[0] = x;
+ this->TotalLength[1] = y;
+ this->TotalLength[2] = z;
+
+ this->Modified();
+
+ this->UpdateProps();
+ }
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVAxesActor::SetNormalizedShaftLength( float x, float y, float z )
+{
+ if ( this->NormalizedShaftLength[0] != x ||
+ this->NormalizedShaftLength[1] != y ||
+ this->NormalizedShaftLength[2] != z )
+ {
+ this->NormalizedShaftLength[0] = x;
+ this->NormalizedShaftLength[1] = y;
+ this->NormalizedShaftLength[2] = z;
+
+ this->Modified();
+
+ this->UpdateProps();
+ }
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVAxesActor::SetNormalizedTipLength( float x, float y, float z )
+{
+ if ( this->NormalizedTipLength[0] != x ||
+ this->NormalizedTipLength[1] != y ||
+ this->NormalizedTipLength[2] != z )
+ {
+ this->NormalizedTipLength[0] = x;
+ this->NormalizedTipLength[1] = y;
+ this->NormalizedTipLength[2] = z;
+
+ this->Modified();
+
+ this->UpdateProps();
+ }
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVAxesActor::SetShaftType( int type )
+{
+ if ( this->ShaftType != type )
+ {
+ this->ShaftType = type;
+
+ this->Modified();
+
+ this->UpdateProps();
+ }
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVAxesActor::SetTipType( int type )
+{
+ if ( this->TipType != type )
+ {
+ this->TipType = type;
+
+ this->Modified();
+
+ this->UpdateProps();
+ }
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVAxesActor::UpdateProps()
+{
+ this->CylinderSource->SetRadius(this->CylinderRadius);
+ this->CylinderSource->SetResolution(this->CylinderResolution);
+
+
+ this->ConeSource->SetResolution(this->ConeResolution);
+ this->ConeSource->SetRadius(this->ConeRadius);
+
+ this->SphereSource->SetThetaResolution( this->SphereResolution );
+ this->SphereSource->SetPhiResolution( this->SphereResolution );
+ this->SphereSource->SetRadius(this->SphereRadius);
+
+ switch ( this->ShaftType )
+ {
+ case vtkPVAxesActor::CYLINDER_SHAFT:
+ (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
+ SetInput( this->CylinderSource->GetOutput() );
+ break;
+ case vtkPVAxesActor::LINE_SHAFT:
+ (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
+ SetInput( this->LineSource->GetOutput() );
+ break;
+ case vtkPVAxesActor::USER_DEFINED_SHAFT:
+ (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
+ SetInput( this->UserDefinedShaft );
+ }
+
+ switch ( this->TipType )
+ {
+ case vtkPVAxesActor::CONE_TIP:
+ (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
+ SetInput( this->ConeSource->GetOutput() );
+ break;
+ case vtkPVAxesActor::SPHERE_TIP:
+ (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
+ SetInput( this->SphereSource->GetOutput() );
+ break;
+ case vtkPVAxesActor::USER_DEFINED_TIP:
+ (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
+ SetInput( this->UserDefinedTip );
+ }
+
+ (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
+ GetInput()->Update();
+ (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
+ GetInput()->Update();
+
+
+
+ float scale[3];
+ double bounds[6];
+
+ (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
+ GetInput()->GetBounds( bounds );
+
+ int i;
+ for ( i = 0; i < 3; i++ )
+ {
+ scale[i] =
+ this->NormalizedShaftLength[i]*this->TotalLength[i] /
+ (bounds[3] - bounds[2]);
+ }
+
+ vtkTransform *xTransform = vtkTransform::New();
+ vtkTransform *yTransform = vtkTransform::New();
+ vtkTransform *zTransform = vtkTransform::New();
+
+ xTransform->RotateZ( -90 );
+ zTransform->RotateX( 90 );
+
+ xTransform->Scale( scale[0], scale[0], scale[0] );
+ yTransform->Scale( scale[1], scale[1], scale[1] );
+ zTransform->Scale( scale[2], scale[2], scale[2] );
+
+ xTransform->Translate( -(bounds[0]+bounds[1])/2,
+ -bounds[2],
+ -(bounds[4]+bounds[5])/2 );
+ yTransform->Translate( -(bounds[0]+bounds[1])/2,
+ -bounds[2],
+ -(bounds[4]+bounds[5])/2 );
+ zTransform->Translate( -(bounds[0]+bounds[1])/2,
+ -bounds[2],
+ -(bounds[4]+bounds[5])/2 );
+
+
+
+ this->XAxisShaft->SetUserTransform( xTransform );
+ this->YAxisShaft->SetUserTransform( yTransform );
+ this->ZAxisShaft->SetUserTransform( zTransform );
+
+ xTransform->Delete();
+ yTransform->Delete();
+ zTransform->Delete();
+
+ (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
+ GetInput()->GetBounds( bounds );
+
+ xTransform = vtkTransform::New();
+ yTransform = vtkTransform::New();
+ zTransform = vtkTransform::New();
+
+ xTransform->RotateZ( -90 );
+ zTransform->RotateX( 90 );
+
+ xTransform->Scale( this->TotalLength[0], this->TotalLength[0], this->TotalLength[0] );
+ yTransform->Scale( this->TotalLength[1], this->TotalLength[1], this->TotalLength[1] );
+ zTransform->Scale( this->TotalLength[2], this->TotalLength[2], this->TotalLength[2] );
+
+ xTransform->Translate( 0, (1.0 - this->NormalizedTipLength[0]), 0 );
+ yTransform->Translate( 0, (1.0 - this->NormalizedTipLength[1]), 0 );
+ zTransform->Translate( 0, (1.0 - this->NormalizedTipLength[2]), 0 );
+
+ xTransform->Scale( this->NormalizedTipLength[0],
+ this->NormalizedTipLength[0],
+ this->NormalizedTipLength[0] );
+
+ yTransform->Scale( this->NormalizedTipLength[1],
+ this->NormalizedTipLength[1],
+ this->NormalizedTipLength[1] );
+
+ zTransform->Scale( this->NormalizedTipLength[2],
+ this->NormalizedTipLength[2],
+ this->NormalizedTipLength[2] );
+
+ xTransform->Translate( -(bounds[0]+bounds[1])/2,
+ -bounds[2],
+ -(bounds[4]+bounds[5])/2 );
+ yTransform->Translate( -(bounds[0]+bounds[1])/2,
+ -bounds[2],
+ -(bounds[4]+bounds[5])/2 );
+ zTransform->Translate( -(bounds[0]+bounds[1])/2,
+ -bounds[2],
+ -(bounds[4]+bounds[5])/2 );
+
+
+ this->XAxisTip->SetUserTransform( xTransform );
+ this->YAxisTip->SetUserTransform( yTransform );
+ this->ZAxisTip->SetUserTransform( zTransform );
+
+ xTransform->Delete();
+ yTransform->Delete();
+ zTransform->Delete();
+
+ this->XAxisVectorText->SetText( this->XAxisLabelText );
+ this->YAxisVectorText->SetText( this->YAxisLabelText );
+ this->ZAxisVectorText->SetText( this->ZAxisLabelText );
+
+
+ float avgScale =
+ (this->TotalLength[0] + this->TotalLength[1] + this->TotalLength[2])/15;
+
+ this->XAxisShaft->GetBounds(bounds);
+ this->XAxisLabel->SetScale( avgScale, avgScale, avgScale );
+ this->XAxisLabel->SetPosition( bounds[0] + this->XAxisLabelPosition *
+ (bounds[1]-bounds[0]),
+ bounds[2] - (bounds[3]-bounds[2])*2.0,
+ bounds[5] + (bounds[5]-bounds[4])/2.0 );
+
+ this->YAxisShaft->GetBounds(bounds);
+ this->YAxisLabel->SetScale( avgScale, avgScale, avgScale );
+ this->YAxisLabel->SetPosition( (bounds[0]+bounds[1])/2,
+ bounds[2] + this->YAxisLabelPosition *
+ (bounds[3]-bounds[2]),
+ bounds[5] + (bounds[5]-bounds[4])/2.0 );
+
+ this->ZAxisShaft->GetBounds(bounds);
+ this->ZAxisLabel->SetScale( avgScale, avgScale, avgScale );
+ this->ZAxisLabel->SetPosition( bounds[0],
+ bounds[2] - (bounds[3]-bounds[2])*2.0,
+ bounds[4] + this->ZAxisLabelPosition *
+ (bounds[5]-bounds[4]) );
+}
+
+//-----------------------------------------------------------------------------
+void vtkPVAxesActor::PrintSelf(ostream& os, vtkIndent indent)
+{
+ this->Superclass::PrintSelf(os,indent);
+
+ os << indent << "UserDefinedShaft: ";
+ if (this->UserDefinedShaft)
+ {
+ os << this->UserDefinedShaft << endl;
+ }
+ else
+ {
+ os << "(none)" << endl;
+ }
+
+ os << indent << "UserDefinedTip: ";
+ if (this->UserDefinedTip)
+ {
+ os << this->UserDefinedTip << endl;
+ }
+ else
+ {
+ os << "(none)" << endl;
+ }
+
+ os << indent << "XAxisLabelText: " << (this->XAxisLabelText ?
+ this->XAxisLabelText : "(none)")
+ << endl;
+ os << indent << "YAxisLabelText: " << (this->YAxisLabelText ?
+ this->YAxisLabelText : "(none)")
+ << endl;
+ os << indent << "ZAxisLabelText: " << (this->ZAxisLabelText ?
+ this->ZAxisLabelText : "(none)")
+ << endl;
+ os << indent << "XAxisLabelPosition: " << this->XAxisLabelPosition << endl;
+ os << indent << "YAxisLabelPosition: " << this->YAxisLabelPosition << endl;
+ os << indent << "ZAxisLabelPosition: " << this->ZAxisLabelPosition << endl;
+
+ os << indent << "SphereRadius: " << this->SphereRadius << endl;
+ os << indent << "SphereResolution: " << this->SphereResolution << endl;
+ os << indent << "CylinderRadius: " << this->CylinderRadius << endl;
+ os << indent << "CylinderResolution: " << this->CylinderResolution << endl;
+ os << indent << "ConeRadius: " << this->ConeRadius << endl;
+ os << indent << "ConeResolution: " << this->ConeResolution << endl;
+
+ os << indent << "NormalizedShaftLength: "
+ << this->NormalizedShaftLength[0] << ","
+ << this->NormalizedShaftLength[1] << ","
+ << this->NormalizedShaftLength[2] << endl;
+ os << indent << "NormalizedTipLength: "
+ << this->NormalizedTipLength[0] << ","
+ << this->NormalizedTipLength[1] << ","
+ << this->NormalizedTipLength[2] << endl;
+ os << indent << "TotalLength: "
+ << this->TotalLength[0] << ","
+ << this->TotalLength[1] << ","
+ << this->TotalLength[2] << endl;
+}
+
+//-----------------------------------------------------------------------------
+// porting to VTK 5.0.x
+void vtkPVAxesActor::AddToRender( vtkRenderer* theRenderer )
+{
+ theRenderer->AddActor(this->XAxisLabel);
+ theRenderer->AddActor(this->YAxisLabel);
+ theRenderer->AddActor(this->ZAxisLabel);
+}
--- /dev/null
+/*=========================================================================
+
+ Program: ParaView
+ Module: $RCSfile$
+
+ Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
+ All rights reserved.
+
+ ParaView is a free software; you can redistribute it and/or modify it
+ under the terms of the ParaView license version 1.2.
+
+ See License_v1.2.txt for the full ParaView license.
+ A copy of this license can be obtained by contacting
+ Kitware Inc.
+ 28 Corporate Drive
+ Clifton Park, NY 12065
+ USA
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=========================================================================*/
+// .NAME vtkPVAxesActor - a 3D axes representation
+// .SECTION Description
+//
+// vtkPVAxesActor is used to represent 3D axes in the scene. The user can
+// define the geometry to use for the shaft and the tip, and the user can
+// set the text for the three axes. The text will follow the camera.
+
+
+#ifndef __vtkPVAxesActor_h
+#define __vtkPVAxesActor_h
+
+#include "SVTK.h"
+#include "vtkProp3D.h"
+
+class vtkRenderer;
+class vtkPropCollection;
+class vtkMapper;
+class vtkProperty;
+class vtkActor;
+class vtkFollower;
+class vtkCylinderSource;
+class vtkLineSource;
+class vtkConeSource;
+class vtkSphereSource;
+class vtkPolyData;
+class vtkVectorText;
+
+class SVTK_EXPORT vtkPVAxesActor : public vtkProp3D
+{
+public:
+ static vtkPVAxesActor *New();
+ vtkTypeRevisionMacro(vtkPVAxesActor,vtkProp3D);
+ void PrintSelf(ostream& os, vtkIndent indent);
+
+
+ // Description:
+ // For some exporters and other other operations we must be
+ // able to collect all the actors or volumes. These methods
+ // are used in that process.
+ virtual void GetActors(vtkPropCollection *);
+
+ // Description:
+ // Support the standard render methods.
+ virtual int RenderOpaqueGeometry(vtkViewport *viewport);
+ //virtual int RenderTranslucentPolygonalGeometry(vtkViewport *viewport); // porting to VTK 5.0.x
+ //virtual int HasTranslucentPolygonalGeometry(); // porting to VTK 5.0.x
+ virtual int RenderTranslucentGeometry(vtkViewport *viewport); // porting to VTK 5.0.x
+
+ // Description:
+ // Shallow copy of an axes actor. Overloads the virtual vtkProp method.
+ void ShallowCopy(vtkProp *prop);
+
+ // Description:
+ // Release any graphics resources that are being consumed by this actor.
+ // The parameter window could be used to determine which graphic
+ // resources to release.
+ void ReleaseGraphicsResources(vtkWindow *);
+
+ // Description:
+ // Get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax). (The
+ // method GetBounds(double bounds[6]) is available from the superclass.)
+ void GetBounds(double bounds[6]);
+ double *GetBounds();
+
+ // Description:
+ // Get the actors mtime plus consider its properties and texture if set.
+ unsigned long int GetMTime();
+
+ // Description:
+ // Return the mtime of anything that would cause the rendered image to
+ // appear differently. Usually this involves checking the mtime of the
+ // prop plus anything else it depends on such as properties, textures
+ // etc.
+ virtual unsigned long GetRedrawMTime();
+
+ // Description:
+ // Set the total length of the axes in 3 dimensions.
+ void SetTotalLength( float v[3] )
+ { this->SetTotalLength( v[0], v[1], v[2] ); }
+ void SetTotalLength( float x, float y, float z );
+ vtkGetVectorMacro( TotalLength, float, 3 );
+
+ // Description:
+ // Set the normalized (0-1) length of the shaft.
+ void SetNormalizedShaftLength( float v[3] )
+ { this->SetNormalizedShaftLength( v[0], v[1], v[2] ); }
+ void SetNormalizedShaftLength( float x, float y, float z );
+ vtkGetVectorMacro( NormalizedShaftLength, float, 3 );
+
+ // Description:
+ // Set the normalized (0-1) length of the tip.
+ void SetNormalizedTipLength( float v[3] )
+ { this->SetNormalizedTipLength( v[0], v[1], v[2] ); }
+ void SetNormalizedTipLength( float x, float y, float z );
+ vtkGetVectorMacro( NormalizedTipLength, float, 3 );
+
+ // Description:
+ // Set/get the resolution of the pieces of the axes actor
+ vtkSetClampMacro(ConeResolution, int, 3, 128);
+ vtkGetMacro(ConeResolution, int);
+ vtkSetClampMacro(SphereResolution, int, 3, 128);
+ vtkGetMacro(SphereResolution, int);
+ vtkSetClampMacro(CylinderResolution, int, 3, 128);
+ vtkGetMacro(CylinderResolution, int);
+
+ // Description:
+ // Set/get the radius of the pieces of the axes actor
+ vtkSetClampMacro(ConeRadius, float, 0, VTK_LARGE_FLOAT);
+ vtkGetMacro(ConeRadius, float);
+ vtkSetClampMacro(SphereRadius, float, 0, VTK_LARGE_FLOAT);
+ vtkGetMacro(SphereRadius, float);
+ vtkSetClampMacro(CylinderRadius, float, 0, VTK_LARGE_FLOAT);
+ vtkGetMacro(CylinderRadius, float);
+
+ // Description:
+ // Set/get the positions of the axis labels
+ vtkSetClampMacro(XAxisLabelPosition, float, 0, 1);
+ vtkGetMacro(XAxisLabelPosition, float);
+ vtkSetClampMacro(YAxisLabelPosition, float, 0, 1);
+ vtkGetMacro(YAxisLabelPosition, float);
+ vtkSetClampMacro(ZAxisLabelPosition, float, 0, 1);
+ vtkGetMacro(ZAxisLabelPosition, float);
+
+ // Description:
+ // Set the type of the shaft to a cylinder, line, or user defined geometry.
+ void SetShaftType( int type );
+ void SetShaftTypeToCylinder()
+ { this->SetShaftType( vtkPVAxesActor::CYLINDER_SHAFT ); }
+ void SetShaftTypeToLine()
+ { this->SetShaftType( vtkPVAxesActor::LINE_SHAFT ); }
+ void SetShaftTypeToUserDefined()
+ { this->SetShaftType( vtkPVAxesActor::USER_DEFINED_SHAFT ); }
+
+ // Description:
+ // Set the type of the tip to a cone, sphere, or user defined geometry.
+ void SetTipType( int type );
+ void SetTipTypeToCone()
+ { this->SetTipType( vtkPVAxesActor::CONE_TIP ); }
+ void SetTipTypeToSphere()
+ { this->SetTipType( vtkPVAxesActor::SPHERE_TIP ); }
+ void SetTipTypeToUserDefined()
+ { this->SetTipType( vtkPVAxesActor::USER_DEFINED_TIP ); }
+
+ //BTX
+ // Description:
+ // Set the user defined tip polydata.
+ void SetUserDefinedTip( vtkPolyData * );
+ vtkGetObjectMacro( UserDefinedTip, vtkPolyData );
+
+ // Description:
+ // Set the user defined shaft polydata.
+ void SetUserDefinedShaft( vtkPolyData * );
+ vtkGetObjectMacro( UserDefinedShaft, vtkPolyData );
+
+ // Description:
+ // Get the tip properties.
+ vtkProperty *GetXAxisTipProperty();
+ vtkProperty *GetYAxisTipProperty();
+ vtkProperty *GetZAxisTipProperty();
+
+ // Description:
+ // Get the shaft properties.
+ vtkProperty *GetXAxisShaftProperty();
+ vtkProperty *GetYAxisShaftProperty();
+ vtkProperty *GetZAxisShaftProperty();
+
+ // Description:
+ // Get the label properties.
+ vtkProperty *GetXAxisLabelProperty();
+ vtkProperty *GetYAxisLabelProperty();
+ vtkProperty *GetZAxisLabelProperty();
+ //ETX
+ //
+ // Description:
+ // Set the label text.
+ vtkSetStringMacro( XAxisLabelText );
+ vtkSetStringMacro( YAxisLabelText );
+ vtkSetStringMacro( ZAxisLabelText );
+
+//BTX
+ enum
+ {
+ CYLINDER_SHAFT,
+ LINE_SHAFT,
+ USER_DEFINED_SHAFT
+ };
+
+
+ enum
+ {
+ CONE_TIP,
+ SPHERE_TIP,
+ USER_DEFINED_TIP
+ };
+
+//ETX
+
+ void AddToRender( vtkRenderer* theRenderer ); // porting to VTK 5.0.x
+
+protected:
+ vtkPVAxesActor();
+ ~vtkPVAxesActor();
+
+ vtkCylinderSource *CylinderSource;
+ vtkLineSource *LineSource;
+ vtkConeSource *ConeSource;
+ vtkSphereSource *SphereSource;
+
+ vtkActor *XAxisShaft;
+ vtkActor *YAxisShaft;
+ vtkActor *ZAxisShaft;
+
+ vtkActor *XAxisTip;
+ vtkActor *YAxisTip;
+ vtkActor *ZAxisTip;
+
+ void UpdateProps();
+
+ float TotalLength[3];
+ float NormalizedShaftLength[3];
+ float NormalizedTipLength[3];
+
+ int ShaftType;
+ int TipType;
+
+ vtkPolyData *UserDefinedTip;
+ vtkPolyData *UserDefinedShaft;
+
+ char *XAxisLabelText;
+ char *YAxisLabelText;
+ char *ZAxisLabelText;
+
+ vtkVectorText *XAxisVectorText;
+ vtkVectorText *YAxisVectorText;
+ vtkVectorText *ZAxisVectorText;
+
+ vtkFollower *XAxisLabel;
+ vtkFollower *YAxisLabel;
+ vtkFollower *ZAxisLabel;
+
+ int ConeResolution;
+ int SphereResolution;
+ int CylinderResolution;
+
+ float ConeRadius;
+ float SphereRadius;
+ float CylinderRadius;
+
+ float XAxisLabelPosition;
+ float YAxisLabelPosition;
+ float ZAxisLabelPosition;
+
+private:
+ vtkPVAxesActor(const vtkPVAxesActor&); // Not implemented.
+ void operator=(const vtkPVAxesActor&); // Not implemented.
+};
+
+#endif
+
--- /dev/null
+/*=========================================================================
+
+ Program: ParaView
+ Module: $RCSfile$
+
+ Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
+ All rights reserved.
+
+ ParaView is a free software; you can redistribute it and/or modify it
+ under the terms of the ParaView license version 1.2.
+
+ See License_v1.2.txt for the full ParaView license.
+ A copy of this license can be obtained by contacting
+ Kitware Inc.
+ 28 Corporate Drive
+ Clifton Park, NY 12065
+ USA
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=========================================================================*/
+#include "vtkPVAxesWidget.h"
+
+#include "vtkActor2D.h"
+#include "vtkCallbackCommand.h"
+#include "vtkCamera.h"
+#include "vtkCoordinate.h"
+#include "vtkObjectFactory.h"
+#include "vtkPoints.h"
+#include "vtkPolyData.h"
+#include "vtkPolyDataMapper2D.h"
+#include "vtkProperty.h"
+#include "vtkProperty2D.h"
+#include "vtkPVAxesActor.h"
+#include "vtkRenderer.h"
+#include "vtkRenderWindow.h"
+#include "vtkRenderWindowInteractor.h"
+
+vtkStandardNewMacro(vtkPVAxesWidget);
+vtkCxxRevisionMacro(vtkPVAxesWidget, "$Revision$");
+
+vtkCxxSetObjectMacro(vtkPVAxesWidget, AxesActor, vtkPVAxesActor);
+vtkCxxSetObjectMacro(vtkPVAxesWidget, ParentRenderer, vtkRenderer);
+
+//----------------------------------------------------------------------------
+class vtkPVAxesWidgetObserver : public vtkCommand
+{
+public:
+ static vtkPVAxesWidgetObserver *New()
+ {return new vtkPVAxesWidgetObserver;};
+
+ vtkPVAxesWidgetObserver()
+ {
+ this->AxesWidget = 0;
+ }
+
+ virtual void Execute(vtkObject* wdg, unsigned long event, void *calldata)
+ {
+ if (this->AxesWidget)
+ {
+ this->AxesWidget->ExecuteEvent(wdg, event, calldata);
+ }
+ }
+
+ vtkPVAxesWidget *AxesWidget;
+};
+
+//----------------------------------------------------------------------------
+vtkPVAxesWidget::vtkPVAxesWidget()
+{
+ this->StartEventObserverId = 0;
+
+ this->EventCallbackCommand->SetCallback(vtkPVAxesWidget::ProcessEvents);
+
+ this->Observer = vtkPVAxesWidgetObserver::New();
+ this->Observer->AxesWidget = this;
+ this->Renderer = vtkRenderer::New();
+ this->Renderer->SetViewport(0.0, 0.0, 0.2, 0.2);
+ this->Renderer->SetLayer(1);
+ this->Renderer->InteractiveOff();
+ this->Priority = 0.55;
+ this->AxesActor = vtkPVAxesActor::New();
+ this->Renderer->AddActor(this->AxesActor);
+ this->AxesActor->AddToRender(this->Renderer); // tmp
+
+ this->ParentRenderer = NULL;
+
+ this->Moving = 0;
+ this->MouseCursorState = vtkPVAxesWidget::Outside;
+
+ this->StartTag = 0;
+
+ this->Interactive = 1;
+
+ this->Outline = vtkPolyData::New();
+ this->Outline->Allocate();
+ vtkPoints *points = vtkPoints::New();
+ vtkIdType ptIds[5];
+ ptIds[4] = ptIds[0] = points->InsertNextPoint(1, 1, 0);
+ ptIds[1] = points->InsertNextPoint(2, 1, 0);
+ ptIds[2] = points->InsertNextPoint(2, 2, 0);
+ ptIds[3] = points->InsertNextPoint(1, 2, 0);
+ this->Outline->SetPoints(points);
+ this->Outline->InsertNextCell(VTK_POLY_LINE, 5, ptIds);
+ vtkCoordinate *tcoord = vtkCoordinate::New();
+ tcoord->SetCoordinateSystemToDisplay();
+ vtkPolyDataMapper2D *mapper = vtkPolyDataMapper2D::New();
+ mapper->SetInput(this->Outline);
+ mapper->SetTransformCoordinate(tcoord);
+ this->OutlineActor = vtkActor2D::New();
+ this->OutlineActor->SetMapper(mapper);
+ this->OutlineActor->SetPosition(0, 0);
+ this->OutlineActor->SetPosition2(1, 1);
+
+ points->Delete();
+ mapper->Delete();
+ tcoord->Delete();
+}
+
+//----------------------------------------------------------------------------
+vtkPVAxesWidget::~vtkPVAxesWidget()
+{
+ this->Observer->Delete();
+ this->AxesActor->Delete();
+ this->OutlineActor->Delete();
+ this->Outline->Delete();
+ this->SetParentRenderer(NULL);
+ this->Renderer->Delete();
+}
+
+//----------------------------------------------------------------------------
+void vtkPVAxesWidget::SetEnabled(int enabling)
+{
+ if (!this->Interactor)
+ {
+ vtkErrorMacro("The interactor must be set prior to enabling/disabling widget");
+ }
+
+ if (enabling)
+ {
+ if (this->Enabled)
+ {
+ return;
+ }
+ if (!this->ParentRenderer)
+ {
+ vtkErrorMacro("The parent renderer must be set prior to enabling this widget");
+ return;
+ }
+
+ this->Enabled = 1;
+
+ if ( this->EventCallbackCommand )
+ {
+ vtkRenderWindowInteractor *i = this->Interactor;
+ i->AddObserver(vtkCommand::MouseMoveEvent,
+ this->EventCallbackCommand, this->Priority);
+ i->AddObserver(vtkCommand::LeftButtonPressEvent,
+ this->EventCallbackCommand, this->Priority);
+ i->AddObserver(vtkCommand::LeftButtonReleaseEvent,
+ this->EventCallbackCommand, this->Priority);
+ }
+
+ this->ParentRenderer->GetRenderWindow()->AddRenderer(this->Renderer);
+ if (this->ParentRenderer->GetRenderWindow()->GetNumberOfLayers() < 2)
+ {
+ this->ParentRenderer->GetRenderWindow()->SetNumberOfLayers(2);
+ }
+ this->AxesActor->SetVisibility(1);
+ // We need to copy the camera before the compositing observer is called.
+ // Compositing temporarily changes the camera to display an image.
+ this->StartEventObserverId =
+ this->ParentRenderer->AddObserver(vtkCommand::StartEvent,this->Observer,1);
+ this->InvokeEvent(vtkCommand::EnableEvent, NULL);
+ }
+ else
+ {
+ if (!this->Enabled)
+ {
+ return;
+ }
+
+ this->Enabled = 0;
+ this->Interactor->RemoveObserver(this->EventCallbackCommand);
+
+ this->AxesActor->SetVisibility(0);
+ if (this->ParentRenderer)
+ {
+ if (this->ParentRenderer->GetRenderWindow())
+ {
+ this->ParentRenderer->GetRenderWindow()->RemoveRenderer(this->Renderer);
+ this->AxesActor->ReleaseGraphicsResources(this->ParentRenderer->GetRenderWindow());
+ }
+ if (this->StartEventObserverId != 0)
+ {
+ this->ParentRenderer->RemoveObserver(this->StartEventObserverId);
+ }
+ }
+
+ this->InvokeEvent(vtkCommand::DisableEvent, NULL);
+ }
+}
+
+//----------------------------------------------------------------------------
+void vtkPVAxesWidget::ExecuteEvent(vtkObject *vtkNotUsed(o),
+ unsigned long vtkNotUsed(event),
+ void *vtkNotUsed(calldata))
+{
+ if (!this->ParentRenderer)
+ {
+ return;
+ }
+
+ vtkCamera *cam = this->ParentRenderer->GetActiveCamera();
+ double pos[3], fp[3], viewup[3];
+ cam->GetPosition(pos);
+ cam->GetFocalPoint(fp);
+ cam->GetViewUp(viewup);
+
+ cam = this->Renderer->GetActiveCamera();
+ cam->SetPosition(pos);
+ cam->SetFocalPoint(fp);
+ cam->SetViewUp(viewup);
+ this->Renderer->ResetCamera();
+
+ this->SquareRenderer();
+}
+
+void vtkPVAxesWidget::UpdateCursorIcon()
+{
+ if (!this->Enabled)
+ {
+ this->SetMouseCursor(vtkPVAxesWidget::Outside);
+ return;
+ }
+
+ if (this->Moving)
+ {
+ return;
+ }
+
+ int *parentSize = this->ParentRenderer->GetSize();
+
+ int x = this->Interactor->GetEventPosition()[0];
+ int y = this->Interactor->GetEventPosition()[1];
+ double xNorm = x / (double)parentSize[0];
+ double yNorm = y / (double)parentSize[1];
+
+ double pos[4];
+ this->Renderer->GetViewport(pos);
+
+ int pState = this->MouseCursorState;
+
+ if (xNorm > pos[0] && xNorm < pos[2] && yNorm > pos[1] && yNorm < pos[3])
+ {
+ this->MouseCursorState = vtkPVAxesWidget::Inside;
+ }
+ else if (fabs(xNorm-pos[0]) < .02 && fabs(yNorm-pos[3]) < .02)
+ {
+ this->MouseCursorState = vtkPVAxesWidget::TopLeft;
+ }
+ else if (fabs(xNorm-pos[2]) < .02 && fabs(yNorm-pos[3]) < .02)
+ {
+ this->MouseCursorState = vtkPVAxesWidget::TopRight;
+ }
+ else if (fabs(xNorm-pos[0]) < .02 && fabs(yNorm-pos[1]) < .02)
+ {
+ this->MouseCursorState = vtkPVAxesWidget::BottomLeft;
+ }
+ else if (fabs(xNorm-pos[2]) < .02 && fabs(yNorm-pos[1]) < .02)
+ {
+ this->MouseCursorState = vtkPVAxesWidget::BottomRight;
+ }
+ else
+ {
+ this->MouseCursorState = vtkPVAxesWidget::Outside;
+ }
+
+ if (pState == this->MouseCursorState)
+ {
+ return;
+ }
+
+ if (this->MouseCursorState == vtkPVAxesWidget::Outside)
+ {
+ this->Renderer->RemoveActor(this->OutlineActor);
+ }
+ else
+ {
+ this->Renderer->AddActor(this->OutlineActor);
+ }
+ this->Interactor->Render();
+
+ this->SetMouseCursor(this->MouseCursorState);
+}
+
+//----------------------------------------------------------------------------
+void vtkPVAxesWidget::SetMouseCursor(int cursorState)
+{
+ switch (cursorState)
+ {
+ case vtkPVAxesWidget::Outside:
+ this->Interactor->GetRenderWindow()->SetCurrentCursor(VTK_CURSOR_DEFAULT);
+ break;
+ case vtkPVAxesWidget::Inside:
+ this->Interactor->GetRenderWindow()->SetCurrentCursor(VTK_CURSOR_SIZEALL);
+ break;
+ case vtkPVAxesWidget::TopLeft:
+ this->Interactor->GetRenderWindow()->SetCurrentCursor(VTK_CURSOR_SIZENW);
+ break;
+ case vtkPVAxesWidget::TopRight:
+ this->Interactor->GetRenderWindow()->SetCurrentCursor(VTK_CURSOR_SIZENE);
+ break;
+ case vtkPVAxesWidget::BottomLeft:
+ this->Interactor->GetRenderWindow()->SetCurrentCursor(VTK_CURSOR_SIZESW);
+ break;
+ case vtkPVAxesWidget::BottomRight:
+ this->Interactor->GetRenderWindow()->SetCurrentCursor(VTK_CURSOR_SIZESE);
+ break;
+ }
+}
+
+//----------------------------------------------------------------------------
+void vtkPVAxesWidget::ProcessEvents(vtkObject* vtkNotUsed(object),
+ unsigned long event,
+ void *clientdata,
+ void* vtkNotUsed(calldata))
+{
+ vtkPVAxesWidget *self =
+ reinterpret_cast<vtkPVAxesWidget*>(clientdata);
+
+ if (!self->GetInteractive())
+ {
+ return;
+ }
+
+ switch (event)
+ {
+ case vtkCommand::LeftButtonPressEvent:
+ self->OnButtonPress();
+ break;
+ case vtkCommand::MouseMoveEvent:
+ self->OnMouseMove();
+ break;
+ case vtkCommand::LeftButtonReleaseEvent:
+ self->OnButtonRelease();
+ break;
+ }
+}
+
+//----------------------------------------------------------------------------
+void vtkPVAxesWidget::OnButtonPress()
+{
+ if (this->MouseCursorState == vtkPVAxesWidget::Outside)
+ {
+ return;
+ }
+
+ this->SetMouseCursor(this->MouseCursorState);
+
+ this->StartPosition[0] = this->Interactor->GetEventPosition()[0];
+ this->StartPosition[1] = this->Interactor->GetEventPosition()[1];
+
+ this->Moving = 1;
+ this->EventCallbackCommand->SetAbortFlag(1);
+ this->StartInteraction();
+ this->InvokeEvent(vtkCommand::StartInteractionEvent, NULL);
+}
+
+//----------------------------------------------------------------------------
+void vtkPVAxesWidget::OnButtonRelease()
+{
+ if (this->MouseCursorState == vtkPVAxesWidget::Outside)
+ {
+ return;
+ }
+
+ this->Moving = 0;
+ this->EndInteraction();
+ this->InvokeEvent(vtkCommand::EndInteractionEvent, NULL);
+}
+
+//----------------------------------------------------------------------------
+void vtkPVAxesWidget::OnMouseMove()
+{
+ if (this->Moving)
+ {
+ switch (this->MouseCursorState)
+ {
+ case vtkPVAxesWidget::Inside:
+ this->MoveWidget();
+ break;
+ case vtkPVAxesWidget::TopLeft:
+ this->ResizeTopLeft();
+ break;
+ case vtkPVAxesWidget::TopRight:
+ this->ResizeTopRight();
+ break;
+ case vtkPVAxesWidget::BottomLeft:
+ this->ResizeBottomLeft();
+ break;
+ case vtkPVAxesWidget::BottomRight:
+ this->ResizeBottomRight();
+ break;
+ }
+
+ this->UpdateCursorIcon();
+ this->EventCallbackCommand->SetAbortFlag(1);
+ this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
+ }
+ else
+ {
+ this->UpdateCursorIcon();
+ }
+}
+
+//----------------------------------------------------------------------------
+void vtkPVAxesWidget::MoveWidget()
+{
+ int x = this->Interactor->GetEventPosition()[0];
+ int y = this->Interactor->GetEventPosition()[1];
+
+ int dx = x - this->StartPosition[0];
+ int dy = y - this->StartPosition[1];
+
+ this->StartPosition[0] = x;
+ this->StartPosition[1] = y;
+
+ int *size = this->ParentRenderer->GetSize();
+ double dxNorm = dx / (double)size[0];
+ double dyNorm = dy / (double)size[1];
+
+ double *vp = this->Renderer->GetViewport();
+
+ double newPos[4];
+ newPos[0] = vp[0] + dxNorm;
+ newPos[1] = vp[1] + dyNorm;
+ newPos[2] = vp[2] + dxNorm;
+ newPos[3] = vp[3] + dyNorm;
+
+ if (newPos[0] < 0)
+ {
+ this->StartPosition[0] = 0;
+ newPos[0] = 0;
+ newPos[2] = vp[2] - vp[0];
+ }
+ if (newPos[1] < 0)
+ {
+ this->StartPosition[1] = 0;
+ newPos[1] = 0;
+ newPos[3] = vp[3] - vp[1];
+ }
+ if (newPos[2] > 1)
+ {
+ this->StartPosition[0] = (int)(size[0] - size[0] * (vp[2]-vp[0]));
+ newPos[0] = 1 - (vp[2]-vp[0]);
+ newPos[2] = 1;
+ }
+ if (newPos[3] > 1)
+ {
+ this->StartPosition[1] = (int)(size[1] - size[1]*(vp[3]-vp[1]));
+ newPos[1] = 1 - (vp[3]-vp[1]);
+ newPos[3] = 1;
+ }
+
+ this->Renderer->SetViewport(newPos);
+ this->Interactor->Render();
+}
+
+//----------------------------------------------------------------------------
+void vtkPVAxesWidget::ResizeTopLeft()
+{
+ int x = this->Interactor->GetEventPosition()[0];
+ int y = this->Interactor->GetEventPosition()[1];
+
+ int dx = x - this->StartPosition[0];
+ int dy = y - this->StartPosition[1];
+
+ int *size = this->ParentRenderer->GetSize();
+ double dxNorm = dx / (double)size[0];
+ double dyNorm = dy / (double)size[1];
+
+ int useX;
+ double change;
+ double absDx = fabs(dxNorm);
+ double absDy = fabs(dyNorm);
+
+ if (absDx > absDy)
+ {
+ change = dxNorm;
+ useX = 1;
+ }
+ else
+ {
+ change = dyNorm;
+ useX = 0;
+ }
+
+ double *vp = this->Renderer->GetViewport();
+
+ this->StartPosition[0] = x;
+ this->StartPosition[1] = y;
+
+ double newPos[4];
+ newPos[0] = useX ? vp[0] + change : vp[0] - change;
+ newPos[1] = vp[1];
+ newPos[2] = vp[2];
+ newPos[3] = useX ? vp[3] - change : vp[3] + change;
+
+ if (newPos[0] < 0)
+ {
+ this->StartPosition[0] = 0;
+ newPos[0] = 0;
+ }
+ if (newPos[0] >= newPos[2]-0.01)
+ {
+ newPos[0] = newPos[2] - 0.01;
+ }
+ if (newPos[3] > 1)
+ {
+ this->StartPosition[1] = size[1];
+ newPos[3] = 1;
+ }
+ if (newPos[3] <= newPos[1]+0.01)
+ {
+ newPos[3] = newPos[1] + 0.01;
+ }
+
+ this->Renderer->SetViewport(newPos);
+ this->Interactor->Render();
+}
+
+//----------------------------------------------------------------------------
+void vtkPVAxesWidget::ResizeTopRight()
+{
+ int x = this->Interactor->GetEventPosition()[0];
+ int y = this->Interactor->GetEventPosition()[1];
+
+ int dx = x - this->StartPosition[0];
+ int dy = y - this->StartPosition[1];
+
+ int *size = this->ParentRenderer->GetSize();
+ double dxNorm = dx / (double)size[0];
+ double dyNorm = dy / (double)size[1];
+
+ double change;
+ double absDx = fabs(dxNorm);
+ double absDy = fabs(dyNorm);
+
+ if (absDx > absDy)
+ {
+ change = dxNorm;
+ }
+ else
+ {
+ change = dyNorm;
+ }
+
+ double *vp = this->Renderer->GetViewport();
+
+ this->StartPosition[0] = x;
+ this->StartPosition[1] = y;
+
+ double newPos[4];
+ newPos[0] = vp[0];
+ newPos[1] = vp[1];
+ newPos[2] = vp[2] + change;
+ newPos[3] = vp[3] + change;
+
+ if (newPos[2] > 1)
+ {
+ this->StartPosition[0] = size[0];
+ newPos[2] = 1;
+ }
+ if (newPos[2] <= newPos[0]+0.01)
+ {
+ newPos[2] = newPos[0] + 0.01;
+ }
+ if (newPos[3] > 1)
+ {
+ this->StartPosition[1] = size[1];
+ newPos[3] = 1;
+ }
+ if (newPos[3] <= newPos[1]+0.01)
+ {
+ newPos[3] = newPos[1] + 0.01;
+ }
+
+ this->Renderer->SetViewport(newPos);
+ this->Interactor->Render();
+}
+
+//----------------------------------------------------------------------------
+void vtkPVAxesWidget::ResizeBottomLeft()
+{
+ int x = this->Interactor->GetEventPosition()[0];
+ int y = this->Interactor->GetEventPosition()[1];
+
+ int dx = x - this->StartPosition[0];
+ int dy = y - this->StartPosition[1];
+
+ int *size = this->ParentRenderer->GetSize();
+ double dxNorm = dx / (double)size[0];
+ double dyNorm = dy / (double)size[1];
+ double *vp = this->Renderer->GetViewport();
+
+ double change;
+ double absDx = fabs(dxNorm);
+ double absDy = fabs(dyNorm);
+
+ if (absDx > absDy)
+ {
+ change = dxNorm;
+ }
+ else
+ {
+ change = dyNorm;
+ }
+
+ this->StartPosition[0] = x;
+ this->StartPosition[1] = y;
+
+ double newPos[4];
+ newPos[0] = vp[0] + change;
+ newPos[1] = vp[1] + change;
+ newPos[2] = vp[2];
+ newPos[3] = vp[3];
+
+ if (newPos[0] < 0)
+ {
+ this->StartPosition[0] = 0;
+ newPos[0] = 0;
+ }
+ if (newPos[0] >= newPos[2]-0.01)
+ {
+ newPos[0] = newPos[2] - 0.01;
+ }
+ if (newPos[1] < 0)
+ {
+ this->StartPosition[1] = 0;
+ newPos[1] = 0;
+ }
+ if (newPos[1] >= newPos[3]-0.01)
+ {
+ newPos[1] = newPos[3] - 0.01;
+ }
+
+ this->Renderer->SetViewport(newPos);
+ this->Interactor->Render();
+}
+
+//----------------------------------------------------------------------------
+void vtkPVAxesWidget::ResizeBottomRight()
+{
+ int x = this->Interactor->GetEventPosition()[0];
+ int y = this->Interactor->GetEventPosition()[1];
+
+ int dx = x - this->StartPosition[0];
+ int dy = y - this->StartPosition[1];
+
+ int *size = this->ParentRenderer->GetSize();
+ double dxNorm = dx / (double)size[0];
+ double dyNorm = dy / (double)size[1];
+
+ double *vp = this->Renderer->GetViewport();
+
+ int useX;
+ double change;
+ double absDx = fabs(dxNorm);
+ double absDy = fabs(dyNorm);
+
+ if (absDx > absDy)
+ {
+ change = dxNorm;
+ useX = 1;
+ }
+ else
+ {
+ change = dyNorm;
+ useX = 0;
+ }
+
+ this->StartPosition[0] = x;
+ this->StartPosition[1] = y;
+
+ double newPos[4];
+ newPos[0] = vp[0];
+ newPos[1] = useX ? vp[1] - change : vp[1] + change;
+ newPos[2] = useX ? vp[2] + change : vp[2] - change;
+ newPos[3] = vp[3];
+
+ if (newPos[2] > 1)
+ {
+ this->StartPosition[0] = size[0];
+ newPos[2] = 1;
+ }
+ if (newPos[2] <= newPos[0]+0.01)
+ {
+ newPos[2] = newPos[0] + 0.01;
+ }
+ if (newPos[1] < 0)
+ {
+ this->StartPosition[1] = 0;
+ newPos[1] = 0;
+ }
+ if (newPos[1] >= newPos[3]-0.01)
+ {
+ newPos[1] = newPos[3]-0.01;
+ }
+
+ this->Renderer->SetViewport(newPos);
+ this->Interactor->Render();
+}
+
+//----------------------------------------------------------------------------
+void vtkPVAxesWidget::SquareRenderer()
+{
+ int *size = this->Renderer->GetSize();
+ if (size[0] == 0 || size[1] == 0)
+ {
+ return;
+ }
+
+ double vp[4];
+ this->Renderer->GetViewport(vp);
+
+ double deltaX = vp[2] - vp[0];
+ double newDeltaX = size[1] * deltaX / (double)size[0];
+ double deltaY = vp[3] - vp[1];
+ double newDeltaY = size[0] * deltaY / (double)size[1];
+
+ if (newDeltaX > 1)
+ {
+ if (newDeltaY > 1)
+ {
+ if (size[0] > size[1])
+ {
+ newDeltaX = size[1] / (double)size[0];
+ newDeltaY = 1;
+ }
+ else
+ {
+ newDeltaX = 1;
+ newDeltaY = size[0] / (double)size[1];
+ }
+ vp[0] = vp[1] = 0;
+ vp[2] = newDeltaX;
+ vp[3] = newDeltaY;
+ }
+ else
+ {
+ vp[3] = vp[1] + newDeltaY;
+ if (vp[3] > 1)
+ {
+ vp[3] = 1;
+ vp[1] = vp[3] - newDeltaY;
+ }
+ }
+ }
+ else
+ {
+ vp[2] = vp[0] + newDeltaX;
+ if (vp[2] > 1)
+ {
+ vp[2] = 1;
+ vp[0] = vp[2] - newDeltaX;
+ }
+ }
+
+ this->Renderer->SetViewport(vp);
+
+ this->Renderer->NormalizedDisplayToDisplay(vp[0], vp[1]);
+ this->Renderer->NormalizedDisplayToDisplay(vp[2], vp[3]);
+
+ vtkPoints *points = this->Outline->GetPoints();
+ points->SetPoint(0, vp[0]+1, vp[1]+1, 0);
+ points->SetPoint(1, vp[2]-1, vp[1]+1, 0);
+ points->SetPoint(2, vp[2]-1, vp[3]-1, 0);
+ points->SetPoint(3, vp[0]+1, vp[3]-1, 0);
+}
+
+//----------------------------------------------------------------------------
+void vtkPVAxesWidget::SetInteractive(int state)
+{
+ if (this->Interactive != state)
+ {
+ this->Interactive = state;
+ }
+
+ if (!state)
+ {
+ this->OnButtonRelease();
+ this->MouseCursorState = vtkPVAxesWidget::Outside;
+ this->Renderer->RemoveActor(this->OutlineActor);
+ if (this->Interactor)
+ {
+ this->SetMouseCursor(this->MouseCursorState);
+ // this->Interactor->Render();
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+void vtkPVAxesWidget::SetOutlineColor(double r, double g, double b)
+{
+ this->OutlineActor->GetProperty()->SetColor(r, g, b);
+ if (this->Interactor)
+ {
+// this->Interactor->Render();
+ }
+}
+
+//----------------------------------------------------------------------------
+double* vtkPVAxesWidget::GetOutlineColor()
+{
+ return this->OutlineActor->GetProperty()->GetColor();
+}
+
+//----------------------------------------------------------------------------
+void vtkPVAxesWidget::SetAxisLabelColor(double r, double g, double b)
+{
+ this->AxesActor->GetXAxisLabelProperty()->SetColor(r, g, b);
+ this->AxesActor->GetYAxisLabelProperty()->SetColor(r, g, b);
+ this->AxesActor->GetZAxisLabelProperty()->SetColor(r, g, b);
+}
+
+//----------------------------------------------------------------------------
+double* vtkPVAxesWidget::GetAxisLabelColor()
+{
+ return this->AxesActor->GetXAxisLabelProperty()->GetColor();
+}
+
+//----------------------------------------------------------------------------
+vtkRenderer* vtkPVAxesWidget::GetParentRenderer()
+{
+ return this->ParentRenderer;
+}
+
+//----------------------------------------------------------------------------
+void vtkPVAxesWidget::SetViewport(double minX, double minY,
+ double maxX, double maxY)
+{
+ this->Renderer->SetViewport(minX, minY, maxX, maxY);
+}
+
+//----------------------------------------------------------------------------
+double* vtkPVAxesWidget::GetViewport()
+{
+ return this->Renderer->GetViewport();
+}
+
+//----------------------------------------------------------------------------
+void vtkPVAxesWidget::PrintSelf(ostream& os, vtkIndent indent)
+{
+ this->Superclass::PrintSelf(os, indent);
+
+ os << indent << "AxesActor: " << this->AxesActor << endl;
+ os << indent << "Interactive: " << this->Interactive << endl;
+}
--- /dev/null
+/*=========================================================================
+
+ Program: ParaView
+ Module: $RCSfile$
+
+ Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
+ All rights reserved.
+
+ ParaView is a free software; you can redistribute it and/or modify it
+ under the terms of the ParaView license version 1.2.
+
+ See License_v1.2.txt for the full ParaView license.
+ A copy of this license can be obtained by contacting
+ Kitware Inc.
+ 28 Corporate Drive
+ Clifton Park, NY 12065
+ USA
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=========================================================================*/
+// .NAME vtkPVAxesWidget - A widget to manipulate an axe
+//
+// .SECTION Description
+// This widget creates and manages its own vtkPVAxesActor.
+
+
+#ifndef __vtkPVAxesWidget_h
+#define __vtkPVAxesWidget_h
+
+#include "SVTK.h"
+#include "vtkInteractorObserver.h"
+
+class vtkActor2D;
+class vtkKWApplication;
+class vtkPolyData;
+class vtkPVAxesActor;
+class vtkPVAxesWidgetObserver;
+class vtkRenderer;
+
+class SVTK_EXPORT vtkPVAxesWidget : public vtkInteractorObserver
+{
+public:
+ static vtkPVAxesWidget* New();
+ vtkTypeRevisionMacro(vtkPVAxesWidget, vtkInteractorObserver);
+ void PrintSelf(ostream& os, vtkIndent indent);
+
+ // Description:
+ // Set/get the axes actor to be displayed in this 3D widget.
+ void SetAxesActor(vtkPVAxesActor *actor);
+ vtkGetObjectMacro(AxesActor, vtkPVAxesActor);
+
+ // Description:
+ // Enable the 3D widget.
+ virtual void SetEnabled(int);
+
+ //BTX
+ // Description:
+ // Set the renderer this 3D widget will be contained in.
+ void SetParentRenderer(vtkRenderer *ren);
+ vtkRenderer* GetParentRenderer();
+ //ETX
+
+ // Description:
+ // Callback to keep the camera for the axes actor up to date with the
+ // camera in the parent renderer
+ void ExecuteEvent(vtkObject *o, unsigned long event, void *calldata);
+
+ // Description:
+ // Set/get whether to allow this 3D widget to be interactively moved/scaled.
+ void SetInteractive(int state);
+ vtkGetMacro(Interactive, int);
+ vtkBooleanMacro(Interactive, int);
+
+ // Description:
+ // Set/get the color of the outline of this widget. The outline is visible
+ // when (in interactive mode) the cursor is over this 3D widget.
+ void SetOutlineColor(double r, double g, double b);
+ double *GetOutlineColor();
+
+ // Description:
+ // Set/get the color of the axis labels of this widget.
+ void SetAxisLabelColor(double r, double g, double b);
+ double *GetAxisLabelColor();
+
+ // Description:
+ // Set/get the viewport to position/size this 3D widget.
+ void SetViewport(double minX, double minY, double maxX, double maxY);
+ double* GetViewport();
+
+protected:
+ vtkPVAxesWidget();
+ ~vtkPVAxesWidget();
+
+ vtkRenderer *Renderer;
+ vtkRenderer *ParentRenderer;
+
+ vtkPVAxesActor *AxesActor;
+ vtkPolyData *Outline;
+ vtkActor2D *OutlineActor;
+
+ static void ProcessEvents(vtkObject *object, unsigned long event,
+ void *clientdata, void *calldata);
+
+ vtkPVAxesWidgetObserver *Observer;
+ int StartTag;
+
+ int MouseCursorState;
+ int Moving;
+ int StartPosition[2];
+
+ int Interactive;
+
+ void UpdateCursorIcon();
+ void SetMouseCursor(int cursorState);
+
+//BTX
+ int State;
+
+ enum AxesWidgetState
+ {
+ Outside = 0,
+ Inside,
+ TopLeft,
+ TopRight,
+ BottomLeft,
+ BottomRight
+ };
+//ETX
+
+ void OnButtonPress();
+ void OnMouseMove();
+ void OnButtonRelease();
+
+ void MoveWidget();
+ void ResizeTopLeft();
+ void ResizeTopRight();
+ void ResizeBottomLeft();
+ void ResizeBottomRight();
+
+ void SquareRenderer();
+
+ unsigned long StartEventObserverId;
+private:
+ vtkPVAxesWidget(const vtkPVAxesWidget&); // Not implemented
+ void operator=(const vtkPVAxesWidget&); // Not implemented
+};
+
+#endif
<parameter name="navigation_mode" value="0"/>
<parameter name="speed_mode" value="0"/>
<parameter name="speed_value" value="10"/>
+ <parameter name="show_static_trihedron" value="true" />
<parameter name="spacemouse_func1_btn" value="1"/>
<parameter name="spacemouse_func2_btn" value="2"/>
<parameter name="spacemouse_func5_btn" value="5"/>