Skip to content

Commit

Permalink
Refs #6818. Adding menu item to set/unset LOD threshold.
Browse files Browse the repository at this point in the history
Also, making the ThreeSlice view automatically turn the threshold off.
  • Loading branch information
Michael Reuter committed Apr 3, 2013
1 parent fda0724 commit e139202
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class EXPORT_OPT_MANTIDVATES_SIMPLEGUI_VIEWWIDGETS MdViewerWidget : public Manti
protected slots:
/// Check for certain updates when an accept is fired.
void checkForUpdates();
/// Turn on/off the LOD threshold.
void onLodToggled(bool state);
/// Pop-up the rotation point dialog.
void onRotationPoint();
/// Show the wiki help in a browser.
Expand All @@ -99,6 +101,8 @@ protected slots:
pqLoadDataReaction *dataLoader; ///< Holder for the load data reaction
ViewBase *hiddenView; ///< Holder for the view that is being switched from
bool isPluginInitialized; ///< Flag for plugin initialization
double lodThreshold; ///< Default value for the LOD threshold (5 MB)
QAction *lodAction; ///< Holder for the LOD threshold menu item
bool pluginMode; ///< Flag to say widget is in plugin mode
RotationPointDialog *rotPointDialog; ///< Holder for the rotation point dialog
Ui::MdViewerWidgetClass ui; ///< The MD viewer's UI form
Expand Down Expand Up @@ -137,6 +141,8 @@ protected slots:
ViewBase *setMainViewWidget(QWidget *container, ModeControlWidget::Views v);
/// Helper function to swap current and hidden view pointers.
void swapViews();
/// Update the state of application widgets.
void updateAppState();
};

} // SimpleGui
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <pqPipelineSource.h>
#include <pqPVApplicationCore.h>
#include <pqRenderView.h>
#include <pqSettings.h>
#include <pqStatusBar.h>
#include <pqViewSettingsReaction.h>
#include <vtkSMDoubleVectorProperty.h>
Expand Down Expand Up @@ -127,6 +128,7 @@ void MdViewerWidget::internalSetup(bool pMode)
this->isPluginInitialized = false;
this->pluginMode = pMode;
this->rotPointDialog = NULL;
this->lodThreshold = 5.0;
}

/**
Expand Down Expand Up @@ -517,7 +519,7 @@ void MdViewerWidget::switchViews(ModeControlWidget::Views v)
this->currentView->render();
this->currentView->checkViewOnSwitch();
this->currentView->correctVisibility();
this->viewSettings->updateEnableState();
this->updateAppState();
}

/**
Expand Down Expand Up @@ -575,6 +577,15 @@ void MdViewerWidget::createMenus()

QMenu *viewMenu = menubar->addMenu(QApplication::tr("&View"));

this->lodAction = new QAction(QApplication::tr("Level-of-Detail (LOD...)"), this);
this->lodAction->setShortcut(QKeySequence::fromString("Ctrl+Shift+L"));
this->lodAction->setStatusTip(QApplication::tr("Enable/disable level-of-detail threshold."));
this->lodAction->setCheckable(true);
this->lodAction->setChecked(true);
QObject::connect(this->lodAction, SIGNAL(toggled(bool)),
this, SLOT(onLodToggled(bool)));
viewMenu->addAction(this->lodAction);

QAction *settingsAction = new QAction(QApplication::tr("View Settings..."), this);
settingsAction->setShortcut(QKeySequence::fromString("Ctrl+Shift+S"));
settingsAction->setStatusTip(QApplication::tr("Show the settings for the current view."));
Expand Down Expand Up @@ -606,6 +617,16 @@ void MdViewerWidget::addMenus()
this->createMenus();
}

/**
* This function intercepts the LOD menu action checking and calls the
* correct slot on the current view.
* @param state : whether the action is checked or not
*/
void MdViewerWidget::onLodToggled(bool state)
{
this->currentView->onLodThresholdChange(state, this->lodThreshold);
}

/**
* This function handles creating the rotation point input dialog box and
* setting the communication between it and the current view.
Expand Down Expand Up @@ -697,6 +718,27 @@ void MdViewerWidget::connectDialogs()
this->connectRotationPointDialog();
}

/**
* This function handles any update to the state of application components
* like menus, menu items, buttons, views etc.
*/
void MdViewerWidget::updateAppState()
{
this->viewSettings->updateEnableState();

ThreeSliceView *tsv = dynamic_cast<ThreeSliceView *>(this->currentView);
if (tsv)
{
this->currentView->onLodThresholdChange(false, this->lodThreshold);
this->lodAction->setChecked(false);
}
else
{
this->currentView->onLodThresholdChange(true, this->lodThreshold);
this->lodAction->setChecked(true);
}
}

} // namespace SimpleGui
} // namespace Vates
} // namespace Mantid

0 comments on commit e139202

Please sign in to comment.