Skip to content

Commit 58417b9

Browse files
author
Charles PIGNEROL
committed
Version 8.7.0. QtVtkViewPointToolBar and QtVtkViewPointToolButton classes: manage VTK viewpoints via a Qt button bar.
1 parent 500c43f commit 58417b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+4375
-49
lines changed

cmake/version.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
set (QT_VTK_MAJOR_VERSION "8")
6-
set (QT_VTK_MINOR_VERSION "6")
6+
set (QT_VTK_MINOR_VERSION "7")
77
set (QT_VTK_RELEASE_VERSION "0")
88
set (QT_VTK_VERSION ${QT_VTK_MAJOR_VERSION}.${QT_VTK_MINOR_VERSION}.${QT_VTK_RELEASE_VERSION})
99

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
add_subdirectory (QtVtk)
2+
add_subdirectory (viewpoint)
23

34

src/QtVtk/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,21 @@ include (${GUIToolkitsVariables_CMAKE_DIR}/workarounds.cmake)
1010

1111
find_package (VtkContrib 5 REQUIRED)
1212
include (${CMAKE_SOURCE_DIR}/cmake/qtvtk_common.cmake) # Après VtkContrib qui positionne les variables VTK_7, VTK_8 et VTK_9
13-
find_package (QtUtil 6 REQUIRED)
13+
find_package (PrefsQt 6 REQUIRED)
1414
find_package(Qt${QT_MAJOR}Core NO_CMAKE_SYSTEM_PATH) # In order to enable moc ...
1515
if (VTK_9)
1616
find_package (VTK COMPONENTS GUISupportQt IOExportGL2PS FiltersExtraction)
1717
endif (VTK_9)
1818

