Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/progress_ma…
Browse files Browse the repository at this point in the history
…nagement

# Conflicts:
#	HDPS/src/Project.cpp
  • Loading branch information
ThomasKroes committed Sep 26, 2023
2 parents 64d0c0a + 97edcf3 commit d552ff2
Show file tree
Hide file tree
Showing 22 changed files with 237 additions and 48 deletions.
38 changes: 31 additions & 7 deletions HDPS/src/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "Project.h"
#include "AbstractProjectManager.h"
#include "CoreInterface.h"
#include "Set.h"

#include "util/Serialization.h"

Expand All @@ -28,13 +29,7 @@ Project::Project(QObject* parent /*= nullptr*/) :
}

Project::Project(const QString& filePath, QObject* parent /*= nullptr*/) :
QObject(parent),
Serializable("Project"),
_filePath(),
_startupProject(),
_applicationVersion(Application::current()->getVersion()),
_projectMetaAction(this),
_task(this, "Project Task")
Project(parent)
{
setFilePath(filePath);
initialize();
Expand Down Expand Up @@ -160,19 +155,48 @@ void Project::updateContributors()

void Project::setStudioMode(bool studioMode)
{
<<<<<<< HEAD
auto plugins = hdps::plugins().getPluginsByTypes({ plugin::Type::VIEW, plugin::Type::ANALYSIS });
=======
auto plugins = hdps::plugins().getPluginsByTypes(); // by default gets all plugin types
auto& datasets = hdps::data().allSets();
>>>>>>> origin/master

if (studioMode) {
for (auto plugin : plugins)
plugin->cacheConnectionPermissions(true);
<<<<<<< HEAD

for (auto plugin : plugins)
plugin->setConnectionPermissionsToAll(true);
=======

for (auto plugin : plugins)
plugin->setConnectionPermissionsToAll(true);

for (auto& dataset : datasets)
{
for (auto& action : dataset.get()->getActions())
action->cacheConnectionPermissions(true);

for (auto& action : dataset.get()->getActions())
action->setConnectionPermissionsToAll(true);
}

>>>>>>> origin/master
}
else {
for (auto plugin : plugins)
plugin->restoreConnectionPermissions(true);
<<<<<<< HEAD
=======

for (auto& dataset : datasets)
for (auto& action : dataset.get()->getActions())
action->restoreConnectionPermissions(true);
>>>>>>> origin/master
}

}

ProjectMetaAction& Project::getProjectMetaAction()
Expand Down
5 changes: 5 additions & 0 deletions HDPS/src/actions/ColorPickerAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ ColorPickerAction::Widget::Widget(QWidget* parent, ColorPickerAction* colorPicke
auto colorPickerWidget = getWidgetFromColorDialog("QColorPicker");
auto colorLuminanceWidget = getWidgetFromColorDialog("QColorLuminancePicker");

if(colorPickerWidget == nullptr)
colorPickerWidget = getWidgetFromColorDialog("QtPrivate::QColorPicker");
if(colorLuminanceWidget == nullptr)
colorLuminanceWidget = getWidgetFromColorDialog("QtPrivate::QColorLuminancePicker");

colorPickerWidget->setFixedSize(250, 150);

auto pickersLayout = new QHBoxLayout();
Expand Down
15 changes: 9 additions & 6 deletions HDPS/src/actions/NumericalRangeAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class NumericalRangeAction : public GroupAction
using RangeChangedCB = std::function<void()>;

public:
using ValueType = NumericalType;

/** Describes the widget settings */
enum WidgetFlag {
Expand Down Expand Up @@ -126,11 +127,8 @@ class NumericalRangeAction : public GroupAction
if (range == getRange())
return;

QSignalBlocker rangeMinActionBlocker(&_rangeMinAction);
QSignalBlocker rangeMaxActionBlocker(&_rangeMaxAction);

_rangeMinAction.initialize(range.getMinimum(), range.getMaximum(), range.getMinimum(), range.getMinimum());
_rangeMaxAction.initialize(range.getMinimum(), range.getMaximum(), range.getMaximum(), range.getMaximum());
_rangeMinAction.setValue(range.getMinimum());
_rangeMaxAction.setValue(range.getMaximum());

_rangeChanged();
}
Expand All @@ -152,6 +150,7 @@ class NumericalRangeAction : public GroupAction
return;

_rangeMinAction.setMinimum(limitsMinimum);
_rangeMaxAction.setMinimum(limitsMinimum);

_limitsChanged();
}
Expand All @@ -169,9 +168,10 @@ class NumericalRangeAction : public GroupAction
* @param limitsMaximum Limits maximum
*/
void setLimitsMaximum(NumericalType limitsMaximum) {
if (limitsMaximum == _rangeMaxAction.getMinimum())
if (limitsMaximum == _rangeMaxAction.getMaximum())
return;

_rangeMinAction.setMaximum(limitsMaximum);
_rangeMaxAction.setMaximum(limitsMaximum);

_limitsChanged();
Expand All @@ -191,6 +191,9 @@ class NumericalRangeAction : public GroupAction
return;

_rangeMinAction.setMinimum(limits.getMinimum());
_rangeMaxAction.setMinimum(limits.getMinimum());

_rangeMinAction.setMaximum(limits.getMaximum());
_rangeMaxAction.setMaximum(limits.getMaximum());

_limitsChanged();
Expand Down
75 changes: 69 additions & 6 deletions HDPS/src/actions/RectangleAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ namespace hdps::gui {
template<typename RectangleType, typename NumericalRangeActionType>
class RectangleAction : public GroupAction
{
typedef typename NumericalRangeActionType::ValueType NumValType;
using ValueRange = util::NumericalRange<NumValType>;
public:

/** Templated classes with Q_OBJECT macro are not allowed, so use function pointers in stead */
Expand Down Expand Up @@ -98,7 +100,8 @@ class RectangleAction : public GroupAction
*/
RectangleAction(QObject * parent, const QString& title, const RectangleType& rectangle = RectangleType()) :
GroupAction(parent, title),
_rangeAction{ NumericalRangeActionType(this, "X-range"), NumericalRangeActionType(this, "Y-range") }
_rangeAction{ NumericalRangeActionType(this, "X-range", ValueRange(std::numeric_limits<NumValType>::lowest(), std::numeric_limits<NumValType>::max())), NumericalRangeActionType(this, "Y-range", ValueRange(std::numeric_limits<NumValType>::lowest(), std::numeric_limits<NumValType>::max())) },
_rectangle()
{
setDefaultWidgetFlags(WidgetFlag::Default);

Expand All @@ -118,9 +121,7 @@ class RectangleAction : public GroupAction
*/
RectangleType getRectangle() const
{
RectangleType rectangle;

return rectangle;
return _rectangle;
}

/**
Expand All @@ -129,14 +130,75 @@ class RectangleAction : public GroupAction
*/
void setRectangle(const RectangleType& rectangle)
{
/*
if (rectangle == _rectangle)
return;

_rectangle = rectangle;

getRangeAction(Axis::X).setRange(ValueRange(static_cast<NumValType>(_rectangle.left()), static_cast<NumValType>(_rectangle.right())));
getRangeAction(Axis::Y).setRange(ValueRange(static_cast<NumValType>(_rectangle.bottom()), static_cast<NumValType>(_rectangle.top())));

_rectangleChanged();
}

/**
* Set left rectangle value to to \p left
* @param left New left rectangle value
*/
void setValueLeft(typename NumericalRangeActionType::ValueType left)
{
if (left == _rectangle.left())
return;

_rectangle.setLeft(left);
getRangeAction(Axis::X).setMinimum(left);

_rectangleChanged();
}

/**
* Set right rectangle value to to \p right
* @param right New right rectangle value
*/
void setValueRight(typename NumericalRangeActionType::ValueType right)
{
if (right == _rectangle.right())
return;

_rectangle.setRight(right);
getRangeAction(Axis::X).setMaximum(right);

_rectangleChanged();
}

/**
* Set bottom rectangle value to to \p bottom
* @param bottom New bottom rectangle value
*/
void setValueBottom(typename NumericalRangeActionType::ValueType bottom)
{
if (bottom == _rectangle.bottom())
return;

_rectangle.setBottom(bottom);
getRangeAction(Axis::Y).setMinimum(bottom);

_rectangleChanged();
}

/**
* Set top rectangle value to to \p top
* @param top New top rectangle value
*/
void setValueTop(typename NumericalRangeActionType::ValueType top)
{
if (top == _rectangle.top())
return;

_rectangle.setTop(top);
getRangeAction(Axis::Y).setMaximum(top);

_rectangleChanged();
*/
}

public: // Action getters
Expand All @@ -150,6 +212,7 @@ class RectangleAction : public GroupAction

protected:
RectangleChangedCB _rectangleChanged; /** Callback which is called when the rectangle changed */
RectangleType _rectangle; /** Rectanlge values (left, right, top, bottom) */
};

}
2 changes: 1 addition & 1 deletion HDPS/src/plugins/ClusterData/src/InfoAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "ClusterData.h"
#include "ClustersAction.h"

#include "actions/Actions.h"
#include "actions/StringAction.h"
#include "event/EventListener.h"

namespace hdps {
Expand Down
3 changes: 2 additions & 1 deletion HDPS/src/plugins/ClusterData/src/SubsetAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

#pragma once

#include "actions/Actions.h"
#include "actions/StringAction.h"
#include "actions/TriggerAction.h"

using namespace hdps;
using namespace hdps::gui;
Expand Down
17 changes: 11 additions & 6 deletions HDPS/src/plugins/DataHierarchyPlugin/src/DataHierarchyWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <QLabel>
#include <QStyledItemDelegate>
#include <QStyleOptionViewItem>
#include <QScopedPointer>

#include <stdexcept>

Expand Down Expand Up @@ -138,16 +139,20 @@ DataHierarchyWidget::DataHierarchyWidget(QWidget* parent) :
});

connect(&_hierarchyWidget.getTreeView(), &QTreeView::customContextMenuRequested, this, [this](const QPoint& position) {
const auto selectedRows = _hierarchyWidget.getSelectedRows();

Datasets datasets;
auto createContextMenu = [this, position]() -> void {
Datasets datasets;

for (const auto& selectedRow : selectedRows)
datasets << _model.getItem(selectedRow, Qt::DisplayRole)->getDataHierarchyItem()->getDataset();
for (const auto& selectedRow : _hierarchyWidget.getSelectedRows())
datasets << _model.getItem(selectedRow, Qt::DisplayRole)->getDataHierarchyItem()->getDataset();

auto datasetsContextMenu = new DataHierarchyWidgetContextMenu(this, datasets);
QScopedPointer<DataHierarchyWidgetContextMenu> datasetsContextMenu(new DataHierarchyWidgetContextMenu(this, datasets));
datasetsContextMenu->exec(_hierarchyWidget.getTreeView().viewport()->mapToGlobal(position));

datasetsContextMenu->exec(_hierarchyWidget.getTreeView().viewport()->mapToGlobal(position));
};

// Get around possible signal-execution order complications
QTimer::singleShot(10, createContextMenu);
});

for (const auto topLevelItem : Application::core()->getDataHierarchyManager().getTopLevelItems())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,56 @@
#include <Application.h>
#include <CoreInterface.h>
#include <AbstractDataHierarchyManager.h>
#include <widgets/ViewPluginEditorDialog.h>
#include <Set.h>

Q_PLUGIN_METADATA(IID "nl.BioVault.DataPropertiesPlugin")

using namespace hdps;

DataPropertiesPlugin::DataPropertiesPlugin(const PluginFactory* factory) :
ViewPlugin(factory),
_dataPropertiesWidget(nullptr)
_dataPropertiesWidget(nullptr),
_additionalEditorAction(this, "Edit dataset parameters..."),
_dataset(nullptr)
{
_additionalEditorAction.setIcon(Application::getIconFont("FontAwesome").getIcon("cogs"));
_additionalEditorAction.setShortcut(tr("F11"));
_additionalEditorAction.setShortcutContext(Qt::WidgetWithChildrenShortcut);
_additionalEditorAction.setConfigurationFlag(WidgetAction::ConfigurationFlag::VisibleInMenu);
_additionalEditorAction.setConnectionPermissionsToForceNone();
_additionalEditorAction.setEnabled(false);

addTitleBarMenuAction(&_additionalEditorAction);

connect(&Application::core()->getDataHierarchyManager(), &AbstractDataHierarchyManager::selectedItemsChanged, this, &DataPropertiesPlugin::selectedItemsChanged, Qt::DirectConnection);

connect(&_additionalEditorAction, &TriggerAction::triggered, this, [this]() -> void {

if (!_dataset.isValid())
return;

auto* viewPluginEditorDialog = new hdps::gui::ViewPluginEditorDialog(nullptr, dynamic_cast<WidgetAction*>(_dataset.get()));
connect(viewPluginEditorDialog, &hdps::gui::ViewPluginEditorDialog::finished, viewPluginEditorDialog, &hdps::gui::ViewPluginEditorDialog::deleteLater);
viewPluginEditorDialog->open();
});

}

void DataPropertiesPlugin::selectedItemsChanged(DataHierarchyItems selectedItems)
{
if (projects().isOpeningProject() || projects().isImportingProject())
return;

if (selectedItems.isEmpty()) {
_dataset = nullptr;
_additionalEditorAction.setEnabled(false);
return;
}

// Save reference to currently selected dataset
_dataset = selectedItems.first()->getDataset();
_additionalEditorAction.setEnabled(true);
}

void DataPropertiesPlugin::init()
Expand Down
11 changes: 11 additions & 0 deletions HDPS/src/plugins/DataPropertiesPlugin/src/DataPropertiesPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "DataPropertiesWidget.h"

#include <ViewPlugin.h>
#include <actions/TriggerAction.h>

using namespace hdps::plugin;

Expand All @@ -26,8 +27,18 @@ class DataPropertiesPlugin : public ViewPlugin

void init() override;

protected:

/**
* Callback when is called when the selected items in the data hierarchy changes
* @param datasetId Globally unique identifier of the dataset
*/
void selectedItemsChanged(DataHierarchyItems selectedItems);

private:
DataPropertiesWidget _dataPropertiesWidget; /** Data properties widget */
gui::TriggerAction _additionalEditorAction; /** Trigger action to start the data set editor */
Dataset<DatasetImpl> _dataset; /** Smart pointer to currently selected dataset */
};

class DataPropertiesPluginFactory : public ViewPluginFactory
Expand Down
2 changes: 1 addition & 1 deletion HDPS/src/plugins/ImageData/src/InfoAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include "actions/Actions.h"
#include "actions/StringAction.h"
#include "event/EventListener.h"

#include "Images.h"
Expand Down
Loading

0 comments on commit d552ff2

Please sign in to comment.