SET(CAS_CPPFLAGS ${CAS_CPPFLAGS} -DHAVE_LIMITS_H)
SET(CAS_CPPFLAGS ${CAS_CPPFLAGS} -I${CASROOT}/inc)
+IF(NOT WINDOWS)
+ FIND_LIBRARY(Xmu Xmu)
+ IF(Xmu)
+ SET(CAS_LDPATH ${Xmu})
+ ENDIF(Xmu)
+ENDIF(NOT WINDOWS)
+
IF(WINDOWS)
IF(CMAKE_BUILD_TYPE STREQUAL Debug)
SET(CASROOT_LIBDIR ${CASROOT}/win32/libd)
check_SalomeObject.m4 \
check_sip.m4 \
check_SupervGraphViewer.m4 \
-check_vtk.m4 \
check_VTKViewer.m4 \
check_QxGraphViewer.m4 \
check_TestRecorder.m4
+++ /dev/null
-dnl Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
-dnl
-dnl Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-dnl
-dnl This library is free software; you can redistribute it and/or
-dnl modify it under the terms of the GNU Lesser General Public
-dnl License as published by the Free Software Foundation; either
-dnl version 2.1 of the License.
-dnl
-dnl This library is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-dnl Lesser General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU Lesser General Public
-dnl License along with this library; if not, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-dnl
-dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-dnl
-
-dnl OPTIONS_VTK
-dnl ------------------------------------------------------------------------
-dnl Adds the --with-vtk=path and --with-vtk-version configure options
-dnl
-AC_DEFUN([OPTIONS_VTK], [
- AC_ARG_WITH([vtk],
- [AC_HELP_STRING([--with-vtk], [The prefix where VTK is installed (default "" means taking from environment variable)])],
- [with_vtk=$withval], [with_vtk=""])
-
- AC_ARG_WITH([vtk-version],
- [AC_HELP_STRING([--with-vtk-version], [VTK include directory name is vtk-suffix, e.g. vtk-5.0/. What is the suffix? (Default "yes" means taking from environment variable)])],
- [vtk_suffix=$withval], [vtk_suffix="yes"])
-
- AC_ARG_WITH([paraview],
- [AC_HELP_STRING([--with-paraview], [ParaView from the specified location is used instead of VTK (default "" means ParaView should not be used)])])
-])
-
-dnl
-dnl CHECK_VTK
-dnl ------------------------------------------------------------------------
-dnl
-AC_DEFUN([CHECK_VTK], [
-AC_REQUIRE([AC_PROG_CC])dnl
-AC_REQUIRE([AC_PROG_CXX])dnl
-AC_REQUIRE([AC_PROG_CPP])dnl
-AC_REQUIRE([AC_PROG_CXXCPP])dnl
-AC_REQUIRE([AC_LINKER_OPTIONS])dnl
-
-AC_REQUIRE([OPTIONS_VTK])dnl
-
-AC_CHECKING(for VTK)
-
-AC_LANG_SAVE
-AC_LANG_CPLUSPLUS
-
-AC_SUBST(VTK_INCLUDES)
-AC_SUBST(VTK_LIBS)
-AC_SUBST(VTKPY_MODULES)
-
-VTK_INCLUDES=""
-VTK_LIBS=""
-VTKPY_MODULES=""
-
-vtk_ok=no
-
-if test "x$OpenGL_ok" != "xyes" ; then
- AC_MSG_WARN(VTK needs OpenGL correct configuration, check configure output)
-fi
-
-AC_PATH_X
-if test "x$x_libraries" != "x"
-then
- LXLIB="-L$x_libraries"
-else
- LXLIB=""
-fi
-
-if test "x$x_libraries" = "x/usr/lib"
-then
- LXLIB=""
-fi
-
-if test "x$x_libraries" = "x/usr/lib${LIB_LOCATION_SUFFIX}"
-then
- LXLIB=""
-fi
-
-LOCAL_INCLUDES="$OGL_INCLUDES -DVTK_EXCLUDE_STRSTREAM_HEADERS"
-LOCAL_LIBS="-lvtkCommon -lvtkGraphics -lvtkImaging -lvtkFiltering -lvtkIO -lvtkRendering -lvtkHybrid -lvtkParallel -lvtkWidgets $LXLIB -lX11 -lXt"
-TRY_LINK_LIBS="-lvtkCommon $LXLIB -lX11 -lXt"
-
-dnl VTK version suffix
-if test -z $vtk_suffix ; then
- vtk_suffix="yes"
-fi
-if test "x$vtk_suffix" == "xno" ; then
- dnl in case user wrote --with-vtk-version=no, use empty suffix
- vtk_suffix=""
-fi
-if test "x$vtk_suffix" != "xyes" ; then
- VTKSUFFIX="$vtk_suffix"
-else
- dnl in case user wrote --with-vtk-version=yes, get the suffix from env
- if test -z $VTKSUFFIX ; then
- VTKSUFFIX="-5.0"
- fi
-fi
-
-dnl VTK install dir
-if test -z $with_vtk ; then
- with_vtk=""
-fi
-if test "x$with_vtk" = "xyes" ; then
- dnl in case user wrote --with-vtk=yes
- with_vtk=""
-fi
-if test "x$with_vtk" = "xno" ; then
- dnl in case user wrote --with-vtk=no
- with_vtk=""
- AC_MSG_WARN(Value "no", specified for option --with-vtk, is not supported)
-fi
-
-if test "x$with_vtk" != "x" ; then
- VTKHOME="$with_vtk"
-else
- if test -z $VTKHOME ; then
- AC_MSG_WARN(undefined VTKHOME variable which specify where vtk was compiled)
- for d in /usr/local /usr ; do
- if test -f ${d}/include/vtk${VTKSUFFIX}/vtkPlane.h ; then
- AC_MSG_RESULT(trying ${d})
- VTKHOME="${d}"
- break
- fi
- if test -f ${d}/include/vtk-5.0/vtkPlane.h ; then
- AC_MSG_RESULT(trying ${d})
- VTKHOME="${d}"
- VTKSUFFIX="-5.0"
- break
- fi
- if test -f ${d}/include/vtk-5.2/vtkPlane.h ; then
- AC_MSG_RESULT(trying ${d})
- VTKHOME="${d}"
- VTKSUFFIX="-5.2"
- break
- fi
- if test -f ${d}/include/vtk/vtkPlane.h ; then
- AC_MSG_RESULT(trying ${d})
- VTKHOME="${d}"
- VTKSUFFIX=""
- break
- fi
- done
- fi
-fi
-
-# Using regular VTK installation
-if test "x$with_paraview" = "x" ; then
- LOCAL_INCLUDES="-I$VTKHOME/include/vtk${VTKSUFFIX} $LOCAL_INCLUDES"
- LOCAL_LIBS="-L$VTKHOME/lib${LIB_LOCATION_SUFFIX}/vtk${VTKSUFFIX} $LOCAL_LIBS"
- TRY_LINK_LIBS="-L$VTKHOME/lib${LIB_LOCATION_SUFFIX} -L$VTKHOME/lib${LIB_LOCATION_SUFFIX}/vtk${VTKSUFFIX} $TRY_LINK_LIBS"
- if test "x$VTKHOME" != "x/usr" ; then
- LOCAL_LIBS="-L$VTKHOME/lib${LIB_LOCATION_SUFFIX} $LOCAL_LIBS"
- fi
-else
-# VTK from ParaView overrides other VTK versions
- if test "${with_paraview}" = "yes" ; then
- if test -z $PVHOME ; then
- PVHOME="/usr"
- fi
- else
- PVHOME=${with_paraview}
- fi
-
-
- LOCAL_INCLUDES="-I$PVHOME/include/paraview-$PVVERSION $LOCAL_INCLUDES"
-
- LOCAL_LIBS="-L$PVHOME/lib/paraview-$PVVERSION -lvtksys -lvtkzlib -lvtkpng -lvtkjpeg -lvtktiff -lvtkexpat -lvtksqlite -lvtkmetaio -lvtkverdict -lvtkNetCDF -lvtkDICOMParser -lvtkfreetype -lvtkftgl -lvtkexoIIc $LOCAL_LIBS"
- TRY_LINK_LIBS="-L$PVHOME/lib/paraview-$PVVERSION -lvtksys $TRY_LINK_LIBS"
-fi
-
-dnl vtk headers
-CPPFLAGS_old="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES"
-
-AC_CHECK_HEADER(vtkPlane.h,vtk_ok="yes",vtk_ok="no")
-
-CPPFLAGS="$CPPFLAGS_old"
-
-if test "x$vtk_ok" = "xyes"
-then
- VTK_INCLUDES="$LOCAL_INCLUDES"
-
- dnl vtk libraries
-
- AC_MSG_CHECKING(linking VTK library)
-
- LIBS_old="$LIBS"
- LIBS="$LIBS $TRY_LINK_LIBS"
- #LIBS="$LIBS $LOCAL_LIBS"
- CPPFLAGS_old="$CPPFLAGS"
- CPPFLAGS="$CPPFLAGS $VTK_INCLUDES"
-
- dnl VTKPY_MODULES="$VTKHOME/python"
-
- AC_CACHE_VAL(salome_cv_lib_vtk,[
- AC_TRY_LINK([#include "vtkPlane.h"
- ],
- [vtkPlane::New()],
- [salome_cv_lib_vtk=yes],
- [salome_cv_lib_vtk=no])
- ])
- vtk_ok="$salome_cv_lib_vtk"
- LIBS="$LIBS_old"
- CPPFLAGS="$CPPFLAGS_old"
-fi
-
-if test "x$vtk_ok" = "xno"
-then
- AC_MSG_RESULT(no)
- AC_MSG_WARN(unable to link with vtk library)
-else
- AC_MSG_RESULT(yes)
- VTK_LIBS="$LOCAL_LIBS"
- VTK_MT_LIBS="$LOCAL_LIBS"
-fi
-
-AC_MSG_RESULT(for VTK: $vtk_ok)
-
-AC_LANG_RESTORE
-
-# Save cache
-AC_CACHE_SAVE
-
-])dnl
</ul>
</ul>
+<br><h2>Stream Lines Preferences</h2>
+
+\image html pref32.png
+
+<ul>
+<li><b>Stream Lines Preferences</b></li>
+<ul>
+<li><b>Used points</b> - allows to define a default value of percentage
+of points used for building the Stream Lines presentation.</li>
+</ul>
+</ul>
+
<br><h2>Sweep and Animation Preferences</h2>
\image html ppref3.png
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
<h1>Spin boxes</h1>
This type of widgets is used for numeric (integer or floating-point)
-data input. Spin boxes are used in standard \b SALOME modules in case
-if an input value has clearly defined input range (and precision in
-case of floating-point value).
+data input. Spin boxes are used in standard \b SALOME modules if the
+input value has a clearly defined input range (and precision in
+case of a floating-point value).
-Input precision has specific semantics in \b SALOME floating-point
+Input precision has a specific semantics in \b SALOME floating-point
spin boxes:
-- Positive value means that a number in a fixed-point format
-(corresponding to "f" format specifier for C printf function) is
+- Positive precision value means that a number in the fixed-point format
+(corresponding to the "f" format specifier for C printf function) is
expected. Positive precision value is the maximum allowed number of
digits after the decimal separator.
-- Negative precision value means that a number either in a fixed-point
-or scientific (exponetial) format is expected. This is similar to
-behavior of "g" format specifier for C printf function. Absolute
+- Negative precision value means that a number either in the fixed-point
+or the scientific (exponetial) format is expected. This is similar to the
+behavior of the "g" format specifier for C printf function. Negative
precision value is the maximum allowed number of significant digits in
mantissa (note that one digit is always before the decimal separator).
To make the user aware of an input value constraints applied by some
-\b SALOME operation, the following basic capabilties are provided by
+\b SALOME operations, the following basic capabilties are provided by
spin boxes:
-- Text entered manually into a spin box by the user is checked to be a
+- The text input manually in a spin box by the user is checked to be a
number of valid type (integer or floating-point).
-- The text is converted to a number and checked against the valid
+- The text is converted to a number and checked to be within the valid
range.
- Additionally, for floating-point data the input text is checked
against the precision rules described above.
-In case if the input text in a spin box does not satisfy the
-constraints, the user is informed about this by a message shown in a
+If the input text in a spin box does not meet the
+constraints, the user is shown a message in a
tooltip near the spin box just as he types in it. The tooltip contains
-information about valid data range. For floating-point input, the
-tooltip also contains information about expected precision.
+information about the valid data range. For a floating-point input, the
+tooltip also contains information about the expected precision.
-In standard \bSALOME modules precision value can be adjusted through
-\ref setting_preferences_page "user preferences" of correspodning modules, and the tooltip contains a
-reference to corresponding parameter in the preferences.
+In standard \bSALOME modules the precision value can be adjusted through
+\ref setting_preferences_page "user preferences" of the correspodning modules, and the tooltip contains a
+reference to the corresponding parameter in the preferences.
On-line documentation for each standard SALOME module contains the
list of user preferences that can be used for tuning floating-point
-precision for different type of input quantities.
+precision for different types of input quantities.
<h2>Spin boxes and SALOME Notebook</h2>
-Apart from numeric input, spin boxes in some \b SALOME modules accept
-names of \b Notebook variables (see \ref using_notebook "Using Notebook"
+Apart from the numeric input, spin boxes in some \b SALOME modules accept
+the names of \b Notebook variables (see \ref using_notebook "Using Notebook"
page for more details about \b Notebook).
-If some spin box accepts variable names, then it is
-additionally checked whether the manual input text represents a variable name. Variable
-names should satisfy common naming rules for \b Python variables.
-In case if the input is neither a valid number nor a variable name,
-the tooltip is shown informing the user that variable names are
-also acceptable in this spin box.
+If a spin box accepts variable names, then it is
+additionally checked whether the manually input text represents a variable name. Variable
+names should comply with the common naming rules for \b Python variables.
+If the input is neither a valid number nor a variable name,
+the tooltip informs the user that variable names are also acceptable in this spin box.
*/
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>
if( !IsEXTInitialized ||
strstr( ext, "GL_EXT_framebuffer_object" ) == NULL )
{
- INFOS( "Initializing OpenGL FrameBuffer extension failed" );
+ MESSAGE( "Initializing OpenGL FrameBuffer extension failed" );
return false;
}
#include <limits>
+const double PSEUDO_ZERO = 1.e-20;
+
/*!
\class QtxDoubleSpinBox
\brief Enhanced version of the Qt's double spin box.
myCleared = false;
QDoubleSpinBox::stepBy( steps );
+ double tmpval = value();
+ if ( qAbs( tmpval ) < PSEUDO_ZERO ) tmpval = 0.;
+ if ( tmpval < minimum() ) tmpval = minimum();
+ else if ( tmpval > maximum() ) tmpval = maximum();
+ setValue( tmpval );
}
/*!
return map.keys();
}
+/*!
+ \brief Get all sections names matching specified regular expression.
+ \param re searched regular expression
+ \return list of sections names
+*/
+QStringList QtxResourceMgr::sections(const QRegExp& re) const
+{
+ return sections().filter( re );
+}
+
+/*!
+ \brief Get all sections names with the prefix specified by passed
+ list of parent sections names.
+
+ Sub-sections are separated inside the section name by the sections
+ separator token, for example "splash:color:label".
+
+ \param names parent sub-sections names
+ \return list of sections names
+*/
+QStringList QtxResourceMgr::sections(const QStringList& names) const
+{
+ QStringList nm = names;
+ nm << ".+";
+ QRegExp re( QString( "^%1$" ).arg( nm.join( sectionsToken() ) ) );
+ return sections( re );
+}
+
+/*!
+ \brief Get list of sub-sections names for the specified parent section name.
+
+ Sub-sections are separated inside the section name by the sections
+ separator token, for example "splash:color:label".
+
+ \param section parent sub-section name
+ \param full if \c true return full names of child sub-sections, if \c false,
+ return only top-level sub-sections names
+ \return list of sub-sections names
+*/
+QStringList QtxResourceMgr::subSections(const QString& section, const bool full) const
+{
+ QStringList names = sections( QStringList() << section );
+ QMutableListIterator<QString> it( names );
+ while ( it.hasNext() ) {
+ QString name = it.next().mid( section.size() ).trimmed();
+ if ( name.isEmpty() ) {
+ it.remove();
+ continue;
+ }
+ if ( !full ) name = name.split( sectionsToken() ).first();
+ it.setValue( name );
+ }
+ names.removeDuplicates();
+ names.sort();
+ return names;
+}
+
/*!
\brief Get all parameters name in specified section.
\param sec section name
\brief Get application resources section name.
By default, application resources section name is "resources" but
- it can be changed by setting the corresponding resources manager option.
+ it can be changed by setting the "res_section_name" resources manager option.
\return section corresponding to the resources directories
\sa option(), setOption()
\brief Get application language section name.
By default, application language section name is "language" but
- it can be changed by setting the corresponding resources manager option.
+ it can be changed by setting the "lang_section_name" resources manager option.
\return section corresponding to the application language settings
\sa option(), setOption()
return res;
}
+/*!
+ \brief Get sections separator token.
+
+ By default, sections separator token is colon symbol ":" but
+ it can be changed by setting the "section_token" resources manager option.
+
+ \return string corresponding to the current section separator token
+ \sa option(), setOption()
+*/
+QString QtxResourceMgr::sectionsToken() const
+{
+ QString res = option( "section_token" );
+ if ( res.isEmpty() )
+ res = QString( ":" );
+ return res;
+}
+
/*!
\brief Get default pixmap.
QString resSection() const;
QString langSection() const;
+ QString sectionsToken() const;
QPixmap loadPixmap( const QString&, const QString& ) const;
QPixmap loadPixmap( const QString&, const QString&, const bool ) const;
bool save();
QStringList sections() const;
+ QStringList sections(const QRegExp&) const;
+ QStringList sections(const QStringList&) const;
+ QStringList subSections(const QString&, const bool = true) const;
QStringList parameters( const QString& ) const;
void refresh();
emit( selectionChanged() );
}
+/*!
+ \brief Called when rows are about to be removed.
+ \param parent model index
+ \param start first row to remove
+ \param end last row to remove
+*/
+void QtxTreeView::rowsAboutToBeRemoved( const QModelIndex& parent, int start, int end )
+{
+ QModelIndex curIndex = currentIndex();
+ while ( curIndex.isValid() && curIndex.parent() != parent )
+ curIndex = curIndex.parent();
+ if ( curIndex.isValid() && curIndex.row() >= start && curIndex.row() <= end )
+ setCurrentIndex( QModelIndex() );
+ QTreeView::rowsAboutToBeRemoved( parent, start, end );
+}
+
/*!
\brief Expand/collapse the specified item (recursively).
\param index model index
protected slots:
void onHeaderClicked( int );
+ void rowsAboutToBeRemoved( const QModelIndex&, int, int );
void selectionChanged( const QItemSelection&, const QItemSelection& );
void onAppropriate( Qt::Orientation, int, int );
#include <QtxTreeView.h>
#include <QShortcut>
-#include <iostream>
/*!
\class SUIT_DataBrowser
\param autoOpen if \c true automatically open branches
*/
void SUIT_DataBrowser::updateTree( SUIT_DataObject* obj, const bool autoOpen )
-{
- //std::cerr << " updateTree from SUIT_DataBrowser" << std::endl;
+{
SUIT_ProxyModel* m = qobject_cast<SUIT_ProxyModel*>( model() );
if ( m ) {
m->updateTree( obj );
virtual int id() const;
SUIT_DataObject* root() const;
- QString studyName() const;
+ virtual QString studyName() const;
SUIT_Application* application() const;
virtual bool isSaved() const;
return myItems.contains( obj ) ? obj : 0;
}
-#include <iostream>
/*!
\brief Create an item corresponding to the data object.
\param obj source data object
\param index starting index for the updating
\sa setAutoUpdate()
*/
-#include <iostream>
void SUIT_ProxyModel::updateTree( const QModelIndex& index )
{
//std::cerr << "updateTree with QModelIndex from SUIT_ProxyModel" << std::endl;
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;
+}
+
+//-----------------------------------------------------------------------------
+#if (VTK_MINOR_VERSION>=2)
+// 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;
+}
+
+#else
+//-----------------------------------------------------------------------------
+// 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;
+}
+#endif
+
+//-----------------------------------------------------------------------------
+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);
+#if (VTK_MINOR_VERSION>=2)
+ virtual int RenderTranslucentPolygonalGeometry(vtkViewport *viewport); // porting to VTK 5.0.x
+ virtual int HasTranslucentPolygonalGeometry(); // porting to VTK 5.0.x
+#else
+ virtual int RenderTranslucentGeometry(vtkViewport *viewport); // porting to VTK 5.0.x
+#endif
+
+ // 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
int SalomeApp_Study::id() const
{
int id = -1;
- if ( myStudyDS )
+ if ( studyDS() )
id = studyDS()->StudyId();
return id;
}
+/*!
+ Get study name.
+*/
+QString SalomeApp_Study::studyName() const
+{
+ // redefined from SUIT_Study to update study name properly since
+ // it can be changed outside of GUI
+ // TEMPORARILY SOLUTION: better to be implemented with help of SALOMEDS observers
+ if ( studyDS() ) {
+ QString newName = studyDS()->Name().c_str();
+ if ( LightApp_Study::studyName() != newName ) {
+ SalomeApp_Study* that = const_cast<SalomeApp_Study*>( this );
+ that->setStudyName( newName );
+ ((SalomeApp_Application*)application())->updateDesktopTitle();
+ }
+ }
+ return LightApp_Study::studyName();
+}
+
/*!
Gets studyDS pointer.
*/
}
/*!
+ \return a name of save point
*/
QString SalomeApp_Study::getNameOfSavePoint(int savePoint)
{
virtual ~SalomeApp_Study();
virtual int id() const;
+ virtual QString studyName() const;
virtual bool createDocument( const QString& );
virtual bool openDocument( const QString& );
<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"/>
#include "VTKViewer_MarkerDlg.h"
#include "VTKViewer_MarkerWidget.h"
+#include <SUIT_Application.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+
#include <QFrame>
#include <QHBoxLayout>
+#include <QKeyEvent>
/*!
* Class : VTKViewer_MarkerDlg
aTopLayout->setSpacing( 0 );
aTopLayout->setMargin( 0 );
aTopLayout->addWidget( myMarkerWidget );
+
+ connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
}
/*!
{
}
+void VTKViewer_MarkerDlg::setHelpData( const QString& theModuleName,
+ const QString& theHelpFileName )
+{
+ myModuleName = theModuleName;
+ myHelpFileName = theHelpFileName;
+}
+
+void VTKViewer_MarkerDlg::keyPressEvent( QKeyEvent* e )
+{
+ QtxDialog::keyPressEvent( e );
+ if ( e->isAccepted() )
+ return;
+
+ if ( e->key() == Qt::Key_F1 ) {
+ e->accept();
+ onHelp();
+ }
+}
+
+void VTKViewer_MarkerDlg::onHelp()
+{
+ if( myModuleName.isNull() || myHelpFileName.isNull() )
+ return;
+
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ if (app)
+ app->onHelpContextModule(myModuleName, myHelpFileName);
+ else {
+ QString platform;
+#ifdef WIN32
+ platform = "winapplication";
+#else
+ platform = "application";
+#endif
+ SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
+ tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+ arg(app->resourceMgr()->stringValue("ExternalBrowser",
+ platform)).
+ arg(myHelpFileName));
+ }
+}
+
void VTKViewer_MarkerDlg::setCustomMarkerMap( VTK::MarkerMap theMarkerMap )
{
myMarkerWidget->setCustomMarkerMap( theMarkerMap );
VTKViewer_MarkerDlg( QWidget* = 0 );
virtual ~VTKViewer_MarkerDlg();
+ void setHelpData( const QString& theModuleName,
+ const QString& theHelpFileName );
+
void setCustomMarkerMap( VTK::MarkerMap );
VTK::MarkerMap getCustomMarkerMap();
VTK::MarkerScale getStandardMarkerScale() const;
int getCustomMarkerID() const;
+protected:
+ void keyPressEvent( QKeyEvent* );
+
+private slots:
+ void onHelp();
+
private:
VTKViewer_MarkerWidget* myMarkerWidget;
+
+ QString myModuleName;
+ QString myHelpFileName;
};
#endif
{
Q_INIT_RESOURCE( VTKViewer );
- this->ExtensionsInitialized = 0;
+ this->ExtensionsInitialized = ES_None;
this->PointSpriteTexture = 0;
}
//-----------------------------------------------------------------------------
-bool VTKViewer_PolyDataMapper::InitExtensions()
+int VTKViewer_PolyDataMapper::InitExtensions()
{
- if( this->ExtensionsInitialized )
- return true;
-
- InitializeBufferExtensions();
-
char* ext = (char*)glGetString( GL_EXTENSIONS );
if( !IsBufferExtensionsInitialized ||
strstr( ext, "GL_ARB_point_sprite" ) == NULL ||
strstr( ext, "GL_ARB_vertex_buffer_object" ) == NULL )
{
- INFOS("Initializing ARB extensions failed");
- return false;
+ MESSAGE("Initializing ARB extensions failed");
+ return ES_Error;
}
- this->ExtensionsInitialized = 1;
- return true;
+ return ES_Ok;
}
//-----------------------------------------------------------------------------
bool isUsePointSprites = this->MarkerEnabled && this->MarkerType != VTK::MT_NONE;
if( isUsePointSprites )
{
- this->InitExtensions();
+ if( this->ExtensionsInitialized == ES_None )
+ this->ExtensionsInitialized = this->InitExtensions();
this->InitPointSprites();
this->InitTextures();
}
delete aColorFunctor;
}
- if( this->ExtensionsInitialized ) {
+ if( this->ExtensionsInitialized == ES_Ok ) {
GLuint aBufferObjectID = 0;
vglGenBuffersARB( 1, &aBufferObjectID );
vglBindBufferARB( GL_ARRAY_BUFFER_ARB, aBufferObjectID );
*/
class VTKVIEWER_EXPORT VTKViewer_PolyDataMapper : public MAPPER_SUPERCLASS
{
+public:
+ enum ExtensionsState { ES_None = 0, ES_Error, ES_Ok };
+
public:
static VTKViewer_PolyDataMapper* New();
vtkTypeRevisionMacro( VTKViewer_PolyDataMapper, MAPPER_SUPERCLASS );
~VTKViewer_PolyDataMapper();
//! Initializing OpenGL extensions.
- bool InitExtensions();
+ int InitExtensions();
//! Activate Point Sprites.
void InitPointSprites();