1919
file (GLOB HEADERS public/${CURRENT_PACKAGE_NAME}/*.h)
20-
file (GLOB CPP_SOURCES *.cpp)
20+
file (GLOB CPP_SOURCES *.cpp *.qrc)
2121

2222
# On ajoute les en-têtes aux sources. C'est utile pour cmake dans certains cas,
2323
# par exemple lorsqu'ils doivent être pré-processés (moc, ...).
2424
add_library (QtVtk ${CPP_SOURCES} ${HEADERS})
2525
set (ALL_TARGETS QtVtk)
2626
set_property (TARGET QtVtk PROPERTY AUTOMOC ON)
27+
set_property (TARGET QtVtk PROPERTY AUTORCC ON)
2728
set_property (TARGET QtVtk PROPERTY VERSION ${QT_VTK_VERSION})
2829
set_property (TARGET QtVtk PROPERTY SOVERSION ${QT_VTK_MAJOR_VERSION})
2930
# Rem : en Qt v 4.* on utilise -DUSE_QT_WEBKIT
@@ -51,7 +52,7 @@ endif(VTK_9)
5152
target_compile_definitions (QtVtk PUBLIC ${QT_VTK_PUBLIC_FLAGS})
5253
target_compile_definitions (QtVtk PRIVATE ${QT_VTK_PRIVATE_FLAGS} ${QT_VTK_PRIVATE_HELP_FLAGS})
5354
target_compile_options (QtVtk PRIVATE ${SHARED_CFLAGS}) # Requested by Qt ...
54-
target_link_libraries (QtVtk PUBLIC QtUtil::QtUtil VtkContrib::VtkContrib)
55+
target_link_libraries (QtVtk PUBLIC PrefsQt::PrefsQt VtkContrib::VtkContrib)
5556

5657
# Etre capable une fois installée de retrouver vtk*, ... :
5758
# (Rem : en son absence on a Set runtime path of "/tmp/pignerol/install/lib/libQtVtk.so.5.0.0" to "") ...

src/QtVtk/QtVTKPrintHelper.cpp

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <TkUtil/MachineData.h>
1313
#include <TkUtil/PrintCommand.h>
1414
#include <QtUtil/QtAutoWaitingCursor.h>
15+
#include <QtUtil/QtFileDialogUtilities.h>
1516
#include <QtUtil/QtUnicodeHelper.h>
1617

1718
#include <vtkWindowToImageFilter.h>
@@ -142,47 +143,6 @@ QtVTKPrintHelper::PrinterStatus QtVTKPrintHelper::print (vtkRenderWindow& window
142143
} // QtVTKPrintHelper::print
143144

144145

145-
/**
146-
* @return La première extension du filtre Qt reçu en argument (format <I>NOM (*.ext1 *.ext2 ... *.extn)</I>.
147-
*/
148-
static string getFirstExtension (const string& filter) // v 7.4.0
149-
{
150-
UTF8String prepared (filter);
151-
prepared.replace (string ("("), string (" "), true); // => nom *.ext1)
152-
prepared.replace (string ("*"), string (""), true); // => nom .ext1)
153-
prepared.replace (string (")"), string (""), true); // => nom *.ext1
154-
istringstream stream (prepared.utf8 ( ));
155-
string name, ext;
156-
stream >> name >> ext;
157-
158-
159-
if ((false == stream.fail ( )) && (false == stream.bad ( )))
160-
return ext;
161-
162-
return string ( );
163-
} // getFirstExtension
164-
165-
166-
/**
167-
* @param Nom de fichier proposé
168-
* @param Filtre Qt utilisé lors du choix du fichier
169-
* @return Le nom de fichier avec extension. Si le nom proposé n'en n'a pas alors la première du filtre est ajoutée.
170-
*/
171-
static string completeFileName (const string& path, const string& filter) // v 7.4.0
172-
{
173-
File file (path);
174-
if (0 != file.getExtension ( ).length ( ))
175-
return path;
176-
177-
// Le fichier n'a pas d'extension, on rajoute la première du filtre
178-
const string ext = getFirstExtension (filter);
179-
UTF8String newPath (charset);
180-
newPath << path << ext;
181-
182-
return newPath.utf8 ( );
183-
} // completeFileName
184-
185-
186146
QtVTKPrintHelper::PrinterStatus QtVTKPrintHelper::printToFile (vtkRenderWindow& window, QWidget* top)
187147
{
188148
QPrinter printer;
@@ -219,8 +179,7 @@ QtVTKPrintHelper::PrinterStatus QtVTKPrintHelper::printToFile (vtkRenderWindow&
219179
if (1 != fileList.size ( ))
220180
throw Exception ("Erreur, la liste de fichiers d'impression ne contient pas qu'un fichier.");
221181

222-
// string fileName (fileList [0].toStdString ( ));
223-
string fileName (completeFileName (fileList [0].toStdString ( ), dialog.selectedNameFilter ( ).toStdString ( ))); // v 7.4.0
182+
string fileName (QtFileDialogUtilities::completeFileName (fileList [0].toStdString ( ), dialog.selectedNameFilter ( ).toStdString ( ))); // v 7.4.0
224183
File file (fileName);
225184

226185
if (false == file.isWritable ( ))
@@ -277,7 +236,7 @@ QtVTKPrintHelper::PrinterStatus QtVTKPrintHelper::printTo4kFile (vtkRenderWindow
277236
if (1 != fileList.size ( ))
278237
throw Exception ("Erreur, la liste de fichiers d'impression ne contient pas qu'un fichier.");
279238

280-
const string fileName (completeFileName (fileList [0].toStdString ( ), dialog.selectedNameFilter ( ).toStdString ( )));
239+
const string fileName (QtFileDialogUtilities::completeFileName (fileList [0].toStdString ( ), dialog.selectedNameFilter ( ).toStdString ( )));
281240
File file (fileName);
282241
if (false == file.isWritable ( ))
283242
{

src/QtVtk/QtVtk.qrc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE RCC><RCC version="1.0">
2+
<qresource>
3+
<file>images/add_viewpoint.png</file>
4+
<file>images/remove_viewpoint.png</file>
5+
<file>images/remove_viewpoints.png</file>
6+
<file>images/export_viewpoints.png</file>
7+
<file>images/import_viewpoints.png</file>
8+
<file>images/viewpoint_01.png</file>
9+
<file>images/viewpoint_02.png</file>
10+
<file>images/viewpoint_03.png</file>
11+
<file>images/viewpoint_04.png</file>
12+
<file>images/viewpoint_05.png</file>
13+
<file>images/viewpoint_06.png</file>
14+
<file>images/viewpoint_07.png</file>
15+
<file>images/viewpoint_08.png</file>
16+
<file>images/viewpoint_09.png</file>
17+
<file>images/viewpoint_10.png</file>
18+
<file>images/viewpoint_11.png</file>
19+
<file>images/viewpoint_12.png</file>
20+
<file>images/viewpoint_13.png</file>
21+
<file>images/viewpoint_14.png</file>
22+
<file>images/viewpoint_15.png</file>
23+
<file>images/viewpoint_16.png</file>
24+
<file>images/viewpoint_17.png</file>
25+
<file>images/viewpoint_18.png</file>
26+
<file>images/viewpoint_19.png</file>
27+
<file>images/viewpoint_20.png</file>
28+
</qresource>
29+
</RCC>
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
#include "QtVtk/QtVtkViewDefinitionDialog.h"
2+
#include <QtUtil/QtGroupBox.h>
3+
#include <QtUtil/QtConfiguration.h>
4+
#include <QtUtil/QtUnicodeHelper.h>
5+
6+
#include <TkUtil/Exception.h>
7+
8+
#include <assert.h>
9+
10+
#include <QLayout>
11+
#include <QLabel>
12+
13+
14+
USING_STD
15+
USING_UTIL
16+
17+
static const Charset charset ("àéèùô");
18+
USE_ENCODING_AUTODETECTION
19+
20+
/**
21+
* Aide pour positionner un widget au centre de "son parent".
22+
* Utile depuis le passage à Qt 5 : une boite de dialogue modale ayant un parent est positionnée au centre du parent, ce qui est très bien, mais si on la
23+
* déplace le parent suit le mouvement ... Donc pas moyen de voir ce qu'il y a dessous la boite de dialogue.
24+
* => créer la boite de dialogue sans parent, et utiliser cette macro juste au moment de l'afficher.
25+
*/
26+
#ifndef QTVTK_CENTER_DIALOG
27+
#define LEM_CENTER_DIALOG(dlg,parent) \
28+
if ((0 != dlg) && (0 != parent)) \
29+
{ \
30+
QRect pfg = parent->frameGeometry ( ); \
31+
QSize sz = dlg->size ( ); \
32+
dlg->move (pfg.x ( ) + (pfg.width ( ) - sz.width ( )) / 2, \
33+
pfg.y ( ) + (pfg.height ( ) - sz.height ( )) / 2); \
34+
}
35+
#endif // LEM_CENTER_DIALOG
36+
37+
38+
QtVtkViewDefinitionDialog::QtVtkViewDefinitionDialog (
39+
QWidget* parent, const string& title, bool modal, const UTF8String& name, const UTF8String& comment,
40+
double position [3], double focal [3], double viewUp [3], double roll,
41+
vtkRenderer* renderer, const string& helpURL, const string& helpTag)
42+
: QDialog (0, true == modal ? (Qt::WindowFlags)(QtConfiguration::modalDialogWFlags | Qt::WindowStaysOnTopHint) : (Qt::WindowFlags)(QtConfiguration::amodalDialogWFlags | Qt::WindowStaysOnTopHint)), _viewDefinitionPanel (0), _closurePanel (0)
43+
{
44+
setModal (modal);
45+
setWindowTitle (QSTR (title));
46+
47+
// Creation de l'ihm :
48+
QVBoxLayout* layout = new QVBoxLayout (this);
49+
layout->setMargin (QtConfiguration::margin);
50+
layout->setSizeConstraint (QLayout::SetMinimumSize);
51+
QtGroupBox* frame = new QtGroupBox (QSTR ("Paramètres de la vue"), this, "frame");
52+
QVBoxLayout* frameLayout = new QVBoxLayout (frame);
53+
layout->addWidget (frame);
54+
frame->setLayout (frameLayout);
55+
frame->setMargin (QtConfiguration::margin);
56+
frame->setSpacing (QtConfiguration::spacing);
57+
_viewDefinitionPanel = new QtVtkViewDefinitionPanel (frame, title, name, comment, position, focal, viewUp, roll, renderer);
58+
_viewDefinitionPanel->adjustSize ( );
59+
frameLayout->addWidget (_viewDefinitionPanel);
60+
61+
layout->addWidget (new QLabel (" ", this));
62+
_closurePanel = new QtDlgClosurePanel (this, true, "Appliquer", "Fermer", "Annuler",helpURL, helpTag);
63+
layout->addWidget (_closurePanel);
64+
_closurePanel->setMinimumSize (_closurePanel->sizeHint ( ));
65+
66+
// Par defaut le bouton OK est artificellement clique par QDialog quand l'utilisateur fait return dans un champ de texte => on inhibe ce comportement par defaut :
67+
_closurePanel->getApplyButton ( )->setAutoDefault (false);
68+
_closurePanel->getApplyButton ( )->setDefault (false);
69+
_closurePanel->getCloseButton ( )->setAutoDefault (false);
70+
_closurePanel->getCloseButton ( )->setDefault (false);
71+
_closurePanel->getCancelButton ( )->setAutoDefault (false);
72+
_closurePanel->getCancelButton ( )->setDefault (false);
73+
connect (_closurePanel->getApplyButton ( ), SIGNAL(clicked ( )), this, SLOT(apply ( )));
74+
connect (_closurePanel->getCloseButton ( ), SIGNAL(clicked ( )), this, SLOT(close ( )));
75+
connect (_closurePanel->getCancelButton ( ), SIGNAL(clicked ( )), this, SLOT(reject ( )));
76+
77+
layout->activate ( );
78+
setMinimumSize (layout->sizeHint ( ));
79+
LEM_CENTER_DIALOG (this, parent)
80+
} // QtVtkViewDefinitionDialog::QtVtkViewDefinitionDialog
81+
82+
83+
QtVtkViewDefinitionDialog::QtVtkViewDefinitionDialog (const QtVtkViewDefinitionDialog&)
84+
{
85+
assert (0 && "QtVtkViewDefinitionDialog copy constructor is forbidden.");
86+
} // QtVtkViewDefinitionDialog::QtVtkViewDefinitionDialog (const QtVtkViewDefinitionDialog&)
87+
88+
89+
QtVtkViewDefinitionDialog& QtVtkViewDefinitionDialog::operator = (const QtVtkViewDefinitionDialog&)
90+
{
91+
assert (0 && "QtVtkViewDefinitionDialog assignment operator is forbidden.");
92+
return *this;
93+
} // QtVtkViewDefinitionDialog::operator =
94+
95+
96+
QtVtkViewDefinitionDialog::~QtVtkViewDefinitionDialog ( )
97+
{
98+
} // QtVtkViewDefinitionDialog::~QtVtkViewDefinitionDialog
99+
100+
101+
UTF8String QtVtkViewDefinitionDialog::getName ( ) const
102+
{
103+
assert ((0 != _viewDefinitionPanel) && "QtVtkViewDefinitionDialog::getName : null view definition panel.");
104+
return _viewDefinitionPanel->getName ( );
105+
} // QtVtkViewDefinitionDialog::getName
106+
107+
108+
UTF8String QtVtkViewDefinitionDialog::getComment ( ) const
109+
{
110+
assert ((0 != _viewDefinitionPanel) && "QtVtkViewDefinitionDialog::getComment : null view definition panel.");
111+
return _viewDefinitionPanel->getComment ( );
112+
} // QtVtkViewDefinitionDialog::getComment
113+
114+
115+
void QtVtkViewDefinitionDialog::getPosition (double coords [3]) const
116+
{
117+
assert ((0 != _viewDefinitionPanel) && "QtVtkViewDefinitionDialog::getPosition : null view definition panel.");
118+
_viewDefinitionPanel->getPosition (coords);
119+
} // QtVtkViewDefinitionDialog::getPosition
120+
121+
122+
void QtVtkViewDefinitionDialog::getFocalPoint (double coords [3]) const
123+
{
124+
assert ((0 != _viewDefinitionPanel) && "QtVtkViewDefinitionDialog::getFocalPoint : null view definition panel.");
125+
_viewDefinitionPanel->getFocalPoint (coords);
126+
} // QtVtkViewDefinitionDialog::getFocalPoint
127+
128+
129+
void QtVtkViewDefinitionDialog::getViewUp (double direction [3]) const
130+
{
131+
assert ((0 != _viewDefinitionPanel) && "QtVtkViewDefinitionDialog::getViewUp : null view definition panel.");
132+
_viewDefinitionPanel->getViewUp (direction);
133+
} // QtVtkViewDefinitionDialog::getViewUp
134+
135+
136+
double QtVtkViewDefinitionDialog::getRoll ( ) const
137+
{
138+
assert ((0 != _viewDefinitionPanel) && "QtVtkViewDefinitionDialog::getRoll : null view definition panel.");
139+
return _viewDefinitionPanel->getRoll ( );
140+
} // QtVtkViewDefinitionDialog::getRoll
141+
142+
143+
QPushButton* QtVtkViewDefinitionDialog::getApplyButton ( ) const
144+
{
145+
assert ((0 != _closurePanel) && "QtVtkViewDefinitionDialog::getApplyButton : null closure panel.");
146+
return _closurePanel->getApplyButton ( );
147+
} // QtVtkViewDefinitionDialog::getApplyButton
148+
149+
150+
QPushButton* QtVtkViewDefinitionDialog::getCancelButton ( ) const
151+
{
152+
assert ((0 != _closurePanel) && "QtVtkViewDefinitionDialog::getCancelButton : null closure panel.");
153+
return _closurePanel->getCancelButton ( );
154+
} // QtVtkViewDefinitionDialog::getCancelButton
155+
156+
157+
void QtVtkViewDefinitionDialog::apply ( )
158+
{
159+
assert ((0 != _viewDefinitionPanel) && "QtVtkViewDefinitionDialog::apply : null view definition panel.");
160+
_viewDefinitionPanel->apply ( );
161+
} // QtVtkViewDefinitionDialog::apply
162+
163+
164+
void QtVtkViewDefinitionDialog::close ( )
165+
{
166+
QDialog::accept ( );
167+
emit applied (this);
168+
} // QtVtkViewDefinitionDialog::close
169+
170+
171+
void QtVtkViewDefinitionDialog::reject ( )
172+
{
173+
assert ((0 != _viewDefinitionPanel) && "QtVtkViewDefinitionDialog::reject : null view definition panel.");
174+
_viewDefinitionPanel->reset ( );
175+
QDialog::reject ( );
176+
emit canceled (this);
177+
} // QtVtkViewDefinitionDialog::reject
178+
179+

0 commit comments

Comments
 (0)