|
| 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