15 class HardwareAdapterBase;
36 template <
typename ValueType>
54 template <
typename EnumType>
56 unsigned short SkipCharsFront = 0,
unsigned short SkipCharsEnd = 0)
59 auto QtEnum = QMetaEnum::fromType<EnumType>();
61 if (
static_cast<long>(QtEnum.keyCount()) - SkipEntriesFront - SkipEntriesEnd <= 0)
64 for (
int i = SkipEntriesFront; i < QtEnum.keyCount() - SkipEntriesEnd; ++i)
66 std::string ElementTitle(QtEnum.key(i));
67 ElementTitle = ElementTitle.substr(SkipCharsFront, ElementTitle.length() - SkipCharsFront - SkipCharsEnd);
69 List.emplace_back(ElementTitle.c_str(),
static_cast<EnumType
>(QtEnum.value(i)));
86 std::vector<QDomNode>
GetChildDOMNodes(
const QDomElement& Parent,
const QString& ChildTagName);
124 template <
typename T>
134 std::string
GetTFromDOMElement(
const QDomElement& Parent,
const QString& ChildTagName);
144 QDomAttr
GetDOMAttribute(
const QDomElement& Element,
const QString& AttributeName);
162 template <
typename T>
190 const QString& Title,
const QString& DefaultSuffix,
const QString& NameFilter,
const QString& InitialDirectory =
"");
203 const QString& Title,
const QString& DefaultSuffix,
const QString& NameFilter,
const QString& InitialDirectory =
"");
217 const QString& Title,
const QString& DefaultSuffix,
const QString& NameFilter);
235 QImage
QImageFromBlobData(BlobDataType&& BlobData,
int Width,
int Height,
int BytesPerLine, QImage::Format Format);
298 bool SaveToFile(
const QString& Filename, std::string_view Text);
316 std::string
ReadFromFile(
const std::filesystem::path& Filename);
412 constexpr
auto GetID() const noexcept {
return ID; }
413 constexpr std::string_view
GetName() const noexcept {
return Name; }
420 void SetName(std::string_view NewName);
470 void AddMarker(
const QPoint& MarkerPos,
const QColor& Color,
bool IsUserDeletable =
true,
MarkerType::IDType ID = -1, std::string Name = {});
479 void RemoveMarker(
size_t Index,
bool OnlyUserDeletableMarkers =
false);
487 void RemoveMarker(
const QPoint& MarkerPos,
bool OnlyUserDeletableMarkers =
false);
495 void RemoveMarker(std::string_view Name,
bool OnlyUserDeletableMarkers =
false);
515 void RenameMarker(
const QPoint& MarkerPos, std::string_view NewName);
542 virtual void wheelEvent(QWheelEvent* Event)
override;
582 virtual void dropEvent(QDropEvent* event)
override;
609 bool operator<(
const QTableWidgetItem& Other)
const;
611 virtual QTableWidgetItem*
clone()
const override;
632 virtual QWidget*
createEditor(QWidget* parent,
const QStyleOptionViewItem& option,
const QModelIndex& index)
const override;
Q_DECLARE_METATYPE(Util::MarkerGraphicsView::MarkerType::IDType)
DynExp's core class acts as the interface between the user interface and DynExp's internal data like ...
DynExpCore(HardwareAdapterLibraryVectorType HardwareAdapterLib, InstrumentLibraryVectorType InstrumentLib, ModuleLibraryVectorType ModuleLib, std::string ProjectFileToOpen="")
Constructs a DynExpCore instance.
Implements a QItemDelegate which forces e.g. a QTableWidgetItem's content to be boolean (0 or 1).
DigitalOnlyItemDelegate(QObject *parent=nullptr)
Implements a QGraphicsView the user can interact with to insert graphical markers....
const auto & GetCurrentImagePos() const noexcept
void OnSaveMarkers(bool)
Asks the user for a file name and saves all markers to a CSV file.
void OnContextMenuRequested(QPoint Position)
Shows the context menu at position Position.
const std::vector< MarkerType > & GetMarkers() const noexcept
virtual void mousePressEvent(QMouseEvent *Event) override
Adds a marker to the mouse pointer position assigning the highest ID amongst all markers in the graph...
QAction * SaveMarkersAction
bool MarkersChanged
Holds whether the markers have changed by any of the marker operations.
void ZoomReset()
Resets the zoom.
void DeselectMarkers()
Deselects all selected markers.
void EnableActions(bool Enable)
QAction * ShowMarkersAction
static constexpr double DeselectedMarkerOpacity
Determines the opacity of a marker which is not selected.
auto contextMenu() const noexcept
void setMarkersHidden(bool MarkersHidden)
Hides or shows all markers.
void RenameMarker(const QPoint &MarkerPos, std::string_view NewName)
Assigns a name to the marker at position MarkerPos. Affects MarkersChanged.
void SelectMarker(const QPoint &MarkerPos)
Selects the marker at position MarkerPos.
std::vector< MarkerType > Markers
List of the markers.
bool HaveMarkersChanged() noexcept
Returns whether a marker operation has changed the stored markers. Resets the flag.
void RemoveMarker(size_t Index, bool OnlyUserDeletableMarkers=false)
Removes the n-th marker specified by Index. Affects MarkersChanged.
bool MarkersHidden
Determines whether the markers are currently displayed or not.
QAction * RemoveMarkersAction
void AddMarker(const QPoint &MarkerPos, const QColor &Color, bool IsUserDeletable=true, MarkerType::IDType ID=-1, std::string Name={})
Adds a marker to the graphics view at position MarkerPos assigning the properties passed as arguments...
MarkerGraphicsView(QWidget *parent)
Constructs a MarkerGraphicsView.
void ZoomIn()
Zooms in one step.
static constexpr double ZoomFactor
Determines the magnification of one zoom step.
void OnShowMarkers(bool Checked)
If Checked is true, all markers are made visible, otherwise they become hidden.
void ZoomOut()
Zooms out one step.
static constexpr double SelectedMarkerOpacity
Determines the opacity of a selected marker.
virtual void mouseDoubleClickEvent(QMouseEvent *Event) override
Removes the marker at the mouse pointer position if it is user-deletable. Affects MarkersChanged.
QPointF CurrentImagePos
Sample position where the image has been recorded (in nm). Refer to MarkerType::ImagePos.
void SetCurrentImagePos(const QPointF &Pos)
void OnRemoveMarkers(bool)
Removes all user-deletable markers. Affects MarkersChanged.
virtual void wheelEvent(QWheelEvent *Event) override
Zooms in or out when Control is pressed on the keyboard at the same time.
void mouseClickEvent(QPoint Position)
void RemoveMarkers(bool OnlyUserDeletableMarkers)
Removes all markers from the graphics view. Affects MarkersChanged.
QAction * EditMarkersAction
Implements a QItemDelegate which forces e.g. a QTableWidgetItem's content to be numeric (double-preci...
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
NumericOnlyItemDelegate(QObject *parent=nullptr, double min=std::numeric_limits< double >::lowest(), double max=std::numeric_limits< double >::max(), int precision=-1)
Constructs a NumericOnlyItemDelegate and sets constraints on the numeric values it considers valid.
Thrown when an argument passed to a function exceeds the valid range.
Implements a QObject belonging to a hardware adapter (derived from DynExp::HardwareAdapterBase) that ...
static const DynExp::DynExpCore & GetDynExpCore(const DynExp::DynExpCore *DynExpCore=nullptr)
Returns the application's DynExp::DynExpCore instance which is globally set in constructor DynExp::Dy...
void MoveToWorkerThread(DynExp::ItemIDType ID)
Moves the instance to DynExpCore's worker thread. Do not call from constructor since derived classes ...
std::weak_ptr< const DynExp::HardwareAdapterBase > OwnerPtrType
bool HasBeenMovedToWorkerThread
Indicates whether the worker has already been moved to the worker thread.
void SetOwner(OwnerPtrType Owner) noexcept
Sets the hardware adapter owning this worker instance.
auto GetOwner() const noexcept
Returns this worker instance's owner.
OwnerPtrType Owner
Pointer to the hardware adapter owning this instance.
DynExp's main namespace contains the implementation of DynExp including classes to manage resources (...
size_t ItemIDType
ID type of objects/items managed by DynExp.
DynExp's Util namespace contains commonly used functions and templates as well as extensions to Qt an...
std::vector< TextType > TextListType
List type of text-type parameters.
std::string GetTFromDOMAttribute(const QDomElement &Element, const QString &AttributeName)
Behaves like GetDOMAttribute() but returns the content from an attribute converted to a certain type ...
ImageHistogramType ConvertRGBToIntensityHistogram(const ImageRGBHistogramType &RGBHistogram)
Computes an intensity (grayscale) histogram from a RGB histogram.
bool SaveToFile(const QString &Filename, std::string_view Text)
Saves a std::string_view to a file (using QFile). Creates a new file or truncates an existing file's ...
QDomElement GetSingleChildDOMElement(const QDomElement &Parent, const QString &ChildTagName)
Behaves like GetSingleChildDOMNode() but returns the node converted to a DOM element.
std::string GetTFromDOMElement(const QDomElement &Parent, const QString &ChildTagName)
Behaves like GetSingleChildDOMElement() but returns the content from a DOM element converted to a cer...
size_t TextListIndexType
List index type of Util::TextListType.
std::string GetStringFromDOMElement(const QDomElement &Parent, const QString &ChildTagName)
Behaves like GetSingleChildDOMElement() but returns the text from a DOM element.
const QLocale & GetDefaultQtLocale()
Returns the default locale properties to be assigned to Qt widgets.
std::string_view TextRefType
Reference-to-string type of text-type parameters (DynExp::ParamsBase::Param)
std::vector< QDomNode > GetChildDOMNodes(const QDomElement &Parent, const QString &ChildTagName)
Finds child nodes with a certain tag name.
QPolygonF MakeCrossPolygon(QPointF Center, unsigned int ArmLength)
Returns a QPolygonF representing a cross-style marker.
QImage QImageFromBlobData(BlobDataType &&BlobData, int Width, int Height, int BytesPerLine, QImage::Format Format)
Converts raw pixel data stored in a Util::BlobDataType object to a QImage transfering the ownership o...
std::array< unsigned long long, 256 > ImageHistogramType
Alias which represents a histogram as a std::array with 256 numeric bins. The lowest (highest) index ...
QString PromptOpenFilePath(QWidget *Parent, const QString &Title, const QString &DefaultSuffix, const QString &NameFilter, const QString &InitialDirectory)
Opens a file dialog to ask the user to select a single existing file.
ImageHistogramType ComputeIntensityHistogram(const QImage &Image)
Computes an intensity (grayscale) histogram from a QImage object.
void ActivateWindow(QWidget &Widget)
Renders a window active and brings it to the front.
auto QtEnumToTextValueList(unsigned short SkipEntriesFront=0, unsigned short SkipEntriesEnd=0, unsigned short SkipCharsFront=0, unsigned short SkipCharsEnd=0)
Returns a TextValueListType containing entries which reflect the items (names and values) of an enume...
std::string ReadFromFile(const QString &Filename)
Reads the entire content from a text file.
QDomAttr GetDOMAttribute(const QDomElement &Element, const QString &AttributeName)
Extracts an attribute from a DOM element.
QDomNode GetSingleChildDOMNode(const QDomElement &Parent, const QString &ChildTagName)
Finds a single child node with a certain tag name.
std::string TextType
String type of text-type parameters (DynExp::ParamsBase::Param)
std::tuple< ImageHistogramType, ImageHistogramType, ImageHistogramType > ImageRGBHistogramType
Alias which represents a RGB histogram as a std::tuple of three ImageHistogramType elements....
std::vector< std::pair< TextType, ValueType > > TextValueListType
Type of a list containing key-value pairs where key is a text of type Util::TextType.
QString PromptSaveFilePath(QWidget *Parent, const QString &Title, const QString &DefaultSuffix, const QString &NameFilter, const QString &InitialDirectory)
Works as PromptOpenFilePath() but asks the user to select a single file which does not need to exist.
ImageRGBHistogramType ComputeRGBHistogram(const QImage &Image)
Computes a RGB histogram from a QImage object.
QString PromptSaveFilePathModule(DynExp::QModuleWidget *Parent, const QString &Title, const QString &DefaultSuffix, const QString &NameFilter)
Works as PromptOpenFilePath() but asks the user to select a single file which does not need to exist....
std::string GetStringFromDOMAttribute(const QDomElement &Element, const QString &AttributeName)
Behaves like GetDOMAttribute() but returns the text from the attribute.
Accumulates include statements to provide a precompiled header.
Data associated with one marker.
constexpr const auto & GetMarkerPos() const noexcept
constexpr std::string_view GetName() const noexcept
constexpr const auto GetMarker() const noexcept
IDType ID
ID of the marker to identify it amongst other markers in the same graphics view.
QPointF ImagePos
Position in nm (e.g. of a sample under a microscope) where the associated image the marker belongs to...
bool UserDeletable
Determines whether the user can interact with this marker to delete it.
constexpr auto GetID() const noexcept
QPoint MarkerPos
Position of the marker within the graphics view in pixels.
QGraphicsPolygonItem * Marker
Qt polygon object to draw the marker onto the graphics view.
constexpr MarkerType(QGraphicsPolygonItem *Marker, const QPoint &MarkerPos, bool IsUserDeletable=true, IDType ID=-1, const QPointF &ImagePos={}) noexcept
Constructs a marker assigning the properties passed as arguments. Name will stay empty.
void SetName(std::string_view NewName)
constexpr const auto & GetImagePos() const noexcept
constexpr bool IsUserDeletable() const noexcept
std::string Name
Name of the marker to describe it.
constexpr auto GetMarker() noexcept