STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7)
-SET(${PROJECT_NAME_UC}_MINOR_VERSION 4)
+SET(${PROJECT_NAME_UC}_MINOR_VERSION 5)
SET(${PROJECT_NAME_UC}_PATCH_VERSION 1)
SET(${PROJECT_NAME_UC}_VERSION
${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
-SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
+SET(${PROJECT_NAME_UC}_VERSION_DEV 0)
# Find KERNEL
# ===========
<ul>
<li>\b File menu corresponds to \subpage study_management_page "Study management" functionalities
-(creation, saving, loading, editing studies, connecting, disconnecting, etc.).</li>
+(creation, saving, loading, connecting, disconnecting, editing studies, etc.)</li>
<li>\b Edit menu gives access to <b> Copy/Paste</b> allowing to paste the
objects from one study into the other. The availability of this
functionality depends on the module and the nature of an operation or
\page salome_desktop_page SALOME desktop
SALOME applies <b>Single Document Interface</b> (SDI) approach. Only one
-\ref study_management_page "study (document)" can be opened at the moment.
+\ref study_management_page "study (document)" can be opened at any given moment.
-The front-end of the application is represented as a single Desktop top-level window
-that embeds all GUI operations. Desktop window provides access to standard GUI elements
-like viewers, main menu, toolbars, dock windows, dialog boxes, etc.
+The front-end of the application is a single Desktop top-level window
+that embeds all GUI operations. The desktop window provides access to standard GUI elements,
+such as viewers, main menu, toolbars, dockable windows, dialog boxes, etc.
The main elements of the SALOME Desktop are represented on the picture below:
\image html desktop.png
The main parts of the SALOME Desktop are:
-- <b>Main menu</b> - This is a set of context-sensitive menus, which will
-be updated according to the functionality of the currently active component. In
+- <b>Main menu</b> - This is a set of context-sensitive menus
+updated according to the functionality of the currently active component. In
general, these menus contain all functional options of SALOME platform.
- <b>Standard toolbar</b> - contains standard actions
that allow creating new or opening existing study, saving study, deleting
-objects etc.
+objects, etc.
- <b>Components toolbar</b> - allows activating
components in SALOME platform.
- <b>Module toolbars</b> - contain actions specific to the
\page study_management_page Study management
-Study is a document within application, where you can carry out all
+Study is a document within the application, where you can carry out all
operations provided by the SALOME functionality.
This is a certain abstraction layer between actual
document data (probably, remote data available through CORBA) and data
\note SALOME is a single-study application. It means that only one study
can be opened at the moment.
-Immediately after application start-up there is (normally) no active study.
+Immediately after the application is launched there is (normally) no active study.
However, you have access to the embedded Python console, that can be used to initialize
-the study by means of Python API (see documentation on SALOME KERNEL module for more details).
+a study by means of Python API (see documentation on SALOME KERNEL module for more details).
The following operations are available from the \b File menu:
\image html menu_file.png
-As soon as study is created, loaded from the file or from the data server,
-some additional operations become available from the \b File menu:
+As soon as a study is created or loaded from a file or a data server,
+additional operations become available from the \b File menu:
\image html studymanagement.png
\b New - creates a new study. The study will be created
-with default name \b Study1. If there is already opened study,
+with default name \b Study1. If there is an already opened study,
you will be asked to close it before creating new one.
\b Open - allows to open an existing study by browsing for it in a
\b Disconnect - unloads the current study from the desktop. The study stays opened
in the data server; it can be then reloaded in the same working session
-(\b Connect operation), but if you quit SALOME application, all changes in the
+(using \b Connect operation), but if you quit SALOME application, all changes in the
unloaded study can be lost.
\note If the study has not been previously saved, you will be prompted
int LightApp_Application::lastStudyId = 0;
-
// Markers used to parse array with dockable windows and toolbars state.
// For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp
// in the Qt source code.
updateWindows();
updateViewManagers();
+ if ( activeStudy() && activeStudy()->root() && objectBrowser() && objectBrowser()->root() != activeStudy()->root() ) {
+ objectBrowser()->setRoot( activeStudy()->root() );
+ updateObjectBrowser( true );
+ }
return true;
}
#ifndef DISABLE_PYCONSOLE
if( pythonConsole() )
- pythonConsole()->getInterp()->initStudy();
+ getPyInterp()->initStudy();
#endif
}
#ifndef DISABLE_PYCONSOLE
if( pythonConsole() )
- pythonConsole()->getInterp()->initStudy();
+ getPyInterp()->initStudy();
#endif
emit studyOpened();
#ifndef DISABLE_PYCONSOLE
else if ( flag == WT_PyConsole )
{
- PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(),new LightApp_PyInterp());
+ PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(), getPyInterp() );
pyCons->setObjectName( "pythonConsole" );
pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
return result;
}
+#ifndef DISABLE_PYCONSOLE
+
+PyConsole_Interp* LightApp_Application::getPyInterp()
+{
+ static PyConsole_Interp* myInterp = 0;
+ if ( !myInterp )
+ myInterp = createPyInterp();
+ return myInterp;
+}
+
+PyConsole_Interp* LightApp_Application::createPyInterp()
+{
+ return new LightApp_PyInterp();
+}
+
+#endif // DISABLE_PYCONSOLE
class LogWindow;
#ifndef DISABLE_PYCONSOLE
class PyConsole_Console;
+class PyConsole_Interp;
#endif
class LightApp_WidgetContainer;
class LightApp_Preferences;
virtual bool checkExistingDoc();
+#ifndef DISABLE_PYCONSOLE
+ PyConsole_Interp* getPyInterp();
+#endif
+
signals:
void studyOpened();
void studySaved();
virtual QMap<int, QString> activateModuleActions() const;
virtual void moduleActionSelected( const int );
+#ifndef DISABLE_PYCONSOLE
+ virtual PyConsole_Interp* createPyInterp();
+#endif
+
protected slots:
virtual void onDesktopActivated();
virtual void onViewManagerRemoved( SUIT_ViewManager* );
{
if ( myCompDataType.isEmpty() ) {
SUIT_DataObject* aCompObj = componentObject();
- LightApp_ModuleObject* anObj = dynamic_cast<LightApp_ModuleObject*>( aCompObj );
+ CAM_ModuleObject* anObj = dynamic_cast<CAM_ModuleObject*>( aCompObj );
if ( anObj ) {
CAM_DataModel* aModel = anObj->dataModel();
if ( aModel ) {
class LightApp_PyInterp : public PyConsole_EnhInterp
{
+ friend class LightApp_Application;
+
public:
- LightApp_PyInterp();
virtual ~LightApp_PyInterp();
protected:
+ LightApp_PyInterp();
virtual void initPython();
};
<name>LightApp_Application</name>
<message>
<source>LANG_CHANGED</source>
- <translation>La langue de l'application a été modifié.
+ <translation>La langue de l'application a été modifiée.
+Les modifications seront appliquées à la prochaine session.</translation>
+ </message>
+ <message>
+ <source>LOCALE_CHANGED</source>
+ <translation>La locale de l'application a été modifiée.
Les modifications seront appliquées à la prochaine session.</translation>
</message>
<message>
</message>
<message>
<source>NEW_WINDOW_5</source>
- <translation>Sène G&raphiques</translation>
+ <translation>Scène G&raphiques</translation>
+ </message>
+ <message>
+ <source>NEW_WINDOW_6</source>
+ <translation>Scène ParaVie&w</translation>
</message>
<message>
<source>CREATING_NEW_WINDOW</source>
<source>PREF_CURRENT_LANGUAGE</source>
<translation>Langue actuelle</translation>
</message>
+ <message>
+ <source>PREF_CURRENT_LOCALE</source>
+ <translation>Utiliser la locale "C"</translation>
+ </message>
<message>
<source>PREF_GROUP_LOOK_AND_FEEL</source>
<translation>Aspect</translation>
</message>
<message>
<source>STUDYCLOSE_DESCRIPTION</source>
- <translation type="unfinished">You already have an active study in your
+ <translation type="unfinished">You already have an active study in your
session. It has to be closed before working with another study.</translation>
</message>
<message>
<source>NEW_WINDOW_5</source>
<translation>グラフィックの表示 (&r)</translation>
</message>
+ <message>
+ <source>NEW_WINDOW_6</source>
+ <translation type="unfinished">ParaVie&w view</translation>
+ </message>
<message>
<source>CREATING_NEW_WINDOW</source>
<translation>新しい %1 を作成します。</translation>
</message>
<message>
<source>DSC_FITALL</source>
- <translation>すべてのオブジェクトを表示するには、シーンを Redimentionner</translation>
+ <translation>すべてのオブジェクトを表示するには、シーンを</translation>
</message>
<message>
<source>MNU_CLIPPING</source>
<name>OCCViewer_AxialScaleDlg</name>
<message>
<source>DLG_SCALING</source>
- <translation>ã\82¹ã\82±ã\83¼ã\83ªã\83³ã\82°</translation>
+ <translation>ã\82¹ã\82±ã\83¼ã\83«ã\81®å¤\89æ\9b´</translation>
</message>
<message>
<source>LBL_X</source>
<translation>パラメータ</translation>
</message>
<message>
- <source>HELP</source>
- <translation>ヘルプ(&H)</translation>
+ <source>HELP</source>
+ <translation>ヘルプ(&H)</translation>
</message>
</context>
</TS>
# resource files / to be processed by lrelease
SET(_ts_RESOURCES
resources/PVViewer_msg_en.ts
+ resources/PVViewer_msg_ja.ts
)
# --- sources ---
#include <pqPropertiesPanel.h>
#include <pqPipelineBrowserWidget.h>
#include <pqParaViewMenuBuilders.h>
+#include <pqMainControlsToolbar.h>
+#include <pqVCRToolbar.h>
+#include <pqAnimationTimeToolbar.h>
+#include <pqColorToolbar.h>
+#include <pqRepresentationToolbar.h>
+#include <pqCameraToolbar.h>
+#include <pqAxesToolbar.h>
+#include <pqSetName.h>
+
+#include <pqPythonManager.h>
+#include <pqApplicationCore.h>
#include <QMenu>
#include <QList>
#include <QAction>
+#include <QToolBar>
+#include <QLayout>
+
+#include <QCoreApplication>
PVViewer_GUIElements * PVViewer_GUIElements::theInstance = 0;
pqParaViewMenuBuilders::buildFiltersMenu(*filtersMenu, desk);
macrosMenu = new QMenu(0);
pqParaViewMenuBuilders::buildMacrosMenu(*macrosMenu);
+
+ myBuildToolbars(desk);
}
PVViewer_GUIElements * PVViewer_GUIElements::GetInstance(SUIT_Desktop* desk)
return theInstance;
}
-//void PVViewer_GUIElements::updateSourcesMenu(QMenu *menu)
-//{
-// if (menu)
-// {
-// menu->clear();
-// QList<QAction *> act_list = sourcesMenu->actions();
-// foreach(QAction * a, act_list)
-// {
-// menu->addAction(a);
-// }
-// }
-//}
-//
-//void PVViewer_GUIElements::updateFiltersMenu(QMenu *menu)
-//{
-// if (menu)
-// {
-// filtersMenu->linkToMenu(menu);
-// menu->clear();
-// QList<QAction *> act_list = filtersMenu->actions();
-// foreach(QAction * a, act_list)
-// {
-// menu->addAction(a);
-// }
-// }
-//}
-//
-//void PVViewer_GUIElements::updateMacrosMenu(QMenu *menu)
-//{
-// if (menu)
-// {
-// menu->clear();
-// QList<QAction *> act_list = macrosMenu->actions();
-// foreach(QAction * a, act_list)
-// {
-// menu->addAction(a);
-// }
-// }
-//}
+/**
+ * See ParaView source code: pqParaViewMenuBuilders::buildToolbars()
+ * to keep this function up to date:
+ */
+void PVViewer_GUIElements::myBuildToolbars(SUIT_Desktop* mainWindow)
+{
+ mainToolBar = new pqMainControlsToolbar(mainWindow)
+ << pqSetName("MainControlsToolbar");
+ mainToolBar->layout()->setSpacing(0);
+
+ vcrToolbar = new pqVCRToolbar(mainWindow)
+ << pqSetName("VCRToolbar");
+ vcrToolbar->layout()->setSpacing(0);
+
+ timeToolbar = new pqAnimationTimeToolbar(mainWindow)
+ << pqSetName("currentTimeToolbar");
+ timeToolbar->layout()->setSpacing(0);
+
+ colorToolbar = new pqColorToolbar(mainWindow)
+ << pqSetName("variableToolbar");
+ colorToolbar->layout()->setSpacing(0);
+
+ reprToolbar = new pqRepresentationToolbar(mainWindow)
+ << pqSetName("representationToolbar");
+ reprToolbar->layout()->setSpacing(0);
+
+ cameraToolbar = new pqCameraToolbar(mainWindow)
+ << pqSetName("cameraToolbar");
+ cameraToolbar->layout()->setSpacing(0);
+ axesToolbar = new pqAxesToolbar(mainWindow)
+ << pqSetName("axesToolbar");
+ axesToolbar->layout()->setSpacing(0);
+
+ // Give the macros menu to the pqPythonMacroSupervisor
+ pqPythonManager* manager = qobject_cast<pqPythonManager*>(
+ pqApplicationCore::instance()->manager("PYTHON_MANAGER"));
+
+ macrosToolbar = new QToolBar("Macros Toolbars", mainWindow)
+ << pqSetName("MacrosToolbar");
+ manager->addWidgetForRunMacros(macrosToolbar);
+
+ addToolbars(mainWindow);
+}
+
+void PVViewer_GUIElements::setToolBarVisible(bool show)
+{
+ QCoreApplication::processEvents();
+ mainAction->setChecked(!show);
+ mainAction->trigger();
+ vcrAction->setChecked(!show);
+ vcrAction->trigger();
+ timeAction->setChecked(!show);
+ timeAction->trigger();
+ colorAction->setChecked(!show);
+ colorAction->trigger();
+ reprAction->setChecked(!show);
+ reprAction->trigger();
+ cameraAction->setChecked(!show);
+ cameraAction->trigger();
+ axesAction->setChecked(!show);
+ axesAction->trigger();
+ macrosAction->setChecked(!show);
+ macrosAction->trigger();
+}
+
+void PVViewer_GUIElements::addToolbars(SUIT_Desktop* desk)
+{
+ desk->addToolBar(Qt::TopToolBarArea, mainToolBar);
+ desk->addToolBar(Qt::TopToolBarArea, vcrToolbar);
+ desk->addToolBar(Qt::TopToolBarArea, timeToolbar);
+ desk->addToolBar(Qt::TopToolBarArea, colorToolbar);
+ desk->insertToolBarBreak(colorToolbar);
+ desk->addToolBar(Qt::TopToolBarArea, reprToolbar);
+ desk->addToolBar(Qt::TopToolBarArea, cameraToolbar);
+ desk->addToolBar(Qt::TopToolBarArea, axesToolbar);
+ desk->addToolBar(Qt::TopToolBarArea, macrosToolbar);
+
+ mainAction = mainToolBar->toggleViewAction();
+ vcrAction = vcrToolbar->toggleViewAction();
+ timeAction = timeToolbar->toggleViewAction();
+ colorAction = colorToolbar->toggleViewAction();
+ reprAction = reprToolbar->toggleViewAction();
+ cameraAction = cameraToolbar->toggleViewAction();
+ axesAction = axesToolbar->toggleViewAction();
+ macrosAction = macrosToolbar->toggleViewAction();
+}
void PVViewer_GUIElements::onEmulateApply()
{
class pqPipelineBrowserWidget;
class SUIT_Desktop;
class QMenu;
+class QToolBar;
+class QAction;
+class pqAnimationTimeToolbar;
+class pqVCRToolbar;
/*!
* Some GUI elements of ParaView need to be instanciated in a proper order. This class
QMenu * getSourcesMenu() { return sourcesMenu; }
QMenu * getMacrosMenu() { return macrosMenu; }
+ pqVCRToolbar * getVCRToolbar() { return vcrToolbar; }
+ pqAnimationTimeToolbar * getTimeToolbar() { return timeToolbar; }
+
+ void myBuildToolbars(SUIT_Desktop* desk);
+ void addToolbars(SUIT_Desktop* desk);
+ void setToolBarVisible(bool show);
public slots:
void onEmulateApply(); // better use the slot from PVViewer_ViewManager if you want to trigger "Apply"
QMenu * sourcesMenu;
QMenu * filtersMenu;
QMenu * macrosMenu;
+
+ // Toolbars also need to be instanciated early:
+ QToolBar* mainToolBar;
+ pqVCRToolbar* vcrToolbar;
+ pqAnimationTimeToolbar * timeToolbar;
+ QToolBar* colorToolbar;
+ QToolBar* reprToolbar;
+ QToolBar* cameraToolbar;
+ QToolBar* axesToolbar;
+ QToolBar* macrosToolbar;
+
+public:
+ QAction * mainAction;
+ QAction * vcrAction;
+ QAction * timeAction;
+ QAction * colorAction;
+ QAction * reprAction;
+ QAction * cameraAction;
+ QAction * axesAction;
+ QAction * macrosAction;
};
#endif /* PVVIEWERGUIELEMENTS_H_ */
#include <pqTabbedMultiViewWidget.h>
#include <pqApplicationCore.h>
+
/*!
\class PVViewer_ViewWindow
\brief PVGUI view window.
PVViewer_ViewManager::ParaviewInitBehaviors(true, theDesktop);
PVViewer_ViewManager::ConnectToExternalPVServer(theDesktop);
PVViewer_ViewManager::ParaviewLoadConfigurations();
+
+ // Hide toolbars
+ PVViewer_GUIElements * pvge = PVViewer_GUIElements::GetInstance(theDesktop);
+ pvge->setToolBarVisible(false);
} else
qDebug("No multiViewManager defined");
}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
+ <context>
+ <name>@default</name>
+ <message>
+ <translation type="unfinished"/>
+ </message>
+ </context>
+ <context>
+ <name>PVViewer_ViewManager</name>
+ <message>
+ <source>PARAVIEW_VIEW_TITLE</source>
+ <translation type="unfinished">ParaView scene:%M - viewer:%V</translation>
+ </message>
+ </context>
+</TS>
<name>@default</name>
<message>
<source>DASHDOT_LINE_LBL</source>
- <translation>TiretPoint</translation>
+ <translation>DashDot</translation>
</message>
<message>
<source>DASH_LINE_LBL</source>
</message>
<message>
<source>DAHSDOTDOT_LINE_LBL</source>
- <translation>TiretPointPoint</translation>
+ <translation>DashDotDot</translation>
</message>
<message>
<source>NONE_LINE_LBL</source>
<source>DIAMOND_MARKER_LBL</source>
<translation>ダイヤモンド</translation>
</message>
- <message>
- <source>NONE_MARKER_LBL</source>
- <translation>[なし]</translation>
- </message>
<message>
<source>CIRCLE_MARKER_LBL</source>
<translation>円</translation>
</message>
+ <message>
+ <source>NONE_MARKER_LBL</source>
+ <translation>[なし]</translation>
+ </message>
</context>
<context>
<name>Plot2d_FitDataDlg</name>
</message>
<message>
<source>PREF_BOTTOM</source>
- <translation type="unfinished">Bottom</translation>
+ <translation>下</translation>
</message>
<message>
<source>PREF_CURVE_TYPE</source>
<source>PLOT2D_SELECTED_LEGEND_FONT_COLOR</source>
<translation>ハイライト凡例フォントの色:</translation>
</message>
-</context>
-<context>
+ </context>
+ <context>
<name>Plot2d_SetupCurveDlg</name>
<message>
<source>TLT_SETUP_CURVE</source>
</message>
<message>
<source>CURVE_LINE_WIDTH_LAB</source>
- <translation>線の太さ:</translation>
+ <translation>線幅:</translation>
</message>
<message>
<source>CURVE_LINE_TYPE_LAB</source>
- <translation>回線の種類:</translation>
+ <translation>線種:</translation>
</message>
<message>
<source>CURVE_COLOR_LAB</source>
</message>
<message>
<source>CURVE_PREVIEW_LAB</source>
- <translation>プレビュー</translation>
+ <translation>プレビュー:</translation>
</message>
<message>
<source>CURVE_MARKER_TYPE_LAB</source>
<translation>マーカーの種類:</translation>
</message>
-</context>
-<context>
+ </context>
+ <context>
<name>Plot2d_ViewWindow</name>
<message>
<source>MNU_DUMP_VIEW</source>
- <translation>ビューを保存.</translation>
+ <translation type="unfinished">Dump view...</translation>
</message>
<message>
<source>MNU_PAN_VIEW</source>
- <translation>パンニング</translation>
+ <translation>パン</translation>
</message>
<message>
<source>MNU_CLONE_VIEW</source>
- <translation>ビューの複製</translation>
+ <translation type="unfinished">Clone View</translation>
</message>
<message>
<source>MNU_PRINT_VIEW</source>
- <translation>印刷ビュー</translation>
+ <translation type="unfinished">Print View</translation>
</message>
<message>
<source>POSTSCRIPT_FILES</source>
</message>
<message>
<source>ENCAPSULATED_POSTSCRIPT_FILES</source>
- <translation>カプセル化された PostScript (*.eps) ファイル</translation>
+ <translation>カプセル化された PostScript ファイル (*.eps)</translation>
</message>
<message>
<source>PDF_FILES</source>
</message>
<message>
<source>DSC_GLOBALPAN_VIEW</source>
- <translation>ビューの新しい中心地の選択</translation>
+ <translation type="unfinished">Selection of a new center of the view</translation>
</message>
<message>
<source>PRP_PLOT2D_MODE_LINEAR_VER</source>
- <translation>線形スケールのモードには、垂直軸の表示を変更します。</translation>
+ <translation type="unfinished">Switches view to linear scaling mode along vertical axis</translation>
</message>
<message>
<source>PRP_PLOT2D_MODE_LINEAR_HOR</source>
- <translation>線形スケールのモードに、ビューの水平方向の軸を変更します。</translation>
+ <translation type="unfinished">Switches view to linear scaling mode along horizontal axis</translation>
</message>
<message>
<source>CURVE_TYPE_POPUP</source>
- <translation>曲線の種類</translation>
+ <translation type="unfinished">Curve type</translation>
</message>
<message>
<source>NORMALIZATION_TYPE_POPUP</source>
- <translation>標準化</translation>
+ <translation type="unfinished">Normalization</translation>
</message>
<message>
<source>TOT_PLOT2D_MODE_LINEAR_VER</source>
- <translation>垂直軸: 線形</translation>
+ <translation type="unfinished">Vertical axis: linear</translation>
</message>
<message>
<source>TOT_PLOT2D_MODE_LINEAR_HOR</source>
- <translation>水平軸: 線形</translation>
+ <translation type="unfinished">Horizontal axis: linear</translation>
</message>
<message>
<source>MNU_ZOOM_VIEW</source>
</message>
<message>
<source>DSC_PAN_VIEW</source>
- <translation>ã\83\93ã\83¥ã\83¼ã\82\92移å\8b\95ã\81\97ã\81¾ã\81\99ã\80\82</translation>
+ <translation>ã\83\91ã\83³</translation>
</message>
<message>
<source>PRP_PLOT2D_CURVES_SPLINES</source>
- <translation>表示モードのスプラインを変更します。</translation>
+ <translation type="unfinished">Switches view to splines mode</translation>
</message>
<message>
<source>DSC_FITALL</source>
- <translation>すべてのオブジェクトを表示するには、シーンを調整します。</translation>
+ <translation>全表示</translation>
</message>
<message>
<source>MNU_FITALL</source>
- <translation>すべて表示</translation>
+ <translation>全表示</translation>
</message>
<message>
<source>TOT_PLOT2D_MODE_LOGARITHMIC_HOR</source>
- <translation>水平軸: 対数</translation>
+ <translation type="unfinished">Horizontal axis: logarithmic</translation>
</message>
<message>
<source>TOT_PLOT2D_MODE_LOGARITHMIC_VER</source>
- <translation>垂直軸: 対数</translation>
+ <translation type="unfinished">Vertical axis: logarithmic</translation>
</message>
<message>
<source>MNU_GLOBALPAN_VIEW</source>
- <translation>グローバルパンニング</translation>
+ <translation type="unfinished">Global Panning</translation>
</message>
<message>
<source>DSC_CLONE_VIEW</source>
- <translation>現在のステージの新しいビューアー OCC を開く</translation>
+ <translation type="unfinished">Create new OCC viewer for the active scene</translation>
</message>
<message>
<source>DSC_PRINT_VIEW</source>
- <translation>現在のビューを印刷します。</translation>
+ <translation type="unfinished">Print active view</translation>
</message>
<message>
<source>TOT_PLOT2D_SETTINGS</source>
- <translation>パラメーター</translation>
+ <translation type="unfinished">Settings</translation>
</message>
<message>
<source>TOT_PLOT2D_ANALYTICAL_CURVES</source>
- <translation>分析曲線</translation>
+ <translation type="unfinished">Analytical curves</translation>
</message>
<message>
<source>TOT_PLOT2D_NORMALIZE_MODE_LMAX</source>
- <translation>左の Y 軸: グローバルの最大値を標準化します。</translation>
+ <translation type="unfinished">Left Y Axis: Normalize to global maximum</translation>
</message>
<message>
<source>TOT_PLOT2D_NORMALIZE_MODE_LMIN</source>
- <translation>左の Y 軸: 世界最小の標準化</translation>
+ <translation type="unfinished">Left Y Axis: Normalize to global minimum</translation>
</message>
<message>
<source>TOT_PLOT2D_NORMALIZE_MODE_RMAX</source>
- <translation>右の Y 軸: グローバルの最大値を標準化します。</translation>
+ <translation type="unfinished">Right Y Axis: Normalize to global maximum</translation>
</message>
<message>
<source>TOT_PLOT2D_NORMALIZE_MODE_RMIN</source>
- <translation>右の Y 軸: 世界最小の標準化</translation>
+ <translation type="unfinished">Right Y Axis: Normalize to global minimum</translation>
</message>
<message>
<source>MEN_PLOT2D_CURVES_SPLINES</source>
- <translation>スプラインを描画します。</translation>
+ <translation>2Dスプラインカーブ</translation>
</message>
<message>
<source>PRP_PLOT2D_MODE_LOGARITHMIC_HOR</source>
- <translation>横軸に対数スケール モードの表示方法を変更</translation>
+ <translation type="unfinished">Switches view to logarithmic scaling mode along horizontal axis</translation>
</message>
<message>
<source>PRP_PLOT2D_MODE_LOGARITHMIC_VER</source>
- <translation>垂直軸を対数スケール モードの表示方法を変更</translation>
+ <translation type="unfinished">Switches view to logarithmic scaling mode along vertical axis</translation>
</message>
<message>
<source>TOT_PLOT2D_CURVES_POINTS</source>
- <translation>ポイントを描画します。</translation>
+ <translation type="unfinished">Draw points</translation>
</message>
<message>
<source>DSC_FITRECT</source>
- <translation>シーンのボックスで選択した領域を調整します。</translation>
+ <translation>領域でフィット</translation>
</message>
<message>
<source>MNU_FITRECT</source>
- <translation>表示エリア</translation>
+ <translation>領域でフィット</translation>
</message>
<message>
<source>MEN_PLOT2D_CURVES_POINTS</source>
- <translation>ポイントを描画します。</translation>
+ <translation type="unfinished">Draw Points</translation>
</message>
<message>
<source>PRP_PLOT2D_CURVES_POINTS</source>
- <translation>表示モードのポイントを変更します。</translation>
+ <translation type="unfinished">Switches view to points mode</translation>
</message>
<message>
<source>DSC_DUMP_VIEW</source>
- <translation>現在のビューをイメージ ファイルに保存します。</translation>
+ <translation type="unfinished">Saves the active view in the image file</translation>
</message>
<message>
<source>DSC_ZOOM_VIEW</source>
</message>
<message>
<source>PRP_PLOT2D_ANALYTICAL_CURVES</source>
- <translation>分析曲線のプロパティを設定します。</translation>
+ <translation type="unfinished">Setups analytical curves properties</translation>
</message>
<message>
<source>PRP_PLOT2D_NORMALIZE_MODE_LMAX</source>
- <translation>左側の Y 軸の最大の標準化の方法に、ビューを切り替える</translation>
+ <translation type="unfinished">Switches view to maximum normalization mode by left Y axis</translation>
</message>
<message>
<source>PRP_PLOT2D_NORMALIZE_MODE_LMIN</source>
- <translation>左側の Y 軸の最小の標準化の方法に、ビューを切り替える</translation>
+ <translation type="unfinished">Switches view to minimum normalization mode by left Y axis</translation>
</message>
<message>
<source>PRP_PLOT2D_NORMALIZE_MODE_RMAX</source>
- <translation>右側の Y 軸の最大の標準化の方法に、ビューを切り替える</translation>
+ <translation type="unfinished">Switches view to maximum normalization mode by right Y axis</translation>
</message>
<message>
<source>PRP_PLOT2D_NORMALIZE_MODE_RMIN</source>
</message>
<message>
<source>TOT_PLOT2D_CURVES_LINES</source>
- <translation>線を描く</translation>
+ <translation>線を描</translation>
</message>
<message>
<source>PRP_PLOT2D_CURVES_LINES</source>
<source>INF_COORDINATES</source>
<translation>お問い合わせ: x: %1、y: %2</translation>
</message>
- <message>
- <source>INF_COORDINATES_SOME_Y</source>
- <translation>お問い合わせ: x: %1、y: %2 ( %3 )</translation>
- </message>
<message>
<source>WRN_XLOG_NOT_ALLOWED</source>
<translation>X 軸上非陽性値を持つポイントが検出されました。カテゴリの対数目盛は許可されていません。</translation>
<source>WRN_YLOG_NOT_ALLOWED</source>
<translation>Y 軸上非陽性値を持つポイントが検出されました。切片の対数目盛は許可されていません。</translation>
</message>
+ <message>
+ <source>INF_COORDINATES_SOME_Y</source>
+ <translation>お問い合わせ: x: %1、y: %2 ( %3 )</translation>
+ </message>
</context>
</TS>
PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* interp )
: QWidget( parent )
{
- // create python interpreter
- myInterp = interp;
- if ( !myInterp )
- myInterp = new PyConsole_Interp();
+ PyConsole_Interp* anInterp = interp ? interp : new PyConsole_Interp();
// initialize Python interpretator
- myInterp->initialize();
+ anInterp->initialize();
// create editor console
QVBoxLayout* lay = new QVBoxLayout( this );
lay->setMargin( 0 );
- myEditor = new PyConsole_Editor( myInterp, this );
+ myEditor = new PyConsole_Editor( anInterp, this );
char* synchronous = getenv("PYTHON_CONSOLE_SYNC");
if (synchronous && atoi(synchronous))
{
/**
* Protected constructor.
*/
-PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* i, PyConsole_Editor* e)
- : QWidget (parent), myEditor(e), myInterp(i)
+PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* /*i*/, PyConsole_Editor* e )
+ : QWidget (parent), myEditor(e)
{}
/*!
{
}
+PyConsole_Interp* PyConsole_Console::getInterp() const
+{
+ return myEditor ? myEditor->getInterp() : 0;
+}
+
/*!
\brief Execute python command in the interpreter.
\param command string with command and arguments
* @param parent
* @param interp
*/
-PyConsole_EnhConsole::PyConsole_EnhConsole( QWidget* parent, PyConsole_EnhInterp* interp)
- : PyConsole_Console(parent, interp, 0)
+PyConsole_EnhConsole::PyConsole_EnhConsole( QWidget* parent, PyConsole_Interp* interp )
+ : PyConsole_Console( parent, interp, 0 )
{
- // create python interpreter
- myInterp = interp;
- if ( !myInterp )
- myInterp = new PyConsole_EnhInterp();
+ PyConsole_Interp* anInterp = interp ? interp : new PyConsole_EnhInterp();
// initialize Python interpretator
- myInterp->initialize();
+ anInterp->initialize();
// create editor console
QVBoxLayout* lay = new QVBoxLayout( this );
lay->setMargin( 0 );
- myEditor = new PyConsole_EnhEditor( static_cast<PyConsole_EnhInterp*>(myInterp), this );
+ myEditor = new PyConsole_EnhEditor( anInterp, this );
char* synchronous = getenv("PYTHON_CONSOLE_SYNC");
if (synchronous && atoi(synchronous))
{
class PyConsole_Interp;
class PyConsole_Editor;
-class PyConsole_EnhInterp;
class PYCONSOLE_EXPORT PyConsole_Console : public QWidget, public SUIT_PopupClient
{
virtual ~PyConsole_Console();
//! \brief Get python interperter
- PyConsole_Interp* getInterp() { return myInterp; }
+ PyConsole_Interp* getInterp() const;
QFont font() const;
virtual void setFont( const QFont& );
PyConsole_Console( QWidget* parent, PyConsole_Interp*, PyConsole_Editor*);
-
- PyConsole_Interp* myInterp; //!< python interpreter
PyConsole_Editor* myEditor; //!< python console editor widget
QMap<int, QAction*> myActions; //!< menu actions list
};
Q_OBJECT
public:
- PyConsole_EnhConsole( QWidget* parent, PyConsole_EnhInterp* interp = 0);
+ PyConsole_EnhConsole( QWidget* parent, PyConsole_Interp* interp = 0 );
virtual ~PyConsole_EnhConsole() {}
};
#include <QTextStream>
#include <QChar>
+//VSR: uncomment below macro to support unicode text properly in SALOME
+// current commented out due to regressions
+//#define PAL22528_UNICODE
+
+namespace
+{
+ QString fromUtf8( const char* txt )
+ {
+#ifdef PAL22528_UNICODE
+ return QString::fromUtf8( txt );
+#else
+ return QString( txt );
+#endif
+ }
+}
+
static QString READY_PROMPT = ">>> ";
static QString DOTS_PROMPT = "... ";
{
if(!((PyConsole_Editor*)data)->isSuppressOutput()) {
PyConsole_Editor* e = (PyConsole_Editor*)data;
- e->putLog( QString::fromUtf8(c) );
- QApplication::postEvent( e, new PrintEvent( QString::fromUtf8(c), false ) );
+ e->putLog( fromUtf8(c) );
+ QApplication::postEvent( e, new PrintEvent( fromUtf8(c), false ) );
}
}
{
if(!((PyConsole_Editor*)data)->isSuppressOutput()) {
PyConsole_Editor* e = (PyConsole_Editor*)data;
- e->putLog( QString::fromUtf8(c) );
- QApplication::postEvent( e, new PrintEvent( QString::fromUtf8(c), true ) );
+ e->putLog( fromUtf8(c) );
+ QApplication::postEvent( e, new PrintEvent( fromUtf8(c), true ) );
}
}
/*!
\brief Destructor.
-
- Does nothing for the moment.
*/
PyConsole_Editor::~PyConsole_Editor()
{
- myInterp->destroy();
- delete myInterp;
myInterp = 0;
}
+/*!
+ \brief Get Python interpreter
+*/
+PyConsole_Interp* PyConsole_Editor::getInterp() const
+{
+ return myInterp;
+}
+
/*!
\brief Get synchronous mode flag value.
public:
PyConsole_Editor( PyConsole_Interp* theInterp, QWidget *theParent = 0 );
~PyConsole_Editor();
+
+ PyConsole_Interp* getInterp() const;
virtual void addText( const QString& str, const bool newBlock = false, const bool isError = false );
bool isCommand( const QString& str ) const;
* @param interp the interpreter linked to the editor
* @param parent parent widget
*/
-PyConsole_EnhEditor::PyConsole_EnhEditor(PyConsole_EnhInterp * interp, QWidget * parent) :
+PyConsole_EnhEditor::PyConsole_EnhEditor(PyConsole_Interp* interp, QWidget* parent) :
PyConsole_Editor(interp, parent),
_tab_mode(false),
_cursor_pos(-1),
setTextCursor(tc);
textCursor().deletePreviousChar();
// TODO: before wait for any TAB event to be completed
- static_cast<PyConsole_EnhInterp *>(myInterp)->clearCompletion();
+ if ( myInterp )
+ myInterp->clearCompletion();
}
_tab_mode = false;
}
_compl_before_point = QString("");
}
- return new CompletionCommand( static_cast<PyConsole_EnhInterp *>(myInterp), _compl_before_point,
- _compl_after_point, this, isSync() );
+ return new CompletionCommand( myInterp, _compl_before_point,
+ _compl_after_point, this, isSync() );
}
/**
* @param matches list of possible completions
* @param result return value
*/
-void PyConsole_EnhEditor::formatCompletion(const std::vector<QString> & matches, QString & result) const
+void PyConsole_EnhEditor::formatCompletion(const QStringList& matches, QString& result) const
{
int sz = matches.size();
*/
void PyConsole_EnhEditor::customEvent( QEvent* event )
{
- std::vector<QString> matches;
+ QStringList matches;
QString first_match, comple_text, doc, base;
QTextCursor cursor(textCursor());
QTextBlockFormat bf;
QTextCharFormat cf;
- PyConsole_EnhInterp * interp = static_cast<PyConsole_EnhInterp *>(myInterp);
int cursorPos;
switch( event->type() )
{
case PyInterp_Event::ES_TAB_COMPLETE_OK:
+ {
// Extract corresponding matches from the interpreter
- matches = interp->getLastMatches();
+ matches = getInterp()->getLastMatches();
+ doc = getInterp()->getDocStr();
if (matches.size() == 0)
- {
- // Completion successful but nothing returned.
- _tab_mode = false;
- _cursor_pos = -1;
- return;
- }
-
+ {
+ // Completion successful but nothing returned.
+ _tab_mode = false;
+ _cursor_pos = -1;
+ return;
+ }
+
// Only one match - complete directly and update doc string window
- doc = interp->getDocStr();
if (matches.size() == 1)
- {
- first_match = matches[0].mid(_compl_after_point.size());
- cursor.insertText(first_match);
- _tab_mode = false;
- if (doc == QString(""))
- emit updateDoc(formatDocHTML("(no documentation available)\n"));
- else
- emit updateDoc(formatDocHTML(doc));
- }
+ {
+ first_match = matches[0].mid(_compl_after_point.size());
+ cursor.insertText(first_match);
+ _tab_mode = false;
+ if (doc.isEmpty())
+ emit updateDoc(formatDocHTML("(no documentation available)\n"));
+ else
+ emit updateDoc(formatDocHTML(doc));
+ }
else
- {
- // Detect if there is a common base to all available completion
- // In this case append this base to the text already
- extractCommon(matches, base);
- first_match = base.mid(_compl_after_point.size());
- cursor.insertText(first_match);
-
- // If this happens to match exaclty the first completion
- // also provide doc
- if (base == matches[0])
- {
- doc = formatDocHTML(doc);
- emit updateDoc(doc);
- }
-
- // Print all matching completion in a "undo-able" block
- cursorPos = cursor.position();
- cursor.insertBlock();
- cursor.beginEditBlock();
-
- // Insert all matches
- QTextCharFormat cf;
- cf.setForeground(QBrush(Qt::darkGreen));
- cursor.setCharFormat(cf);
- formatCompletion(matches, comple_text);
- cursor.insertText(comple_text);
- cursor.endEditBlock();
-
- // Position cursor where it was before inserting the completion list:
- cursor.setPosition(cursorPos);
- setTextCursor(cursor);
- }
+ {
+ // Detect if there is a common base to all available completion
+ // In this case append this base to the text already
+ extractCommon(matches, base);
+ first_match = base.mid(_compl_after_point.size());
+ cursor.insertText(first_match);
+
+ // If this happens to match exaclty the first completion
+ // also provide doc
+ if (base == matches[0])
+ {
+ doc = formatDocHTML(doc);
+ emit updateDoc(doc);
+ }
+
+ // Print all matching completion in a "undo-able" block
+ cursorPos = cursor.position();
+ cursor.insertBlock();
+ cursor.beginEditBlock();
+
+ // Insert all matches
+ QTextCharFormat cf;
+ cf.setForeground(QBrush(Qt::darkGreen));
+ cursor.setCharFormat(cf);
+ formatCompletion(matches, comple_text);
+ cursor.insertText(comple_text);
+ cursor.endEditBlock();
+
+ // Position cursor where it was before inserting the completion list:
+ cursor.setPosition(cursorPos);
+ setTextCursor(cursor);
+ }
break;
+ }
case PyInterp_Event::ES_TAB_COMPLETE_ERR:
+ {
// Tab completion was unsuccessful, switch off mode:
_tab_mode = false;
_cursor_pos = -1;
break;
+ }
case PyInterp_Event::ES_OK:
case PyInterp_Event::ES_ERROR:
case PyInterp_Event::ES_INCOMPLETE:
+ {
// Before everything else, call super()
PyConsole_Editor::customEvent(event);
// If we are in multi_paste_mode, process the next item:
multiLineProcessNextLine();
break;
+ }
default:
+ {
PyConsole_Editor::customEvent( event );
break;
+ }
}
}
* @param matches
* @param result
*/
-void PyConsole_EnhEditor::extractCommon(const std::vector<QString> & matches, QString & result) const
+void PyConsole_EnhEditor::extractCommon(const QStringList& matches, QString& result) const
{
result = "";
int charIdx = 0;
#define PYCONSOLE_ENHEDITOR_H_
#include "PyConsole.h"
-
#include "PyConsole_Editor.h"
+
#include <QObject>
#include <queue>
-class PyConsole_EnhInterp;
-
/**
* Enhanced Python editor handling tab completion.
*/
Q_OBJECT;
public:
- PyConsole_EnhEditor(PyConsole_EnhInterp * interp, QWidget * parent=0);
+ PyConsole_EnhEditor(PyConsole_Interp* interp, QWidget* parent = 0);
virtual ~PyConsole_EnhEditor() {}
signals:
virtual void handleTab();
virtual void handleBackTab();
virtual void clearCompletion();
- virtual void formatCompletion(const std::vector<QString> & matches, QString & result) const;
+ virtual void formatCompletion(const QStringList& matches, QString& result) const;
virtual QString formatDocHTML(const QString & doc) const;
virtual void multilinePaste(const QString & s);
virtual void multiLineProcessNextLine();
private:
- void extractCommon(const std::vector<QString> & matches, QString & result) const;
+ void extractCommon(const QStringList& matches, QString& result) const;
};
const std::vector<QString> PyConsole_EnhInterp::PYTHON_KEYWORDS = \
std::vector<QString>(tmp_k, tmp_k+sizeof(tmp_k)/sizeof(tmp_k[0]));
+/*!
+ \brief Constructor
+*/
+PyConsole_EnhInterp::PyConsole_EnhInterp()
+ : PyConsole_Interp()
+{
+}
+
+/*!
+ \brief Destructor
+*/
+PyConsole_EnhInterp::~PyConsole_EnhInterp()
+{
+}
+
+QStringList PyConsole_EnhInterp::getLastMatches() const
+{
+ return _last_matches;
+}
+
+QString PyConsole_EnhInterp::getDocStr() const
+{
+ return _doc_str;
+}
+
/*!
\brief Run Python dir() command and saves the result internally in _lastPy
\param dirArgument Python expression to pass to the dir command. The parsing of what the
the user types "a_string_variable.rsp <TAB>", this is "rsp".
\return command exit status - 0 = success
*/
-int PyConsole_EnhInterp::runDirCommand(const QString & dirArgument, const QString & startMatch)
+int PyConsole_EnhInterp::runDirCommand(const QString& dirArgument, const QString& startMatch)
{
int ret;
std::vector<QString> v;
* @return -1 if the call to dir() or the parsing of the result failed, 0 otherwise.
*/
int PyConsole_EnhInterp::runDirAndExtract(const QString& dirArgument,
- const QString & startMatch, std::vector<QString> & result,
- bool discardSwig) const
+ const QString& startMatch,
+ QStringList& result,
+ bool discardSwig) const
{
QRegExp re("^[A-Z].+_[A-Z]+[a-z]+.+$"); // discard SWIG static method, e.g. MEDCouplingUMesh_Blabla
QString command("dir(" + dirArgument + ")");
*/
void PyConsole_EnhInterp::clearCompletion()
{
- _last_matches.resize(0);
- _doc_str = QString("");
+ _last_matches.clear();
+ _doc_str = "";
}
-
-
-
class PYCONSOLE_EXPORT PyConsole_EnhInterp: public PyConsole_Interp
{
public:
- PyConsole_EnhInterp()
- : PyConsole_Interp(), _last_matches(0), _doc_str("")
- {}
+ PyConsole_EnhInterp();
+ virtual ~PyConsole_EnhInterp();
- virtual ~PyConsole_EnhInterp() {}
-
- const std::vector<QString>& getLastMatches() const { return _last_matches; }
- const QString & getDocStr() const { return _doc_str; }
+ virtual QStringList getLastMatches() const;
+ virtual QString getDocStr() const;
virtual int runDirCommand(const QString& dirArgument, const QString& startMatch);
virtual void clearCompletion();
static const std::vector<QString> PYTHON_KEYWORDS;
/** Last computed matches */
- std::vector<QString> _last_matches;
+ QStringList _last_matches;
/** Doc string of the first match - when only one match it will be displayed by the Editor*/
QString _doc_str;
- virtual int runDirAndExtract(const QString& dirArgument, const QString & startMatch,
- std::vector<QString> & result, bool discardSwig=true) const;
-
+ virtual int runDirAndExtract(const QString& dirArgument, const QString& startMatch,
+ QStringList& result, bool discardSwig=true) const;
};
#endif /* PYCONSOLE_ENHINTERP_H_ */
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-
-// SALOME SALOMEGUI : implementation of desktop and GUI kernel
// File : PyConsole_Interp.cxx
// Author : Nicolas REJNERI, Adrien BRUNETON
-// Module : SALOME
-//
+
#include "PyConsole_Interp.h"
/*!
Creates new python interpreter.
*/
PyConsole_Interp::PyConsole_Interp(): PyInterp_Interp()
-{}
+{
+}
/*!
\brief Destructor.
Does nothing for the moment.
*/
-PyConsole_Interp::~PyConsole_Interp() { }
+PyConsole_Interp::~PyConsole_Interp()
+{
+}
/*! Sets the variable "__IN_SALOME_GUI_CONSOLE" to True.
* This is not attached to a module (like salome_iapp.IN_SALOME_GUI_CONSOLE)
{
return PyRun_SimpleString("__builtins__.__IN_SALOME_GUI_CONSOLE=False");
}
+
+QStringList PyConsole_Interp::getLastMatches() const
+{
+ return QStringList();
+}
+
+QString PyConsole_Interp::getDocStr() const
+{
+ return QString();
+}
+
+int PyConsole_Interp::runDirCommand(const QString&, const QString& )
+{
+ return 0;
+}
+
+void PyConsole_Interp::clearCompletion()
+{
+}
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-
-// SALOME SALOMEGUI : implementation of desktop and GUI kernel
// File : PyConsole_Interp.h
// Author : Nicolas REJNERI, Adrien BRUNETON
-// Module : SALOME
-//
+
#ifndef PYCONSOLE_INTERP_H
#define PYCONSOLE_INTERP_H
#include "PyConsole.h"
+#include "PyInterp_Interp.h" /// !!! WARNING !!! THIS INCLUDE MUST BE VERY FIRST !!!
-#include <PyInterp_Interp.h> /// !!! WARNING !!! THIS INCLUDE MUST BE VERY FIRST !!!
+#include <QStringList>
class PYCONSOLE_EXPORT PyConsole_Interp : public PyInterp_Interp
{
virtual int afterRun();
virtual int beforeRun();
+
+ virtual QStringList getLastMatches() const;
+ virtual QString getDocStr() const;
+
+ virtual int runDirCommand(const QString&, const QString&);
+ virtual void clearCompletion();
};
#endif // PYCONSOLE_INTERP_H
// Created on: 3 avr. 2013
#include "PyConsole_Request.h"
-
-#include "PyInterp_Event.h"
+#include "PyConsole_Interp.h"
#include "PyConsole_Event.h"
-#include "PyConsole_EnhInterp.h"
-#include "PyConsole_EnhEditor.h"
+#include "PyInterp_Event.h"
#include <QCoreApplication>
* @param sync
*/
ExecCommand::ExecCommand( PyInterp_Interp* theInterp,
- const QString& theCommand,
- PyConsole_Editor* theListener,
- bool sync )
- : PyInterp_LockRequest( theInterp, theListener, sync ),
- myCommand( theCommand ), myState( PyInterp_Event::ES_OK )
- {}
+ const QString& theCommand,
+ QObject* theListener,
+ bool theSync )
+ : PyInterp_LockRequest( theInterp, theListener, theSync ),
+ myCommand( theCommand ), myState( PyInterp_Event::ES_OK )
+{}
/**
* Execute the command by calling the run() method of the embedded interpreter.
void ExecCommand::execute()
{
if ( myCommand != "" )
- {
- int ret = getInterp()->run( myCommand.toUtf8().data() );
- if ( ret < 0 )
- myState = PyInterp_Event::ES_ERROR;
- else if ( ret > 0 )
- myState = PyInterp_Event::ES_INCOMPLETE;
- }
+ {
+ int ret = getInterp()->run( myCommand.toUtf8().data() );
+ if ( ret < 0 )
+ myState = PyInterp_Event::ES_ERROR;
+ else if ( ret > 0 )
+ myState = PyInterp_Event::ES_INCOMPLETE;
+ }
}
/**
\param theListener widget to get the notification messages
\param sync if True the request is processed synchronously
*/
-CompletionCommand::CompletionCommand( PyConsole_EnhInterp* theInterp,
- const QString& input,
- const QString& startMatch,
- PyConsole_EnhEditor* theListener,
- bool sync)
- : PyInterp_LockRequest( theInterp, theListener, sync ),
- _tabSuccess(false), _dirArg(input), _startMatch(startMatch)
+CompletionCommand::CompletionCommand( PyInterp_Interp* theInterp,
+ const QString& theInput,
+ const QString& theStartMatch,
+ QObject* theListener,
+ bool theSync )
+ : PyInterp_LockRequest( theInterp, theListener, theSync ),
+ _tabSuccess(false), _dirArg(theInput), _startMatch(theStartMatch)
{}
/**
*/
void CompletionCommand::execute()
{
- PyConsole_EnhInterp * interp = static_cast<PyConsole_EnhInterp *>(getInterp());
- int ret = interp->runDirCommand( _dirArg, _startMatch);
- if (ret == 0)
- _tabSuccess = true;
- else
- _tabSuccess = false;
+ int ret = static_cast<PyConsole_Interp*>(getInterp())->runDirCommand( _dirArg, _startMatch );
+ _tabSuccess = ret == 0;
}
/**
QEvent* CompletionCommand::createEvent()
{
int typ = _tabSuccess ? PyInterp_Event::ES_TAB_COMPLETE_OK : PyInterp_Event::ES_TAB_COMPLETE_ERR;
-
return new PyInterp_Event( typ, this);
}
-
-
-
#ifndef PYCONSOLE_REQUEST_H_
#define PYCONSOLE_REQUEST_H_
-#include "PyConsole.h"
#include "PyInterp_Request.h"
#include <vector>
#include <QEvent>
class PyInterp_Interp;
-class PyConsole_Editor;
/*!
\class ExecCommand
*/
ExecCommand( PyInterp_Interp* theInterp,
const QString& theCommand,
- PyConsole_Editor* theListener,
- bool sync = false );
+ QObject* theListener,
+ bool theSync = false );
protected:
/*!
int myState; //!< Python command execution status
};
-class PyConsole_EnhInterp;
-class PyConsole_EnhEditor;
-
class CompletionCommand : public PyInterp_LockRequest
{
public:
- CompletionCommand( PyConsole_EnhInterp* theInterp,
- const QString& input,
- const QString& startMatch,
- PyConsole_EnhEditor* theListener,
- bool sync = false );
+ CompletionCommand( PyInterp_Interp* theInterp,
+ const QString& theInput,
+ const QString& theStartMatch,
+ QObject* theListener,
+ bool theSync = false );
protected:
virtual void execute();
virtual QEvent* createEvent();
-
};
#endif /* PYCONSOLE_REQUEST_H_ */
</message>
<message>
<source>EDIT_STARTLOG_CMD</source>
- <translation type="unfinished">Start &Log</translation>
+ <translation>Démarrer une &trace</translation>
</message>
<message>
<source>EDIT_STOPLOG_CMD</source>
- <translation type="unfinished">Stop &Log</translation>
+ <translation>Arrêter la &trace</translation>
</message>
</context>
<context>
<translation>スクリプト コマンドを生成します。(&u)</translation>
</message>
<message>
- <source>EDIT_STARTLOG_CMD</source>
- <translation type="unfinished">Start &Log</translation>
+ <source>EDIT_STARTLOG_CMD</source>
+ <translation type="unfinished">Start &Log</translation>
</message>
<message>
- <source>EDIT_STOPLOG_CMD</source>
- <translation type="unfinished">Stop &Log</translation>
+ <source>EDIT_STOPLOG_CMD</source>
+ <translation type="unfinished">Stop &Log</translation>
</message>
</context>
<context>
<translation>スクリプト コマンドを生成します。</translation>
</message>
<message>
- <source>TOT_SAVE_PYLOG</source>
- <translation type="unfinished">Save log</translation>
+ <source>TOT_SAVE_PYLOG</source>
+ <translation type="unfinished">Save log</translation>
</message>
<message>
<source>PYTHON_FILES_FILTER</source>
<translation>ファイル (*.py) PYTHON</translation>
</message>
<message>
- <source>LOG_FILES_FILTER</source>
- <translation type="unfinished">Log files (*.log *.txt)</translation>
+ <source>LOG_FILES_FILTER</source>
+ <translation type="unfinished">Log files (*.log *.txt)</translation>
</message>
<message>
- <source>ERR_FILE_NOT_WRITABLE</source>
- <translation type="unfinished">File is not writable!</translation>
+ <source>ERR_FILE_NOT_WRITABLE</source>
+ <translation type="unfinished">File is not writable!</translation>
</message>
</context>
</TS>
SET(_rcc_RESOURCES Qtx.qrc)
# resource files / to be processed by lrelease
-SET(_ts_RESOURCES resources/Qtx_msg_fr.ts)
+SET(_ts_RESOURCES resources/Qtx_msg_fr.ts
+ resources/Qtx_msg_ja.ts
+)
# --- sources ---
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="ja" sourcelanguage="en">
+ <context>
+ <name>QtxTreeView</name>
+ <message>
+ <source>Enable sorting</source>
+ <translation>並べ替えの有効化</translation>
+ </message>
+ </context>
+ <context>
+ <name>QtxWorkspaceAction</name>
+ <message>
+ <source>Arranges the windows as overlapping tiles</source>
+ <translation>ウィンドウを重ねて表示</translation>
+ </message>
+ <message>
+ <source>Cascade</source>
+ <translation>重ねて表示</translation>
+ </message>
+ <message>
+ <source>Arranges the windows as nonoverlapping tiles</source>
+ <translation>ウィンドウのタイル表示</translation>
+ </message>
+ <message>
+ <source>Tile</source>
+ <translation>タイル</translation>
+ </message>
+ <message>
+ <source>Arranges the windows as nonoverlapping horizontal tiles</source>
+ <translation>ウィンドウを重ならない水平表示</translation>
+ </message>
+ <message>
+ <source>Tile horizontally</source>
+ <translation>上下に並べて表示</translation>
+ </message>
+ <message>
+ <source>Arranges the windows as nonoverlapping vertical tiles</source>
+ <translation>ウィンドウを重ならない垂直表示</translation>
+ </message>
+ <message>
+ <source>Tile vertically</source>
+ <translation>水平に並べて表示</translation>
+ </message>
+ </context>
+ <context>
+ <name>QtxMainWindow</name>
+ <message>
+ <source>Menu bar</source>
+ <translation>メニュー バー</translation>
+ </message>
+ <message>
+ <source>Status bar</source>
+ <translation>ステータスバー</translation>
+ </message>
+ </context>
+ <context>
+ <name>QtxPathDialog</name>
+ <message>
+ <source>Open file</source>
+ <translation>ファイルを開く</translation>
+ </message>
+ <message>
+ <source>Save file</source>
+ <translation>ファイルの保存</translation>
+ </message>
+ <message>
+ <source>File name</source>
+ <translation>ファイル名</translation>
+ </message>
+ <message>
+ <source>File name not specified</source>
+ <translation>ファイル名が指定されていません</translation>
+ </message>
+ <message>
+ <source>File \"%1\" does not exist</source>
+ <translation>ファイル \"%1\" がありません</translation>
+ </message>
+ <message>
+ <source>File \"%1\" already exist. Do you want to overwrite it?</source>
+ <translation>ファイル \"%1\" が既にあります。 上書きしますか。</translation>
+ </message>
+ <message>
+ <source>Directory \"%1\" does not exist</source>
+ <translation>ディレクトリ \"%1\" がありません</translation>
+ </message>
+ <message>
+ <source>Directory \"%1\" can't be created because file with the same name exist</source>
+ <translation>同名のファイルがあるので、ディレクトリ \"%1\" を作成できません。</translation>
+ </message>
+ <message>
+ <source>Directory \"%1\" not empty. Do you want to remove all files in this directory?</source>
+ <translation>ディレクトリ \"%1\" が空でないです。 すべてのファイルを削除しますか。</translation>
+ </message>
+ <message>
+ <source>File dialog</source>
+ <translation>ファイル ダイアログ</translation>
+ </message>
+ <message>
+ <source>All files (*.*)</source>
+ <translation>すべてのファイル (*.*)</translation>
+ </message>
+ </context>
+ <context>
+ <name>QtxFontEdit</name>
+ <message>
+ <source>B</source>
+ <translatorcomment>Bold</translatorcomment>
+ <translation>B</translation>
+ </message>
+ <message>
+ <source>I</source>
+ <translatorcomment>Italic</translatorcomment>
+ <translation>I</translation>
+ </message>
+ <message>
+ <source>U</source>
+ <translatorcomment>Underline</translatorcomment>
+ <translation>U</translation>
+ </message>
+ <message>
+ <source>S</source>
+ <translatorcomment>Strikethrough</translatorcomment>
+ <translation>S</translation>
+ </message>
+ </context>
+ <context>
+ <name>QtxPathListEdit</name>
+ <message>
+ <source>Warning</source>
+ <translation>警告</translation>
+ </message>
+ <message>
+ <source>Path \"%1\" doesn't exist. Add it to list anyway?</source>
+ <translation>パス \"%1\" がありません。 リストに追加しますか。</translation>
+ </message>
+ <message>
+ <source>Error</source>
+ <translation>エラー</translation>
+ </message>
+ <message>
+ <source>Location \"%1\" doesn't point to file</source>
+ <translation>場所 \"%1\" はファイルを指していません</translation>
+ </message>
+ <message>
+ <source>Location \"%1\" doesn't point to directory</source>
+ <translation>場所 \"%1\" はディレクトリを指していません</translation>
+ </message>
+ <message>
+ <source>Path \"%1\" already exist in the list</source>
+ <translation>パス \"%1\" は既にリストにあります</translation>
+ </message>
+ </context>
+ <context>
+ <name>QtxMRUAction</name>
+ <message>
+ <source>Most Recently Used</source>
+ <translation>最近使用した</translation>
+ </message>
+ <message>
+ <source>Clear</source>
+ <translation>消去</translation>
+ </message>
+ <message>
+ <source><Empty></source>
+ <translation><空></translation>
+ </message>
+ </context>
+ <context>
+ <name>QtxDialog</name>
+ <message>
+ <source>&OK</source>
+ <translation>&OK</translation>
+ </message>
+ <message>
+ <source>&Cancel</source>
+ <translation>キャンセル(&C)</translation>
+ </message>
+ <message>
+ <source>C&lose</source>
+ <translation>閉じる(&l)</translation>
+ </message>
+ <message>
+ <source>&Help</source>
+ <translation>ヘルプ(&H)</translation>
+ </message>
+ <message>
+ <source>&Apply</source>
+ <translation>適用(&A)</translation>
+ </message>
+ <message>
+ <source>&Yes</source>
+ <translation>&Yes</translation>
+ </message>
+ <message>
+ <source>&No</source>
+ <translation>&No</translation>
+ </message>
+ </context>
+ <context>
+ <name>QtxSearchTool</name>
+ <message>
+ <source>Case sensitive</source>
+ <translation>大文字小文字を区別</translation>
+ </message>
+ <message>
+ <source>Regular expression</source>
+ <translation>正規表現</translation>
+ </message>
+ <message>
+ <source>Wrap search</source>
+ <translation>検索を続けます</translation>
+ </message>
+ </context>
+ <context>
+ <name>QtxSplash</name>
+ <message>
+ <source>Error</source>
+ <translation>エラー</translation>
+ </message>
+ <message>
+ <source>&OK</source>
+ <translation>&OK</translation>
+ </message>
+ </context>
+ <context>
+ <name>QtxWorkstack</name>
+ <message>
+ <source>Split vertically</source>
+ <translation>垂直方向分割</translation>
+ </message>
+ <message>
+ <source>Split horizontally</source>
+ <translation>水平方向分割</translation>
+ </message>
+ <message>
+ <source>Close</source>
+ <translation>閉じる</translation>
+ </message>
+ <message>
+ <source>Rename</source>
+ <translation>名前変更</translation>
+ </message>
+ <message>
+ <source>Enter new name:</source>
+ <translation>新規名前の入力:</translation>
+ </message>
+ </context>
+ <context>
+ <name>QtxWorkstackAction</name>
+ <message>
+ <source>Split the active window on two vertical parts</source>
+ <translation>アクティブウィンドウの垂直2分割</translation>
+ </message>
+ <message>
+ <source>Split vertically</source>
+ <translation>垂直方向分割</translation>
+ </message>
+ <message>
+ <source>Split the active window on two horizontal parts</source>
+ <translation>アクティブウィンドウの水平2分割</translation>
+ </message>
+ <message>
+ <source>Split horizontally</source>
+ <translation>水平方向分割</translation>
+ </message>
+ <message>
+ <source>Arrange Views</source>
+ <translation>ビューの配置</translation>
+ </message>
+ </context>
+ <context>
+ <name>QtxColorButton</name>
+ <message>
+ <source>Auto</source>
+ <translation>自動</translation>
+ </message>
+ <message>
+ <source>Other colors...</source>
+ <translation>他の色...</translation>
+ </message>
+ </context>
+ <context>
+ <name>QtxColorScale</name>
+ <message>
+ <source>Color scale</source>
+ <translation>カラースケール</translation>
+ </message>
+ </context>
+ <context>
+ <name>QtxBackgroundTool</name>
+ <message>
+ <source>Browse...</source>
+ <translation>ブラウズ...</translation>
+ </message>
+ <message>
+ <source>Not implemented yet</source>
+ <translation>まだ実装されていません</translation>
+ </message>
+ <message>
+ <source>Center</source>
+ <translation>センター</translation>
+ </message>
+ <message>
+ <source>Tile</source>
+ <translation>タイル</translation>
+ </message>
+ <message>
+ <source>Stretch</source>
+ <translation>ストレッチ</translation>
+ </message>
+ <message>
+ <source>Images Files (*.bmp *.png *.jpg *.jpeg *.gif *.tiff)</source>
+ <translation>イメージ ファイル (*.bmp *.png *.jpg *.jpeg *.gif * .tiff)</translation>
+ </message>
+ <message>
+ <source>Image</source>
+ <translation>イメージ</translation>
+ </message>
+ <message>
+ <source>Single Color</source>
+ <translation>一色</translation>
+ </message>
+ <message>
+ <source>Custom</source>
+ <translation>カスタム</translation>
+ </message>
+ <message>
+ <source>Select Picture</source>
+ <translation>画像選択</translation>
+ </message>
+ </context>
+ <context>
+ <name>QtxBackgroundDialog</name>
+ <message>
+ <source>Change background</source>
+ <translation>背景の変更</translation>
+ </message>
+ </context>
+ <context>
+ <name>QtxSplitDlg</name>
+ <message>
+ <source>Arrange views</source>
+ <translation>ビューの配置</translation>
+ </message>
+ <message>
+ <source>Create sub-views</source>
+ <translation>サブビューの作成</translation>
+ </message>
+ <message>
+ <source>Views Layout</source>
+ <translation>ビューレイアウト</translation>
+ </message>
+ <message>
+ <source>Sub-views Layout</source>
+ <translation>サブ ビュー レイアウト</translation>
+ </message>
+ <message>
+ <source>Views List</source>
+ <translation>ビューのリスト</translation>
+ </message>
+ <message>
+ <source>Close remaining views</source>
+ <translation>残りのビューを閉じる</translation>
+ </message>
+ <message>
+ <source>Stack remaining views in the last area</source>
+ <translation>最後の領域の残りのビューをスタック</translation>
+ </message>
+ <message>
+ <source>Sub-views Properties</source>
+ <translation>サブ ビュー プロパティ</translation>
+ </message>
+ <message>
+ <source>Sub-view</source>
+ <translation>サブビュー</translation>
+ </message>
+ <message>
+ <source>&Apply</source>
+ <translation>適用(&A)</translation>
+ </message>
+ <message>
+ <source>&Close</source>
+ <translation>閉じる(&C)</translation>
+ </message>
+ </context>
+ <context>
+ <name>QtxWebBrowser</name>
+ <message>
+ <source>Open URL</source>
+ <translation>URL を開く</translation>
+ </message>
+ <message>
+ <source>Open in</source>
+ <translation type="unfinished">Open in</translation>
+ </message>
+ <message>
+ <source>Save file</source>
+ <translation>ファイルの保存</translation>
+ </message>
+ <message>
+ <source>&Browse...</source>
+ <translation>ブラウズ...(&B)</translation>
+ </message>
+ <message>
+ <source>Use this program for all files of this type</source>
+ <translation type="unfinished">Use this program for all files of this type</translation>
+ </message>
+ <message>
+ <source>&OK</source>
+ <translation>OK(&O)</translation>
+ </message>
+ <message>
+ <source>&Cancel</source>
+ <translation>キャンセル(&C)</translation>
+ </message>
+ <message>
+ <source>You are opening the file</source>
+ <translation type="unfinished">You are opening the file</translation>
+ </message>
+ <message>
+ <source>Please choose the action to be done</source>
+ <translation type="unfinished">Please choose the action to be done</translation>
+ </message>
+ <message>
+ <source>Choose program</source>
+ <translation type="unfinished">Choose program</translation>
+ </message>
+ <message>
+ <source>Go Back</source>
+ <translation>戻る</translation>
+ </message>
+ <message>
+ <source>Go Forward</source>
+ <translation>進む</translation>
+ </message>
+ <message>
+ <source>Navigation</source>
+ <translation type="unfinished">Navigation</translation>
+ </message>
+ <message>
+ <source>&File</source>
+ <translation>ファイル (&F)</translation>
+ </message>
+ <message>
+ <source>&Open...</source>
+ <translation>開く(&O)...</translation>
+ </message>
+ <message>
+ <source>&Find in text...</source>
+ <translation type="unfinished">&Find in text...</translation>
+ </message>
+ <message>
+ <source>&Find next</source>
+ <translation type="unfinished">&Find next</translation>
+ </message>
+ <message>
+ <source>&Find previous</source>
+ <translation type="unfinished">&Find previous</translation>
+ </message>
+ <message>
+ <source>&Close</source>
+ <translation>閉じる(&C)</translation>
+ </message>
+ <message>
+ <source>&Help</source>
+ <translation>ヘルプ(&H)</translation>
+ </message>
+ <message>
+ <source>&About...</source>
+ <translation type="unfinished">&About...</translation>
+ </message>
+ <message>
+ <source>About %1</source>
+ <translation type="unfinished">About %1</translation>
+ </message>
+ <message>
+ <source>Help Browser</source>
+ <translation type="unfinished">Help Browser</translation>
+ </message>
+ <message>
+ <source>Error</source>
+ <translation>エラー</translation>
+ </message>
+ <message>
+ <source>Can't save file:\n%1</source>
+ <translation>Can't save file:\n%1</translation>
+ </message>
+ <message>
+ <source>Open file</source>
+ <translation>ファイルを開く</translation>
+ </message>
+ <message>
+ <source>%1 has been developed using %2</source>
+ <translation type="unfinished">%1 has been developed using %2</translation>
+ </message>
+ </context>
+</TS>
myHelper->preferencesChanged( section, parameter );
}
+/*!
+ \brief Called when study is closed
+ \param study study being closed
+ \sa PyModuleHelper::studyClosed()
+*/
+void SALOME_PYQT_Module::studyClosed( SUIT_Study* study )
+{
+ // call helper
+ myHelper->modelClosed( study );
+ SalomeApp_Module::studyClosed( study );
+}
+
/*!
\brief Test if object \a what can be dragged by the user.
\param what data object being tested
void contextMenuPopup( const QString&, QMenu*, QString& );
void createPreferences();
void preferencesChanged( const QString&, const QString& );
+ void studyClosed( SUIT_Study* );
// drag-n-drop support
bool isDraggable( const SUIT_DataObject* ) const;
};
int SalomePyQt::createView( const QString& type, QWidget* w )
{
- return ProcessEvent( new TCreateViewWg( type, w ) );
+ int ret = ProcessEvent( new TCreateViewWg( type, w ) );
+ QCoreApplication::processEvents();
+ return ret;
}
/*!
bool STD_Application::closeActiveDoc( bool permanently )
{
SUIT_Study* study = activeStudy();
+ if ( !study ) // no active study
+ return true;
beforeCloseDoc( study );
SET(_internal_HEADERS
SVTK_SelectorDef.h
SVTK_Trihedron.h
- vtkPVAxesActor.h
- vtkPVAxesWidget.h
+ salomevtkPVAxesActor.h
+ salomevtkPVAxesWidget.h
)
# header files / to install
SVTK_ViewModel.cxx
SVTK_ViewParameterDlg.cxx
SVTK_ViewWindow.cxx
- vtkPVAxesActor.cxx
- vtkPVAxesWidget.cxx
+ salomevtkPVAxesActor.cxx
+ salomevtkPVAxesWidget.cxx
)
# sources / to compile
#include "SVTK_Recorder.h"
#include "SVTK_RecorderDlg.h"
-#include "vtkPVAxesWidget.h"
-#include "vtkPVAxesActor.h"
+#include "salomevtkPVAxesWidget.h"
+#include "salomevtkPVAxesActor.h"
#include "SALOME_ListIO.hxx"
setCentralWidget(myInteractor);
- myAxesWidget = vtkPVAxesWidget::New();
+ myAxesWidget = salomevtk::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();
+ salomevtk::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 );
class SVTK_ViewParameterDlg;
class SVTK_Recorder;
-class vtkPVAxesWidget;
+namespace salomevtk
+{
+ class vtkPVAxesWidget;
+}
class vtkObject;
class QtxAction;
int myToolBar;
int myRecordingToolBar;
- vtkPVAxesWidget* myAxesWidget;
+ salomevtk::vtkPVAxesWidget* myAxesWidget;
Qtx::BackgroundData myBackground;
private:
</message>
<message>
<source>DSC_SVTK_SCALING</source>
- <translation>座標のスケールの軸を変更します。</translation>
+ <translation>スケーリング</translation>
</message>
<message>
<source>MNU_SVTK_SCALING</source>
--- /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.
+
+=========================================================================*/
+//
+// VSR 03/12/2014: the original file vtkPVAxesActor.cxx has been renamed to salomevtkPVAxesActor.cxx
+// to avoid collisions with native VTK/ParaView classes
+
+#include "salomevtkPVAxesActor.h" // changed by SALOME
+#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>
+
+// VSR 03/12/2014: we put classes copied from VTK/ParaView to the specific namespace
+// to avoid collisions with native VTK/ParaView classes
+namespace salomevtk
+{
+
+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->SetInputConnection( this->XAxisVectorText->GetOutputPort() );
+ ymapper->SetInputConnection( this->YAxisVectorText->GetOutputPort() );
+ zmapper->SetInputConnection( this->ZAxisVectorText->GetOutputPort() );
+
+ 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_MAJOR_VERSION>5 || 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()))->
+ SetInputConnection( this->CylinderSource->GetOutputPort() );
+ break;
+ case vtkPVAxesActor::LINE_SHAFT:
+ (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
+ SetInputConnection( this->LineSource->GetOutputPort() );
+ break;
+ case vtkPVAxesActor::USER_DEFINED_SHAFT:
+ (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
+ SetInputData( this->UserDefinedShaft );
+ }
+
+ switch ( this->TipType )
+ {
+ case vtkPVAxesActor::CONE_TIP:
+ (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
+ SetInputConnection( this->ConeSource->GetOutputPort() );
+ break;
+ case vtkPVAxesActor::SPHERE_TIP:
+ (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
+ SetInputConnection( this->SphereSource->GetOutputPort() );
+ break;
+ case vtkPVAxesActor::USER_DEFINED_TIP:
+ (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
+ SetInputData( this->UserDefinedTip );
+ }
+
+ (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->Update();
+ (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->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);
+}
+
+} // end of salomevtk namespace
--- /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.
+//
+// VSR 03/12/2014: the original file vtkPVAxesActor.h has been renamed to salomevtkPVAxesActor.h
+// to avoid collisions with native VTK/ParaView classes
+
+#ifndef __salomevtkPVAxesActor_h
+#define __salomevtkPVAxesActor_h
+
+#include "SVTK.h" // added by SALOME
+#include "vtkProp3D.h"
+
+#include <vtkVersion.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;
+
+// VSR 03/12/2014: we put classes copied from VTK/ParaView to the specific namespace
+// to avoid collisions with native VTK/ParaView classes
+namespace salomevtk
+{
+
+class SVTK_EXPORT vtkPVAxesActor : public vtkProp3D
+{
+public:
+ static vtkPVAxesActor *New();
+ vtkTypeMacro(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_MAJOR_VERSION>5 || 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.
+};
+
+} // end of salomevtk namespace
+
+#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.
+
+=========================================================================*/
+// VSR 03/12/2014: the original file vtkPVAxesWidget.cxx has been renamed to salomevtkPVAxesWidget.cxx
+// to avoid collisions with native VTK/ParaView classes
+
+#include "salomevtkPVAxesWidget.h" // changed by SALOME
+#include "salomevtkPVAxesActor.h" // changed by SALOME
+
+#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 "vtkRenderer.h"
+#include "vtkRenderWindow.h"
+#include "vtkRenderWindowInteractor.h"
+
+// VSR 03/12/2014: we put classes copied from VTK/ParaView to the specific namespace
+// to avoid collisions with native VTK/ParaView classes
+namespace salomevtk
+{
+
+vtkStandardNewMacro(vtkPVAxesWidget);
+
+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->SetInputData(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;
+}
+
+} // end of salomevtk namespace
--- /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.
+// VSR 03/12/2014: the original file vtkPVAxesWidget.h has been renamed to salomevtkPVAxesWidget.h
+// to avoid collisions with native VTK/ParaView classes
+
+
+#ifndef __salomevtkPVAxesWidget_h
+#define __salomevtkPVAxesWidget_h
+
+#include "SVTK.h" // added by SALOME
+#include "vtkInteractorObserver.h"
+
+class vtkActor2D;
+class vtkKWApplication;
+class vtkPolyData;
+class vtkRenderer;
+
+// VSR 03/12/2014: we put classes copied from VTK/ParaView to the specific namespace
+// to avoid collisions with native VTK/ParaView classes
+namespace salomevtk
+{
+
+class vtkPVAxesWidgetObserver;
+class vtkPVAxesActor;
+
+class SVTK_EXPORT vtkPVAxesWidget : public vtkInteractorObserver
+{
+public:
+ static vtkPVAxesWidget* New();
+ vtkTypeMacro(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
+};
+
+} // end of salomevtk namespace
+
+#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 "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>
-
-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->SetInputConnection( this->XAxisVectorText->GetOutputPort() );
- ymapper->SetInputConnection( this->YAxisVectorText->GetOutputPort() );
- zmapper->SetInputConnection( this->ZAxisVectorText->GetOutputPort() );
-
- 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_MAJOR_VERSION>5 || 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()))->
- SetInputConnection( this->CylinderSource->GetOutputPort() );
- break;
- case vtkPVAxesActor::LINE_SHAFT:
- (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
- SetInputConnection( this->LineSource->GetOutputPort() );
- break;
- case vtkPVAxesActor::USER_DEFINED_SHAFT:
- (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->
- SetInputData( this->UserDefinedShaft );
- }
-
- switch ( this->TipType )
- {
- case vtkPVAxesActor::CONE_TIP:
- (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
- SetInputConnection( this->ConeSource->GetOutputPort() );
- break;
- case vtkPVAxesActor::SPHERE_TIP:
- (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
- SetInputConnection( this->SphereSource->GetOutputPort() );
- break;
- case vtkPVAxesActor::USER_DEFINED_TIP:
- (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->
- SetInputData( this->UserDefinedTip );
- }
-
- (vtkPolyDataMapper::SafeDownCast(this->XAxisTip->GetMapper()))->Update();
- (vtkPolyDataMapper::SafeDownCast(this->XAxisShaft->GetMapper()))->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"
-
-#include <vtkVersion.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();
- vtkTypeMacro(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_MAJOR_VERSION>5 || 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);
-
-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->SetInputData(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();
- vtkTypeMacro(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
if ( result ) {
if ( !killServers ) myIsCloseFromExit = true;
SUIT_Session::session()->closeSession( SUIT_Session::ASK, killServers );
- myIsCloseFromExit = false;
+ if ( SUIT_Session::session()->applications().count() > 0 ) myIsCloseFromExit = false;
}
}
bool canCopy = false;
bool canPaste = false;
+ LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
+
+ if ( m ) {
+ canCopy = m->canCopy();
+ canPaste = m->canPaste();
+ }
+
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
- if (study != NULL) {
+ if (study) {
_PTR(Study) stdDS = study->studyDS();
if (stdDS) {
_PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
if ( so ) {
- canCopy = studyMgr()->CanCopy(so);
- canPaste = studyMgr()->CanPaste(so);
+ canCopy = canCopy || studyMgr()->CanCopy(so);
+ canPaste = canPaste || studyMgr()->CanPaste(so);
}
}
}
#ifndef DISABLE_PYCONSOLE
else if ( flag == WT_PyConsole )
{
- PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(), new SalomeApp_PyInterp() );
+ PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(), getPyInterp() );
pyCons->setObjectName( "pythonConsole" );
pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
}
return result;
}
+
+
+#ifndef DISABLE_PYCONSOLE
+
+PyConsole_Interp* SalomeApp_Application::createPyInterp()
+{
+ return new SalomeApp_PyInterp();
+}
+
+#endif // DISABLE_PYCONSOLE
#ifndef DISABLE_PYCONSOLE
bool updateStudy();
+ virtual PyConsole_Interp* createPyInterp();
#endif
virtual void afterCloseDoc();
#include <QObject>
#include <QVariant>
+//VSR: uncomment below macro to support unicode text properly in SALOME
+// current commented out due to regressions
+//#define PAL22528_UNICODE
+
+namespace
+{
+ QString fromUtf8( const char* txt )
+ {
+#ifdef PAL22528_UNICODE
+ return QString::fromUtf8( txt );
+#else
+ return QString( txt );
+#endif
+ }
+
+ QString fromUtf8( const std::string& txt )
+ {
+ return fromUtf8( txt.c_str() );
+ }
+}
+
/*!
\class SalomeApp_DataObject
\brief Implementation of the data object for use in CORBA-based
{
QString str;
if ( myObject )
- str = QString::fromUtf8( myObject->GetName().c_str() );
+ str = fromUtf8( myObject->GetName() );
if ( str.isEmpty() ) {
_PTR(SObject) refObj = referencedObject();
if ( refObj )
- str = QString::fromUtf8( refObj->GetName().c_str() );
+ str = fromUtf8( refObj->GetName() );
}
if ( isReference() ) {
_PTR(AttributePixMap) aPixAttr ( anAttr );
if ( aPixAttr->HasPixMap() ) {
QString componentType = componentDataType();
- QString pixmapID = QString::fromUtf8(aPixAttr->GetPixMap().c_str());
+ QString pixmapID = fromUtf8( aPixAttr->GetPixMap() );
// select a plugin within a component
QStringList plugin_pixmap = pixmapID.split( "::", QString::KeepEmptyParts );
if ( plugin_pixmap.size() == 2 ) {
{
_PTR(AttributeString) strAttr = attr;
std::string str = strAttr->Value();
- QString aStrings = QString::fromUtf8( str.c_str() );
+ QString aStrings = fromUtf8( str );
//Special case to show NoteBook variables in the "Value" column of the OB
if ( LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>( root() ) )
#ifndef DISABLE_PYCONSOLE
#include <PyConsole_Interp.h> // this include must be first (see PyInterp_base.h)!
- #include <PyConsole_Console.h>
#endif
#include "SalomeApp_DoubleSpinBox.h"
if( studyDS->IsString( aName ) )
{
#ifndef DISABLE_PYCONSOLE
- PyConsole_Console* pyConsole = app->pythonConsole();
- PyConsole_Interp* pyInterp = pyConsole->getInterp();
+ PyConsole_Interp* pyInterp = app->getPyInterp();
PyLockWrapper aLock; // Acquire GIL
std::string command;
command = "import salome_notebook ; ";
#ifndef DISABLE_PYCONSOLE
#include <PyConsole_Interp.h> //this include must be first (see PyInterp_base.h)!
- #include <PyConsole_Console.h>
#endif
#include "SalomeApp_IntSpinBox.h"
if( studyDS->IsString( aName ) )
{
#ifndef DISABLE_PYCONSOLE
- PyConsole_Console* pyConsole = app->pythonConsole();
- PyConsole_Interp* pyInterp = pyConsole->getInterp();
+ PyConsole_Interp* pyInterp = app->getPyInterp();
PyLockWrapper aLock; // Acquire GIL
std::string command;
command = "import salome_notebook ; ";
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
PyConsole_Console* pyConsole = app->pythonConsole();
- PyConsole_Interp* pyInterp = pyConsole->getInterp();
+ PyConsole_Interp* pyInterp = app->getPyInterp();
PyLockWrapper aLock; // Acquire GIL
std::string command = "import salome_notebook ; ";
command += "salome_notebook.checkThisNoteBook(";
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
PyConsole_Console* pyConsole = app->pythonConsole();
- PyConsole_Interp* pyInterp = pyConsole->getInterp();
+ PyConsole_Interp* pyInterp = app->getPyInterp();
PyLockWrapper aLock; // Acquire GIL
std::string command = "import salome_notebook ; ";
command += "salome_notebook.checkThisNoteBook(";
class SalomeApp_PyInterp : public PyConsole_EnhInterp
{
+ friend class SalomeApp_Application;
+
public:
- SalomeApp_PyInterp();
virtual ~SalomeApp_PyInterp();
virtual void initPython();
virtual void closeContext();
protected:
+ SalomeApp_PyInterp();
virtual int beforeRun();
private:
#ifndef DISABLE_PYCONSOLE
#include "SalomeApp_PyInterp.h" // WARNING! This include must be the first!
- #include <PyConsole_Console.h>
#endif
#include "utilities.h"
desk->blockSignals( isBlocked );
#ifndef DISABLE_PYCONSOLE
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
- if( app->pythonConsole() )
- app->pythonConsole()->getInterp()->destroy();
+ app->getPyInterp()->destroy();
#endif
}
SALOMEDSClient_Study* aStudy = 0;
</message>
<message>
<source>ERR_ACTIVEDOC_LOAD</source>
- <translation type="unfinished">A study is already active in your session, but you are not connected to it. Use the Connect button to load it in the interface.</translation>
+ <translation>Une étude est déjà chargée dans votre session mais vous n'y êtes pas connectée. Utilisez le bouton "Connecter" pour charger l'étude dans l'interface.</translation>
</message>
<message>
<source>WRN_STUDY_LOCKED</source>
<translation>L'étude est verrouillée</translation>
</message>
+ <message>
+ <source>WRN_NO_STUDY_ON SERV</source>
+ <translation>Pas d'étude active dans cette session.</translation>
+ </message>
<message>
<source>CLOSE_LOCKED_STUDY</source>
<translation>Fermer l'étude verrouillée ?</translation>
<translation>Impossible d'ouvrir l'étude car il y en a déjà une d'active.
Lancez une nouvelle session ou fermez l'étude en cours.</translation>
</message>
+ <message>
+ <source>OPEN_DOCUMENT_PROBLEM</source>
+ <translation>Problème inconnu à l'ouverture du document</translation>
+ </message>
+ <message>
+ <source>CREATE_DOCUMENT_PROBLEM</source>
+ <translation>Problème inconnu à la création du document</translation>
+ </message>
<message>
<source>TOT_DESK_CONNECT_STUDY</source>
- <translation type="unfinished">Connect study</translation>
+ <translation>Connecter l'étude</translation>
</message>
<message>
<source>TOT_DESK_DISCONNECT_STUDY</source>
- <translation type="unfinished">Disconnect study</translation>
+ <translation>Déconnecter l'étude</translation>
</message>
<message>
<source>PRP_DESK_CONNECT</source>
- <translation type="unfinished">Connect active study</translation>
+ <translation>Connecter l'étude en cours</translation>
</message>
<message>
<source>PRP_DESK_DISCONNECT</source>
- <translation type="unfinished">Disconnect the current study</translation>
+ <translation>Déconnecter l'étude en cours</translation>
</message>
<message>
<source>MEN_DESK_CONNECT</source>
- <translation type="unfinished">Conn&ect</translation>
+ <translation>Conn&ecter</translation>
</message>
<message>
<source>MEN_DESK_DISCONNECT</source>
- <translation type="unfinished">D&isconnect</translation>
+ <translation>D&éconnecter</translation>
</message>
</context>
<context>
</message>
<message>
<source>ACTIVATE_MODULE_OP_LOAD</source>
- <translation type="unfinished">&Connect</translation>
+ <translation>&Connecter</translation>
</message>
<message>
<source>ACTIVATE_MODULE_OP_SCRIPT</source>
</message>
<message>
<source>DISCONNECT_CAPTION</source>
- <translation type="unfinished">Disconnect active study</translation>
+ <translation>Déconnecter l'étude en cours</translation>
</message>
<message>
<source>DISCONNECT_DESCRIPTION</source>
- <translation type="unfinished">Do you want to save study before disconnect?</translation>
+ <translation>Voulez-vous sauver l'étude avant la déconnexion ?</translation>
</message>
<message>
<source>DISCONNECT_SAVE</source>
- <translation type="unfinished">&Save && Disconnect</translation>
+ <translation>&Sauver && Déconnecter</translation>
</message>
<message>
<source>DISCONNECT_WO_SAVE</source>
- <translation type="unfinished">&Disconnect w/o saving</translation>
+ <translation>&Déconnecter sans sauver</translation>
</message>
</context>
<context>
<translation>すべてのファイル (*. *)</translation>
</message>
<message>
- <source>APPCLOSE_UNLOAD</source>
- <translation type="unfinished">&Disconnect w/o saving</translation>
+ <source>APPCLOSE_UNLOAD</source>
+ <translation>アンロード(&U)</translation>
</message>
<message>
- <source>APPCLOSE_UNLOAD_SAVE</source>
- <translation type="unfinished">S&ave && Disconnect</translation>
+ <source>APPCLOSE_UNLOAD_SAVE</source>
+ <translation type="unfinished">S&ave && Disconnect</translation>
</message>
<message>
<source>MEN_WINDOWS_NEW</source>
</message>
<message>
<source>ACTIVATE_MODULE_OP_LOAD</source>
- <translation type="unfinished">&Connect</translation>
+ <translation>読込み(&L)</translation>
</message>
<message>
<source>ACTIVATE_MODULE_OP_SCRIPT</source>
#define TEXT_MARGIN 4
#define OFFSET_SPACING 2
+//VSR: uncomment below macro to support unicode text properly in SALOME
+// current commented out due to regressions
+//#define PAL22528_UNICODE
+
+namespace
+{
+ QString fromUtf8( const char* txt )
+ {
+#ifdef PAL22528_UNICODE
+ return QString::fromUtf8( txt );
+#else
+ return QString( txt );
+#endif
+ }
+ const char* toUtf8( const QString& txt )
+ {
+#ifdef PAL22528_UNICODE
+ return txt.toUtf8().constData();
+#else
+ return txt.toLatin1().constData();
+#endif
+ }
+}
+
//==================================================================
vtkStandardNewMacro(VTKViewer_FramedTextActor);
{
// remove whitespaces from from the start and the end
// additionally, consider a case of multi-string text
- QString aString(QString::fromUtf8(theText));
+ QString aString(fromUtf8(theText));
QStringList aTrimmedStringList;
QStringList aStringList = aString.split("\n");
while(anIter.hasNext())
aTrimmedStringList.append(anIter.next().trimmed());
- myTextActor->SetInput(aTrimmedStringList.join("\n").toUtf8().constData());
+ myTextActor->SetInput(toUtf8(aTrimmedStringList.join("\n")));
Modified();
}
static double MIN_DISTANCE = 1./VTK_LARGE_FLOAT;
static double MAX_DISTANCE = 0.9*VTK_LARGE_FLOAT;
- if(abs(aBounds[1] - aBounds[0]) < MIN_DISTANCE) {
+ if(fabs(aBounds[1] - aBounds[0]) < MIN_DISTANCE) {
aBounds[0]-=0.001;
aBounds[1]+=0.001;
}
- if(abs(aBounds[3] - aBounds[2]) < MIN_DISTANCE) {
+ if(fabs(aBounds[3] - aBounds[2]) < MIN_DISTANCE) {
aBounds[2]-=0.001;
aBounds[3]+=0.001;
}
- if(abs(aBounds[5] - aBounds[4]) < MIN_DISTANCE) {
+ if(fabs(aBounds[5] - aBounds[4]) < MIN_DISTANCE) {
aBounds[4]-=0.001;
aBounds[5]+=0.001;
}