Add Indicator for PositionLocked state

This commit is contained in:
wandererfan
2019-03-28 11:15:51 -04:00
committed by wmayer
parent 3f88badb6d
commit 3a37fed62a
7 changed files with 42 additions and 1 deletions

View File

@@ -36,7 +36,7 @@
using namespace TechDrawGui;
QGCustomImage::QGCustomImage()
QGCustomImage::QGCustomImage()
{
setCacheMode(QGraphicsItem::NoCache);
setAcceptHoverEvents(false);
@@ -74,6 +74,12 @@ bool QGCustomImage::load(QString fileSpec)
return(success);
}
QSize QGCustomImage::imageSize(void)
{
QSize result = m_px.size();
return result;
}
void QGCustomImage::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;

View File

@@ -26,6 +26,7 @@
#include <QGraphicsItem>
#include <QGraphicsPixmapItem>
#include <QPointF>
#include <QSize>
#include <QByteArray>
#include <QPixmap>
@@ -52,6 +53,7 @@ public:
virtual void centerAt(QPointF centerPos);
virtual void centerAt(double cX, double cY);
virtual bool load(QString fileSpec);
virtual QSize imageSize(void);
protected:
QPixmap m_px;

View File

@@ -60,6 +60,7 @@
#include "QGCustomText.h"
#include "QGICaption.h"
#include "QGCustomClip.h"
#include "QGCustomImage.h"
#include "QGIViewClip.h"
#include "ViewProviderDrawingView.h"
#include "MDIViewPage.h"
@@ -106,6 +107,13 @@ QGIView::QGIView()
addToGroup(m_border);
m_caption = new QGICaption();
addToGroup(m_caption);
m_lock = new QGCustomImage();
m_lock->setParentItem(m_label);
m_lock->load(QString::fromUtf8(":/icons/techdraw-lock.png"));
QSize sizeLock = m_lock->imageSize();
m_lockWidth = (double) sizeLock.width();
m_lockHeight = (double) sizeLock.height();
m_lock->hide();
isVisible(true);
}
@@ -393,12 +401,18 @@ void QGIView::drawCaption()
void QGIView::drawBorder()
{
auto feat = getViewObject();
if (feat == nullptr) {
return;
}
drawCaption();
//show neither
auto vp = static_cast<ViewProviderDrawingView*>(getViewProvider(getViewObject()));
if (!borderVisible && !vp->KeepLabel.getValue()) {
m_label->hide();
m_border->hide();
m_lock->hide();
return;
}
@@ -406,6 +420,7 @@ void QGIView::drawBorder()
//double margin = 2.0;
m_label->hide();
m_border->hide();
m_lock->hide();
m_label->setDefaultTextColor(m_colCurrent);
m_font.setFamily(getPrefFont());
@@ -439,6 +454,17 @@ void QGIView::drawBorder()
displayArea.top(),
frameWidth,
frameHeight);
double lockX = labelArea.left();
double lockY = labelArea.bottom() - (2 * m_lockHeight);
if (feat->isLocked()) {
m_lock->setZValue(ZVALUE::LOCK);
m_lock->setPos(lockX,lockY);
m_lock->show();
} else {
m_lock->hide();
}
prepareGeometryChange();
m_border->setRect(frameArea.adjusted(-2,-2,2,2));
m_border->setPos(0.,0.);

View File

@@ -47,6 +47,7 @@ class QGCustomText;
class QGICaption;
class MDIViewPage;
class QGIViewClip;
class QGCustomImage;
class TechDrawGuiExport QGIView : public QGraphicsItemGroup
{
@@ -141,7 +142,11 @@ protected:
QGCustomLabel* m_label;
QGCustomBorder* m_border;
QGICaption* m_caption;
QGCustomImage* m_lock;
QPen m_decorPen;
double m_lockWidth;
double m_lockHeight;
};
} // namespace

View File

@@ -70,6 +70,7 @@
<file>icons/arrow-down.svg</file>
<file>icons/arrow-ccw.svg</file>
<file>icons/arrow-cw.svg</file>
<file>icons/techdraw-lock.png</file>
<file>translations/TechDraw_af.qm</file>
<file>translations/TechDraw_zh-CN.qm</file>
<file>translations/TechDraw_zh-TW.qm</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -17,5 +17,6 @@ namespace ZVALUE {
const int SECTIONLINE = 80; //TODO: change to "DECORATION"? section lines, symmetry lines, etc?
const int HIGHLIGHT = 80;
const int MATTING = 100;
const int LOCK = 200;
}
#endif