Skip to content
Snippets Groups Projects
Commit 9005db57 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

Serious bug is fixed in SampleDesigner and MaskEditor which was making...

Serious bug is fixed in SampleDesigner and MaskEditor which was making application hanging in mac and slightly clumsy on Linux. Never put invalidate() in drawForeground().
parent b7b7ea3b
No related branches found
No related tags found
No related merge requests found
......@@ -325,7 +325,11 @@ void MaskGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
QGraphicsScene::mouseMoveEvent(event);
m_currentMousePosition = event->scenePos();
if( (isDrawingInProgress() && m_context.isPolygonMode()) || m_context.isLineMode()) {
m_currentMousePosition = event->scenePos();
invalidate();
}
}
//! Finalizes item drawing or pass events to other items
......@@ -354,32 +358,29 @@ void MaskGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
}
void MaskGraphicsScene::drawForeground(QPainter *painter, const QRectF &)
void MaskGraphicsScene::drawForeground(QPainter *painter, const QRectF &rect)
{
// if(PolygonView *polygon = getCurrentPolygon()) {
// painter->setPen(QPen(Qt::black, 1, Qt::DashLine));
// painter->drawLine(QLineF(polygon->getLastAddedPoint(), m_currentMousePosition));
// invalidate();
// } else {
// if(m_context.isLineMode()) {
// const QRectF &plot_scene_rectangle = m_adaptor->getViewportRectangle();
// if(!plot_scene_rectangle.contains(m_currentMousePosition)) return;
// painter->setPen(QPen(Qt::black, 1, Qt::DashLine));
// if(m_context.isVerticalLineMode()) {
// QPointF p1(m_currentMousePosition.x(), plot_scene_rectangle.bottom());
// QPointF p2(m_currentMousePosition.x(), plot_scene_rectangle.top());
// painter->drawLine(QLineF(p1, p2));
// }
// if(m_context.isHorizontalLineMode()) {
// QPointF p1(plot_scene_rectangle.left(), m_currentMousePosition.y());
// QPointF p2(plot_scene_rectangle.right(), m_currentMousePosition.y());
// painter->drawLine(QLineF(p1, p2));
// }
// invalidate();
// }
// }
if(PolygonView *polygon = getCurrentPolygon()) {
painter->setPen(QPen(Qt::black, 1, Qt::DashLine));
painter->drawLine(QLineF(polygon->getLastAddedPoint(), m_currentMousePosition));
} else {
if(m_context.isLineMode()) {
const QRectF &plot_scene_rectangle = m_adaptor->getViewportRectangle();
if(!plot_scene_rectangle.contains(m_currentMousePosition)) return;
painter->setPen(QPen(Qt::black, 1, Qt::DashLine));
if(m_context.isVerticalLineMode()) {
QPointF p1(m_currentMousePosition.x(), plot_scene_rectangle.bottom());
QPointF p2(m_currentMousePosition.x(), plot_scene_rectangle.top());
painter->drawLine(QLineF(p1, p2));
}
if(m_context.isHorizontalLineMode()) {
QPointF p1(plot_scene_rectangle.left(), m_currentMousePosition.y());
QPointF p2(plot_scene_rectangle.right(), m_currentMousePosition.y());
painter->drawLine(QLineF(p1, p2));
}
}
}
}
//! creates item context menu if there is IMaskView beneath the mouse right click
......@@ -735,10 +736,11 @@ PolygonView *MaskGraphicsScene::getCurrentPolygon() const
PolygonView *result(0);
if(isDrawingInProgress() && m_context.isPolygonMode()) {
if(m_currentItem) {
if(IMaskView *view = m_ItemToView[m_currentItem]) {
if(view->type() == MaskEditorHelper::POLYGON)
result = dynamic_cast<PolygonView *>(view);
}
// if(IMaskView *view = m_ItemToView[m_currentItem]) {
// if(view->type() == MaskEditorHelper::POLYGON)
// result = dynamic_cast<PolygonView *>(view);
// }
result = dynamic_cast<PolygonView *>(m_ItemToView[m_currentItem]);
}
}
return result;
......
......@@ -71,7 +71,7 @@ protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void drawForeground(QPainter *painter, const QRectF &);
void drawForeground(QPainter *painter, const QRectF &rect);
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
private:
......
......@@ -338,11 +338,9 @@ void DesignerScene::deleteSelectedItems()
//! shows appropriate layer interface to drop while moving ILayerView
void DesignerScene::drawForeground(QPainter *painter, const QRectF & /* rect */)
{
ILayerView *layer = dynamic_cast<ILayerView *>(mouseGrabberItem());
if (layer && !m_layer_interface_line.isNull()) {
if (isLayerDragged()) {
painter->setPen(QPen(Qt::darkBlue, 2, Qt::DashLine));
painter->drawLine(m_layer_interface_line);
invalidate();
}
}
......@@ -452,6 +450,14 @@ const DesignerMimeData *DesignerScene::checkDragEvent(QGraphicsSceneDragDropEven
return mimeData;
}
void DesignerScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if(isLayerDragged()) {
invalidate(); // to redraw vertical dashed line which denotes where to drag the layer
}
QGraphicsScene::mouseMoveEvent(event);
}
//! Returns true if there is MultiLayerView nearby during drag event.
bool DesignerScene::isMultiLayerNearby(QGraphicsSceneDragDropEvent *event)
{
......@@ -490,6 +496,15 @@ bool DesignerScene::isAcceptedByMultiLayer(const DesignerMimeData *mimeData, QGr
return false;
}
bool DesignerScene::isLayerDragged() const
{
ILayerView *layer = dynamic_cast<ILayerView *>(mouseGrabberItem());
if (layer && !m_layer_interface_line.isNull()) {
return true;
}
return false;
}
void DesignerScene::onSmartAlign()
{
m_aligner->smartAlign();
......
......@@ -82,6 +82,7 @@ public slots:
protected:
void drawForeground(QPainter* painter, const QRectF& rect);
const DesignerMimeData *checkDragEvent(QGraphicsSceneDragDropEvent * event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
private:
......@@ -93,6 +94,7 @@ private:
bool isMultiLayerNearby(QGraphicsSceneDragDropEvent *event);
void adjustSceneRect();
bool isAcceptedByMultiLayer(const DesignerMimeData *mimeData, QGraphicsSceneDragDropEvent *event);
bool isLayerDragged() const;
SampleModel *m_sampleModel;
InstrumentModel *m_instrumentModel;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment