Commit 8cf028fd authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

Merge branch 'clean-sliceviewer-sidebar' into develop

parents cc80f639 6a00f2b4
......@@ -39,9 +39,13 @@ SliderSpinBoxWidget::SliderSpinBoxWidget(QWidget *parent) : QWidget(parent) {
//-- create UI
QVBoxLayout *vLayout= new QVBoxLayout(this);
vLayout->setSpacing ( 0 );
vLayout->setMargin ( 0 );
spinBox = new QSpinBox;
spinBox->setFixedWidth(60);
QFont spinBoxFont = spinBox->font();
spinBoxFont.setPointSize(10);
spinBox->setFont(spinBoxFont);
vLayout->addWidget(spinBox);
QHBoxLayout *hLayout = new QHBoxLayout();
......
......@@ -52,6 +52,7 @@
#include <QMetaEnum>
#include <QWidgetAction>
#include <QTextStream>
#include <QSplitter>
// -- vtk stuff
#include <vtkDataSetMapper.h>
......@@ -202,6 +203,7 @@ InteractiveViewer::InteractiveViewer ( QString & name, ViewerType type ) : Viewe
//-- create the slice slider if needed
viewerMenu = NULL;
viewerToolBar = NULL;
screenshotActionMenu = NULL;
displayedTopLevelComponents = 0;
//-- set picking mode
......@@ -299,6 +301,10 @@ void InteractiveViewer::initSettings() {
bool linesAsTubes = settings.value ( "linesAsTubes", false ).toBool(); // default false
propertyObject->setProperty(linesAsTubesProperty->getName().toStdString().c_str(), linesAsTubes);
// screenshot Action visibility
bool screenshotActionVisible = settings.value ("screenshotActionVisible", false).toBool();
propertyObject->setProperty(screenshotActionProperty->getName().toStdString().c_str(), screenshotActionVisible);
// backface culling
bool backfaceCulling = settings.value ( "backfaceCulling", false ).toBool(); // default false
propertyObject->setProperty(backfaceCullingProperty->getName().toStdString().c_str(), backfaceCulling);
......@@ -346,35 +352,53 @@ QWidget * InteractiveViewer::getWidget ( QWidget * parent ) {
//-- handle layout
QHBoxLayout *myLayout = new QHBoxLayout ( frame );
QSplitter *horizontalSplitter = new QSplitter(frame);
myLayout->addWidget ( horizontalSplitter );
myLayout->setSpacing ( 0 );
myLayout->setMargin ( 0 );
//-- show the renderer!
rendererWidget->setParent ( frame );
rendererWidget->show();
myLayout->addWidget ( rendererWidget );
myLayout->setSpacing ( 0 );
myLayout->setMargin ( 0 );
horizontalSplitter->addWidget(rendererWidget);
connect ( rendererWidget, SIGNAL ( rightButtonPressed() ), this, SLOT ( rightClick() ) );
//-- create the slider if needed
if ( myType == SLICE_VIEWER ) {
sideFrame = new QFrame;
QVBoxLayout *rightSideLayout = new QVBoxLayout;
rightSideLayout->setSpacing ( 0 );
rightSideLayout->setMargin ( 0 );
// add snapshot widget
QToolBar *screenshotActionMenu = new QToolBar ( rendererWidget );
screenshotActionMenu = new QToolBar ( rendererWidget );
screenshotActionMenu->addAction ( screenshotAction );
screenshotActionMenu->setEnabled ( true );
screenshotActionMenu->setVisible( false);
screenshotActionMenu->layout()->setSpacing ( 0 );
screenshotActionMenu->layout()->setMargin ( 0 );
rightSideLayout->addWidget ( screenshotActionMenu, 0, Qt::AlignCenter );
// add slider
sliceSlider->setParent ( frame );
sliceSlider->setFixedWidth ( sliceSlider->sizeHint().width() );
sliceSlider->setMinimumWidth ( 60 );
sliceSlider->setMaximumWidth ( 60 );
// connect the slider to this scene
connect ( sliceSlider, SIGNAL ( valueChanged ( int ) ), this, SLOT ( sliderChanged ( int ) ) );
rightSideLayout->addWidget ( sliceSlider );
// add the right side layout
sideFrame = new QFrame;
/*sideFrame->setSpacing ( 0 );
sideFrame->setMargin ( 0 );
*/
sideFrame->setLayout ( rightSideLayout );
myLayout->addWidget ( sideFrame );
QSizePolicy sideFrameSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
sideFrame->setSizePolicy(sideFrameSizePolicy);
sideFrame->setMinimumWidth(15);
sideFrame->setMaximumWidth(60);
//myLayout->addWidget ( sideFrame );
horizontalSplitter->addWidget(sideFrame);
} else
sideFrame = NULL;
......@@ -648,9 +672,11 @@ QMenu * InteractiveViewer::getMenu() {
options->addAction ( backgroundColorAction );
options->addAction ( toggleCopyrightAction );
options->addAction ( toggleAxesAction );
if ( myType == SLICE_VIEWER )
if ( myType == SLICE_VIEWER ) {
options->addAction ( toggleOrientationDecorationsAction );
options->addAction ( toggleScreenshotAction );
}
// AxesView mode
QMenu * cameraOrientationMenu = new QMenu ( "Camera Orientation" );
options->addMenu ( cameraOrientationMenu );
......@@ -880,6 +906,15 @@ void InteractiveViewer::initActions() {
toggleOrientationDecorationsAction->setStatusTip ( tr ( "Display Slice Orientation Information (Right, Left, Anterior, Posterior, Superior, Inferior" ) );
toggleOrientationDecorationsAction->setWhatsThis ( tr ( "Display Slice Orientation Information (Right, Left, Anterior, Posterior, Superior, Inferior" ) );
connect ( toggleOrientationDecorationsAction, SIGNAL ( toggled ( bool ) ), this, SLOT ( toggleOrientationDecorations ( bool ) ) );
toggleScreenshotAction = new QAction ( tr ( "&Toggle Screenshot Action" ), this );
toggleScreenshotAction->setCheckable ( true );
bool screenshotActionVisible = propertyObject->property(screenshotActionProperty->getName().toStdString().c_str()).toBool();
toggleScreenshotAction->setChecked ( screenshotActionVisible );
toggleScreenshotAction->setStatusTip ( tr ( "Show/Hide the screenshot button in the side bar of the slice viewer." ) );
toggleScreenshotAction->setWhatsThis ( tr ( "Show/Hide the screenshot button in the side bar of the slice viewer." ) );
connect ( toggleScreenshotAction, SIGNAL ( toggled ( bool ) ), this, SLOT ( setScreenshotAction ( bool ) ) );
}
if ( myType == GEOMETRY_VIEWER ) {
......@@ -1924,7 +1959,14 @@ void InteractiveViewer::setBackfaceCulling ( bool b ) {
propertyObject->setProperty(backfaceCullingProperty->getName().toStdString().c_str(), b);
}
//-------------------- slotPickingModeChanged ---------------------
// -------------- setScreenshotAction --------------
void InteractiveViewer::setScreenshotAction(bool b) {
propertyObject->setProperty(screenshotActionProperty->getName().toStdString().c_str(), b);
if (screenshotActionMenu)
screenshotActionMenu->setVisible(b);
}
//-------------------- pickingModeChanged ---------------------
void InteractiveViewer::pickingModeChanged ( QAction *selectedAction ) {
if ( selectedAction == pickCellAction ) {
initPicking ( CELL_PICKING );
......@@ -1937,6 +1979,7 @@ void InteractiveViewer::pickingModeChanged ( QAction *selectedAction ) {
}
}
//-------------------- picked ---------------------
void InteractiveViewer::picked() {
vtkSmartPointer<vtkAbstractPropPicker> picker = vtkAbstractPropPicker::SafeDownCast ( this->rendererWidget->GetInteractor()->GetPicker() );
......@@ -2132,6 +2175,10 @@ void InteractiveViewer::createProperties() {
linesAsTubesProperty = new Property("Lines considered as tube?", false, "Does this viewer replace drawn lines as tubes?", "" );
propertyObject->addProperty(linesAsTubesProperty);
// screenshot action property
screenshotActionProperty = new Property("Screenshot button visible", false, "Is the screenshot button visible in the slice viewer sidebar", "");
propertyObject->addProperty(screenshotActionProperty);
// backface culling property
backfaceCullingProperty = new Property("Backface culling", false, "Compute the non visible polygons and display them?", "");
propertyObject->addProperty(backfaceCullingProperty);
......@@ -2162,11 +2209,14 @@ bool InteractiveViewer::eventFilter(QObject *object, QEvent *event) {
// lines as tubes
bool linesAsTubes = propertyObject->property(linesAsTubesProperty->getName().toStdString().c_str()).toBool();
// backface culling
bool backfaceCulling = propertyObject->property(backfaceCullingProperty->getName().toStdString().c_str()).toBool();
rendererWidget->setBackfaceCulling ( backfaceCulling );
// screenshot action
bool screenshotActionVisible = propertyObject->property(screenshotActionProperty->getName().toStdString().c_str()).toBool();
// point size
double pointSize = propertyObject->property(pointSizeProperty->getName().toStdString().c_str()).toDouble();
rendererWidget->setPointSize ( pointSize );
......@@ -2184,6 +2234,7 @@ bool InteractiveViewer::eventFilter(QObject *object, QEvent *event) {
settings.setValue ("gradientBackground", useGradientBackgroundColor);
settings.setValue ( "linesAsTubes", linesAsTubes );
settings.setValue ( "backfaceCulling", backfaceCulling );
settings.setValue ( "screenshotActionVisible", screenshotActionVisible);
settings.setValue ( "pointSize", pointSize );
settings.endGroup();
......
......@@ -38,6 +38,7 @@
#include <QPushButton>
#include <QWidgetAction>
#include <QComboBox>
class QToolBar;
//-- vtk stuff
#include <vtkType.h>
......@@ -266,6 +267,9 @@ public slots:
/// set the backface culling mode (default is true).
void setBackfaceCulling ( bool );
/// visibility of the screenshot in slice viewers
void setScreenshotAction(bool);
public:
/// get the backface current culling mode.
// bool getBackfaceCulling() const;
......@@ -422,6 +426,9 @@ protected:
/// the right side frame (this is where the slider and screenshot buttons are shown)
QFrame *sideFrame;
/// the screenshot action is inside this menu (in the slice viewer side bar)
QToolBar *screenshotActionMenu;
/// the InteractiveViewerFrame keyPressEvent is a good friend of InteractiveViewer
friend void InteractiveViewerFrame::keyPressEvent ( QKeyEvent* e );
......@@ -489,6 +496,9 @@ protected:
/// back face culling
QAction *toggleBackfaceCullingAction;
/// visibility of the screenshot action in the side toolbar of slice viewer
QAction *toggleScreenshotAction;
/// action of the picking menu
QAction *pickPointAction;
QAction *pickCellAction;
......@@ -578,6 +588,11 @@ protected:
*/
Property* backfaceCullingProperty;
/**
* Property that tells whether the screenshot action is visible or not.
*/
Property* screenshotActionProperty;
/**
* Property which defines the point size of each point in the 3D viewer.
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment