31 #include <boost/filesystem.hpp>
32 #include <boost/program_options.hpp>
34 #include <QtCore/QDir>
37 #include <QDialogButtonBox>
38 #include <QFileDialog>
39 #include <QGridLayout>
41 #include <QPushButton>
43 #include <QVBoxLayout>
45 #include "core/common/WPathHelper.h"
46 #include "core/kernel/WModuleFactory.h"
47 #include "WMainWindow.h"
49 #include "WQtModuleConfig.h"
53 return ( i->getName() < j->getName() );
68 for( ProtoIter iter = r->get().begin(); iter != r->get().end(); ++iter )
75 QVBoxLayout* layoutAllowedModules =
new QVBoxLayout;
76 QWidget* p1 =
new QWidget();
77 p1->setLayout( layoutAllowedModules );
79 QVBoxLayout* layoutModulePaths =
new QVBoxLayout;
80 QWidget* p2 =
new QWidget();
81 p2->setLayout( layoutModulePaths );
84 QTabWidget* tab =
new QTabWidget(
this );
85 tab->addTab( p1,
"Allowed Modules" );
86 tab->addTab( p2,
"Module Paths" );
87 QVBoxLayout* mainLayout =
new QVBoxLayout();
88 mainLayout->addWidget( tab );
89 setLayout( mainLayout );
91 QString helpText =
"This dialog allows you to modify the list of modules used everywhere in OpenWalnut. The list contains all loaded modules. "
92 "By default, the list is interpreted as white-list. This means, you have to select the modules you want "
93 "to use and disable those you won't use. You can switch to black-listing. This allows you to select all modules "
94 "that should not be used.";
95 QLabel* hint =
new QLabel( helpText );
96 hint->setWordWrap(
true );
97 layoutAllowedModules->addWidget( hint );
99 QString helpTextPaths =
"You can add more search paths here, where OpenWalnut searches modules during startup. Each path is searched "
100 "recursively. Use this list to help OpenWalnut find your downloaded or self-made modules. An alternative option is to "
101 "set the environment variable \"OW_MODULE_PATH\", which is a semicolon-separated list of search paths. After "
102 "restarting OpenWalnut, the modules in the added paths appear in the list of allowed modules.";
103 QLabel* hintPaths =
new QLabel( helpTextPaths );
104 hintPaths->setWordWrap(
true );
105 layoutModulePaths->addWidget( hintPaths );
110 m_showThemAll =
new QCheckBox(
"Always show all modules.",
this );
112 "Recommended option. This ensures that all modules get shown all them time, regardless of the list below."
118 m_asBlackList->setToolTip(
"Activate this option if you want all modules to be active in OpenWalnut that are not explicitly deactivated here." );
121 QHBoxLayout* blacklistPresetRow =
new QHBoxLayout();
122 layoutAllowedModules->addLayout( blacklistPresetRow );
124 m_usePreset =
new QCheckBox(
"Use a preset module list",
this );
125 m_usePreset->setToolTip(
"Activate this option if you want to use a list of preselected "
126 "modules which may be specific for different research areas. " );
132 QString presetSIVERT =
"Anisotropic Filter,Calculate GFA,Calculate Tensors,Cluster Display,ClusterDisplayVoxels,"
133 "Data Type Conversion,Diffusion Tensor Scalars,EEG View,Effective Connectivity Cluster,Fiber Data Creator,"
134 "Fiber translator,Functional MRI Viewer,Hierarchical Clustering Display,Image Space LIC,Image Space Tensor LIC,"
135 "Merge Components To Vector,Mori Det. Tracking,Partition To Mesh,Picking in DVR Evaluation,"
136 "Probabilistic Tract Rendering with multi transparent iso surfaces.,"
137 "Read Amira Mesh,Read Dipoles,Read Raw Data,Read Simple Text Line Data,Read Spherical Harmonics,Read VCL,"
138 "Read VIM,Scalar Data Creator,Spline Surface,Superquadric Glyphs,Surface Parameter Animator,"
139 "Template,Template Colormapping,Template Containers,Template Data Loader,Template Render Pipelines,"
140 "Template Shaders,Template UI,Vector Align,Vector Data Creator,Vector Normalize,Vector Operator,"
141 "Vector Plot,Vector Scaling,WebGL Support,Write Amira Mesh,Write Dendrogram,";
149 m_selectPresetBlacklist->setToolTip(
"Select a preset or create a new one by selecting modules in the list below "
150 "and type in a name here." );
163 QSpacerItem* horizSpacer =
new QSpacerItem( 1, 1, QSizePolicy::Expanding, QSizePolicy::Fixed );
164 blacklistPresetRow->addSpacerItem( horizSpacer );
167 m_list =
new QListWidget();
168 layoutAllowedModules->addWidget(
m_list );
175 QHBoxLayout* addRemLayout =
new QHBoxLayout();
176 QWidget* addRemWidget =
new QWidget();
177 addRemWidget->setLayout( addRemLayout );
178 layoutModulePaths->addWidget( addRemWidget );
179 QPushButton* addButton =
new QPushButton(
"Add Path" );
182 addRemLayout->addWidget( addButton );
185 connect( addButton, SIGNAL( clicked(
bool ) ),
this, SLOT(
addModulePath() ) );
193 for( std::vector< WModule::ConstSPtr >::const_iterator iter =
m_moduleList.begin(); iter !=
m_moduleList.end(); ++iter )
196 QWidget* widget =
new QWidget(
m_list );
198 QGridLayout* layoutWidget =
new QGridLayout();
200 QSizePolicy sizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
205 QCheckBox* check =
new QCheckBox();
206 check->setSizePolicy( sizePolicy );
207 layoutWidget->addWidget( check, 0, 0, 2, 1 );
215 QLabel* icon =
new QLabel();
216 icon->setSizePolicy( sizePolicy );
220 QPixmap qicon( modIco.pixmap( 32, 32 ) );
221 qicon = qicon.scaled( 32, 32, Qt::KeepAspectRatio );
222 icon->setPixmap( qicon );
224 layoutWidget->addWidget( icon, 0, column, 2, 1 );
228 layoutWidget->addWidget(
new QLabel(
"<b>" + QString::fromStdString( ( *iter )->getName() )+
"</b>" ), 0, column );
230 if( !( *iter )->getDescription().empty() )
232 layoutWidget->addWidget(
new QLabel( QString::fromStdString( ( *iter )->getDescription() ) ), 1, column );
235 layoutWidget->setSizeConstraint( QLayout::SetMaximumSize );
236 widget->setLayout( layoutWidget );
240 item->setSizeHint( widget->sizeHint() );
243 m_list->setItemWidget( item, widget );
244 m_list->setMinimumHeight( 150 );
248 QDialogButtonBox* defButtons =
new QDialogButtonBox( QDialogButtonBox::Save | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults,
249 Qt::Horizontal,
this );
250 connect( defButtons, SIGNAL( accepted() ),
this, SLOT(
accept() ) );
251 connect( defButtons, SIGNAL( rejected() ),
this, SLOT(
reject() ) );
252 connect( defButtons->button( QDialogButtonBox::RestoreDefaults ), SIGNAL( clicked() ),
this, SLOT(
reset() ) );
253 mainLayout->addWidget( defButtons );
271 std::string p = ( *it ).toString().toStdString();
279 bool ignoreAllowedList =
WQtGui::getSettings().value(
"qtgui/modules/IgnoreAllowedList",
true ).toBool();
280 m_showThemAll->setCheckState( ignoreAllowedList ? Qt::Checked : Qt::Unchecked );
282 bool asBlackList =
WQtGui::getSettings().value(
"qtgui/modules/asBlackList",
false ).toBool();
283 m_asBlackList->setCheckState( asBlackList ? Qt::Checked : Qt::Unchecked );
286 m_usePreset->setCheckState( usePreset ? Qt::Checked : Qt::Unchecked );
288 if( !defaultModulePaths )
296 std::string p = ( *it ).toString().toStdString();
297 m_pathList->addItem( QString::fromStdString( p ) );
306 std::string allowedAsString;
312 if( iter->second->checkState() == Qt::Checked )
315 allowedAsString += iter->first +
",";
320 WQtGui::getSettings().setValue(
"qtgui/modules/allowedList", QString::fromStdString( allowedAsString ) );
335 for(
int i = 0; i <
m_pathList->count(); ++i )
337 paths.push_back(
m_pathList->item( i )->text() );
344 bool blackList = (
m_asBlackList->checkState() == Qt::Checked );
345 bool ignoreList = (
m_showThemAll->checkState() == Qt::Checked );
348 return !ignoreList && ( ( blackList && isInList ) || ( !blackList && !isInList ) );
364 a->setToolTip(
"Allows you to configure the list of modules, which is used for selecting modules in OpenWalnut (i.e. in the toolbar)." );
365 connect( a, SIGNAL( triggered(
bool ) ),
this, SLOT(
configure() ) );
389 m_list->setDisabled(
true );
393 m_list->setDisabled(
false );
408 m_list->setDisabled(
false );
413 QString dir = QFileDialog::getExistingDirectory(
this,
"Select Directory",
415 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks );
438 for( std::vector< WModule::ConstSPtr >::const_iterator iter =
m_moduleList.begin(); iter !=
m_moduleList.end(); ++iter )
441 m_moduleItemMap[ ( *iter )->getName() ]->setCheckState( Qt::Unchecked );
448 std::string allowedModules =
"";
457 allowedModules =
WQtGui::getSettings().value(
"qtgui/modules/allowedList",
"" ).toString().toStdString();
475 if( usePresetState == 0 )
492 settings->beginGroup(
"qtgui/modules/preset/" );
493 QStringList childKeys = settings->childKeys();
495 settings->endGroup();
499 if( selectedPresetIndex != -1 )
QIcon getIcon(const std::string name)
Searches icons in the internal map and all modules for the given icon name.
WIconManager * getIconManager()
Return icon manager.
std::set< std::shared_ptr< WModule > >::const_iterator PrototypeContainerConstIteratorType
Const iterator for the prototype set.
static SPtr getModuleFactory()
Returns instance of the module factory to use to create modules.
std::shared_ptr< const WModule > ConstSPtr
Shared pointer to a const WModule.
static boost::filesystem::path getHomePath()
The path to the OW dir in the user's home.
static std::shared_ptr< WPathHelper > getPathHelper()
Returns instance of the path helper.
static QSettings & getSettings()
Returns the settings object.
static WMainWindow * getMainWindow()
Returns the current main window instance or NULL if not existent.
virtual void pathListSelectionChanged()
Call this notify the remove button whether something is selected in m_pathList or not.
QCheckBox * m_showThemAll
Checkbox controlling whether all modules should be shown all the time.
QPushButton * m_removePathButton
Button responsible for removing the currently selected path in m_pathList.
void configure()
Uses a modal dialog to allow the user modifying it.
QListWidget * m_list
This widget contains the allowed module list.
WQtModuleConfig(QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags())
Constructs excluder dialog and loads needed settings.
QListWidget * m_pathList
This list widget contains all additional search paths.
virtual void removeModulePath()
Remove the selected item from m_pathList;.
void resetAllModuleCheckboxes()
Call this to reset all checkboxes in the list of modules.
QCheckBox * m_asBlackList
Control whether the list is interpreted as black list.
void showThemAllUpdated()
Triggered by the m_showThemAll checkbox.
std::vector< WModule::ConstSPtr > m_moduleList
The list of available modules.
static void initPathHelper()
This function initializes the path helper by loading the module path settings.
virtual void accept()
Hides the dialog, updates the internal lists and emits updated-signal.
bool operator()(std::string const &name) const
Checks exclusion by name.
void refreshComboboxItems()
Call this to refresh the combobox items.
void updated()
Signal getting emitted if the exclusion-lists changes.
void reset()
called by the reset button
virtual void addModulePath()
Add a path to m_pathList;.
QComboBox * m_selectPresetBlacklist
Combobox to select a black list.
void loadListsFromSettings(bool defaultModulePaths=false)
Reloads the whitelist and the blacklist from the QSettings.
virtual ~WQtModuleConfig()
Destructor.
QAction * getConfigureAction() const
Creates an action instance allowing the configuration.
QCheckBox * m_usePreset
Check if you want to use a preset module list.
virtual void reject()
Hides the dialog, does not update the internal lists.
void refreshModuleCheckboxes()
Call this to refresh the list of selected modules, e.g.
ModuleItemMapType m_moduleItemMap
Maps between module name and item.
AllowedModuleList m_allowedModules
The list of modules that are allowed.
void toggleComboboxVisibility(int)
Call this to show or hide the preset combobox.
void saveListToSettings()
Saves the whitelist and the blacklist to the settings.
std::shared_ptr< WSharedObjectTicketRead< T > > ReadTicket
Type for read tickets.
std::vector< std::string > tokenize(const std::string &source, const std::string &delim=WHITESPACE, bool compress=true)
Splits the given string into a vector of strings (so called tokens).