Commit 1264d1d7 authored by Alexander Semke's avatar Alexander Semke
Browse files

[worksheet] always draw the plot legend on top of other plot objects.

parent a0e9a69e
......@@ -30,7 +30,6 @@
#include "backend/worksheet/Worksheet.h"
#include "backend/worksheet/WorksheetElement.h"
#include "backend/worksheet/plots/AbstractPlot.h"
#include "backend/worksheet/plots/cartesian/Axis.h"
#include <QGraphicsItem>
#include <QMenu>
......@@ -144,8 +143,8 @@ QMenu* WorksheetElement::createContextMenu() {
//add the sub-menu for the drawing order
//don't add the drawing order menu for axes, they're always drawn on top of each other elements
if (dynamic_cast<Axis*>(this))
//don't add the drawing order menu for axes and legends, they're always drawn on top of each other elements
if (type() == AspectType::Axis || type() == AspectType::CartesianPlotLegend)
return menu;
//for plots in a worksheet with an active layout the Z-factor is not relevant but we still
......@@ -173,7 +172,7 @@ QMenu* WorksheetElement::createContextMenu() {
//don't add the drawing order menu if the parent element has no other children
int children = 0;
for (auto* child : parentAspect()->children<WorksheetElement>()) {
if ( !dynamic_cast<Axis*>(child) )
if (child->type() != AspectType::Axis && child->type() != AspectType::CartesianPlotLegend)
children++;
}
......@@ -193,8 +192,8 @@ void WorksheetElement::prepareMoveBehindMenu() {
for (int i = 0; i < index; ++i) {
const WorksheetElement* elem = children.at(i);
//axes are always drawn on top of other elements, don't add them to the menu
if (!dynamic_cast<const Axis*>(elem)) {
//axes and legends are always drawn on top of other elements, don't add them to the menu
if (elem->type() != AspectType::Axis && elem->type() != AspectType::CartesianPlotLegend) {
QAction* action = m_moveBehindMenu->addAction(elem->icon(), elem->name());
action->setData(i);
}
......@@ -213,8 +212,8 @@ void WorksheetElement::prepareMoveInFrontOfMenu() {
for (int i = index + 1; i < children.size(); ++i) {
const WorksheetElement* elem = children.at(i);
//axes are always drawn on top of other elements, don't add them to the menu
if (!dynamic_cast<const Axis*>(elem)) {
//axes and legends are always drawn on top of other elements, don't add them to the menu
if (elem->type() != AspectType::Axis && elem->type() != AspectType::CartesianPlotLegend) {
QAction* action = m_moveInFrontOfMenu->addAction(elem->icon(), elem->name());
action->setData(i);
}
......
......@@ -172,6 +172,15 @@ void CartesianPlotLegend::retransform() {
d_ptr->retransform();
}
/*!
* overrides the implementation in WorksheetElement and sets the z-value to the maximal possible,
* legends are drawn on top of all other object in the plot.
*/
void CartesianPlotLegend::setZValue(qreal) {
Q_D(CartesianPlotLegend);
d->setZValue(std::numeric_limits<double>::max());
}
void CartesianPlotLegend::handleResize(double horizontalRatio, double verticalRatio, bool pageResize) {
Q_UNUSED(horizontalRatio);
Q_UNUSED(verticalRatio);
......
......@@ -87,6 +87,7 @@ public:
BASIC_D_ACCESSOR_DECL(int, layoutColumnCount, LayoutColumnCount)
void retransform() override;
void setZValue(qreal) override;
void handleResize(double horizontalRatio, double verticalRatio, bool pageResize) override;
typedef CartesianPlotLegendPrivate Private;
......
Markdown is supported
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