Working Face selection

This commit is contained in:
WandererFan 2016-06-07 13:04:38 -04:00 committed by wmayer
parent f11e8ffa10
commit 6cec1df189
21 changed files with 252 additions and 135 deletions

View File

@ -19,6 +19,12 @@
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
/* *
* Some material based on Boost sample code */
// Distributed under the Boost Software License, Version 1.0. (See
// http://www.boost.org/LICENSE_1_0.txt)
//**************************************************************************
//#include "PreCompiled.h"

View File

@ -19,6 +19,11 @@
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
/*
* Some material based on Boost sample code */
// Distributed under the Boost Software License, Version 1.0. (See
// http://www.boost.org/LICENSE_1_0.txt)
//**************************************************************************
#ifndef TECHDRAW_EDGEWALKER_H
#define TECHDRAW_EDGEWALKER_H

View File

@ -128,7 +128,7 @@ MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget*
m_view, SLOT(setHighQualityAntialiasing(bool)));
#endif
isSlectionBlocked = false;
isSelectionBlocked = false;
QActionGroup *rendererGroup = new QActionGroup(this);
rendererGroup->addAction(m_nativeAction);
@ -353,6 +353,7 @@ int MDIViewPage::attachView(App::DocumentObject *obj)
}
// wf: this is never executed???
void MDIViewPage::preSelectionChanged(const QPoint &pos)
{
QObject *obj = QObject::sender();
@ -360,22 +361,21 @@ void MDIViewPage::preSelectionChanged(const QPoint &pos)
if(!obj)
return;
// Check if an edge was preselected
auto view( dynamic_cast<QGIView *>(obj) );
if(!view)
return;
QGraphicsItem* parent = view->parentItem();
if(!parent)
return;
TechDraw::DrawView *viewObj = view->getViewObject();
std::stringstream ss;
QGIFace *face = dynamic_cast<QGIFace *>(obj);
QGIEdge *edge = dynamic_cast<QGIEdge *>(obj);
QGIVertex *vert = dynamic_cast<QGIVertex *>(obj);
if(edge) {
// Find the parent view that this edges is contained within
QGraphicsItem*parent = edge->parentItem();
if(!parent)
return;
QGIView *viewItem = dynamic_cast<QGIView *>(parent);
if(!viewItem)
return;
TechDraw::DrawView *viewObj = viewItem->getViewObject();
std::stringstream ss;
ss << "Edge" << edge->getProjIndex();
//bool accepted =
static_cast<void> (Gui::Selection().setPreselect(viewObj->getDocument()->getName()
@ -384,18 +384,7 @@ void MDIViewPage::preSelectionChanged(const QPoint &pos)
,pos.x()
,pos.y()
,0));
} else if(vert) {
QGraphicsItem*parent = vert->parentItem();
if(!parent)
return;
QGIView *viewItem = dynamic_cast<QGIView *>(parent);
if(!viewItem)
return;
TechDraw::DrawView *viewObj = viewItem->getViewObject();
std::stringstream ss;
ss << "Vertex" << vert->getProjIndex();
//bool accepted =
static_cast<void> (Gui::Selection().setPreselect(viewObj->getDocument()->getName()
@ -404,25 +393,29 @@ void MDIViewPage::preSelectionChanged(const QPoint &pos)
,pos.x()
,pos.y()
,0));
} else if(face) {
ss << "Face" << face->getProjIndex(); //TODO: SectionFaces have ProjIndex = -1. (but aren't selectable?) Problem?
//bool accepted =
static_cast<void> (Gui::Selection().setPreselect(viewObj->getDocument()->getName()
,viewObj->getNameInDocument()
,ss.str().c_str()
,pos.x()
,pos.y()
,0));
} else {
auto view( dynamic_cast<QGIView *>(obj) );
if(!view)
return;
TechDraw::DrawView *viewObj = view->getViewObject();
ss << "";
Gui::Selection().setPreselect(viewObj->getDocument()->getName()
,viewObj->getNameInDocument()
,""
,ss.str().c_str()
,pos.x()
,pos.y()
,0);
}
}
void MDIViewPage::blockSelection(const bool state)
{
isSlectionBlocked = state;
isSelectionBlocked = state;
}
@ -445,6 +438,7 @@ void MDIViewPage::clearSelection()
void MDIViewPage::selectFeature(App::DocumentObject *obj, const bool isSelected)
{
// Update QGVPage's selection based on Selection made outside Drawing Interace
// wf: but this also executes for changes within the Drawing Interface?
QGIView *view = m_view->findView(obj);
blockSelection(true);
@ -480,11 +474,8 @@ void MDIViewPage::updateTemplate(bool forceUpdate)
}
}
}
// m_view->setPageFeature(pageFeature); redundant
}
void MDIViewPage::updateDrawing(bool forceUpdate)
{
// We cannot guarantee if the number of graphical representations (QGIVxxxx) have changed so check the number
@ -909,7 +900,6 @@ QPrinter::PageSize MDIViewPage::getPageSize(int w, int h) const
return ps;
}
void MDIViewPage::onSelectionChanged(const Gui::SelectionChanges& msg)
{
if (msg.Type == Gui::SelectionChanges::ClrSelection) {
@ -981,57 +971,51 @@ void MDIViewPage::saveSVG()
m_view->saveSvg(fn);
}
//trigged by m_view->scene() signal
void MDIViewPage::selectionChanged()
{
if(isSlectionBlocked)
if(isSelectionBlocked) {
return;
}
QList<QGraphicsItem*> selection = m_view->scene()->selectedItems();
bool block = blockConnection(true); // avoid to be notified by itself
bool saveBlock = blockConnection(true); // avoid to be notified by itself
blockSelection(true);
Gui::Selection().clearSelection();
for (QList<QGraphicsItem*>::iterator it = selection.begin(); it != selection.end(); ++it) {
// All selectable items must be of QGIView type
QGIView *itemView = dynamic_cast<QGIView *>(*it);
if(itemView == 0) {
QGIEdge *edge = dynamic_cast<QGIEdge *>(*it);
if(edge) {
// Find the parent view that this edges is contained within
QGraphicsItem*parent = edge->parentItem();
if(!parent)
return;
continue;
QGIView *viewItem = dynamic_cast<QGIView *>(parent);
if(!viewItem)
return;
continue;
TechDraw::DrawView *viewObj = viewItem->getViewObject();
std::stringstream ss;
//ss << "Edge" << edge->getReference();
ss << "Edge" << edge->getProjIndex();
//bool accepted =
static_cast<void> (Gui::Selection().addSelection(viewObj->getDocument()->getName(),
viewObj->getNameInDocument(),
ss.str().c_str()));
//Base::Console().Message("TRACE - MDIVP::selectionChanged - selection: %s\n",ss.str().c_str());
continue;
}
QGIVertex *vert = dynamic_cast<QGIVertex *>(*it);
if(vert) {
// Find the parent view that this edges is contained within
//WF: sb Vertex
QGraphicsItem*parent = vert->parentItem();
if(!parent)
return;
continue;
QGIView *viewItem = dynamic_cast<QGIView *>(parent);
if(!viewItem)
return;
continue;
TechDraw::DrawView *viewObj = viewItem->getViewObject();
@ -1041,31 +1025,46 @@ void MDIViewPage::selectionChanged()
static_cast<void> (Gui::Selection().addSelection(viewObj->getDocument()->getName(),
viewObj->getNameInDocument(),
ss.str().c_str()));
continue;
}
QGIFace *face = dynamic_cast<QGIFace *>(*it);
if(face) {
QGraphicsItem*parent = face->parentItem();
if(!parent)
continue;
QGIView *viewItem = dynamic_cast<QGIView *>(parent);
if(!viewItem)
continue;
TechDraw::DrawView *viewObj = viewItem->getViewObject();
std::stringstream ss;
ss << "Face" << face->getProjIndex();
//bool accepted =
static_cast<void> (Gui::Selection().addSelection(viewObj->getDocument()->getName(),
viewObj->getNameInDocument(),
ss.str().c_str()));
continue;
}
QGIDatumLabel *dimLabel = dynamic_cast<QGIDatumLabel*>(*it);
if(dimLabel) {
// Find the parent view (dimLabel->dim->view)
QGraphicsItem*dimParent = dimLabel->parentItem();
if(!dimParent)
return;
continue;
QGIView *dimItem = dynamic_cast<QGIView *>(dimParent);
if(!dimItem)
return;
continue;
TechDraw::DrawView *dimObj = dimItem->getViewObject();
//bool accepted =
static_cast<void> (Gui::Selection().addSelection(dimObj->getDocument()->getName(),dimObj->getNameInDocument()));
}
continue;
} else {
TechDraw::DrawView *viewObj = itemView->getViewObject();
@ -1078,7 +1077,8 @@ void MDIViewPage::selectionChanged()
}
blockConnection(block);
blockConnection(saveBlock);
blockSelection(false);
} // end MDIViewPage::selectionChanged()
#include "moc_MDIViewPage.cpp"

View File

@ -106,7 +106,7 @@ private:
QAction *m_outlineAction;
std::string m_objectName;
bool isSlectionBlocked;
bool isSelectionBlocked;
QGVPage *m_view;
QString m_currentPath;

View File

@ -44,6 +44,9 @@ using namespace TechDrawGui;
QGCustomBorder::QGCustomBorder()
{
setCacheMode(QGraphicsItem::NoCache);
setAcceptHoverEvents(false);
setFlag(QGraphicsItem::ItemIsSelectable, false);
setFlag(QGraphicsItem::ItemIsMovable, false);
}
void QGCustomBorder::centerAt(QPointF centerPos)

View File

@ -47,6 +47,9 @@ using namespace TechDrawGui;
QGCustomLabel::QGCustomLabel()
{
setCacheMode(QGraphicsItem::NoCache);
setAcceptHoverEvents(false);
setFlag(QGraphicsItem::ItemIsSelectable, false);
setFlag(QGraphicsItem::ItemIsMovable, false);
}
void QGCustomLabel::centerAt(QPointF centerPos)

View File

@ -44,6 +44,9 @@ using namespace TechDrawGui;
QGCustomRect::QGCustomRect()
{
setCacheMode(QGraphicsItem::NoCache);
setAcceptHoverEvents(false);
setFlag(QGraphicsItem::ItemIsSelectable, false);
setFlag(QGraphicsItem::ItemIsMovable, false);
}
void QGCustomRect::centerAt(QPointF centerPos)

View File

@ -34,6 +34,9 @@ using namespace TechDrawGui;
QGCustomSvg::QGCustomSvg()
{
setCacheMode(QGraphicsItem::NoCache);
setAcceptHoverEvents(false);
setFlag(QGraphicsItem::ItemIsSelectable, false);
setFlag(QGraphicsItem::ItemIsMovable, false);
}
void QGCustomSvg::centerAt(QPointF centerPos)

View File

@ -47,6 +47,9 @@ using namespace TechDrawGui;
QGCustomText::QGCustomText()
{
setCacheMode(QGraphicsItem::NoCache);
setAcceptHoverEvents(false);
setFlag(QGraphicsItem::ItemIsSelectable, false);
setFlag(QGraphicsItem::ItemIsMovable, false);
}
void QGCustomText::centerAt(QPointF centerPos)

View File

@ -47,7 +47,9 @@ QGIArrow::QGIArrow(QGraphicsScene *scene)
// Set Cache Mode
setCacheMode(QGraphicsItem::NoCache);
setAcceptHoverEvents(false);
setFlag(QGraphicsItem::ItemIsSelectable, false);
setFlag(QGraphicsItem::ItemIsMovable, false);
}
QPainterPath QGIArrow::shape() const

View File

@ -47,6 +47,7 @@ QGIEdge::QGIEdge(int index) :
{
setCacheMode(QGraphicsItem::NoCache);
setFlag(QGraphicsItem::ItemIsSelectable, true);
setFlag(QGraphicsItem::ItemIsMovable, false);
setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true);
setFlag(QGraphicsItem::ItemSendsGeometryChanges,true);
setAcceptHoverEvents(true);
@ -54,6 +55,7 @@ QGIEdge::QGIEdge(int index) :
strokeWidth = 1.;
isCosmetic = false;
m_pen.setCosmetic(isCosmetic);
isHighlighted = false;
isHiddenEdge = false;
isSmoothEdge = false;
@ -76,7 +78,6 @@ QGIEdge::QGIEdge(int index) :
m_pen.setStyle(Qt::SolidLine);
m_pen.setCapStyle(Qt::RoundCap);
m_pen.setCosmetic(isCosmetic);
setPrettyNormal();
}
@ -109,7 +110,9 @@ QVariant QGIEdge::itemChange(GraphicsItemChange change, const QVariant &value)
void QGIEdge::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
setPrettyPre();
if (!isSelected()) {
setPrettyPre();
}
QGraphicsPathItem::hoverEnterEvent(event);
}
@ -117,7 +120,6 @@ void QGIEdge::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
QGIView *view = dynamic_cast<QGIView *> (parentItem()); //this is temp for debug??
assert(view != 0);
if(!isSelected() && !isHighlighted) {
setPrettyNormal();
}
@ -130,6 +132,7 @@ void QGIEdge::setCosmetic(bool state)
update();
}
// obs?
void QGIEdge::setHighlighted(bool b)
{
isHighlighted = b;

View File

@ -43,15 +43,21 @@
using namespace TechDrawGui;
QGIFace::QGIFace(int ref) :
reference(ref),
m_fill(Qt::NoBrush)
//m_fill(Qt::CrossPattern)
//m_fill(Qt::Dense3Pattern)
QGIFace::QGIFace(int index) :
projIndex(index),
m_colDefFill(Qt::white), //Qt::transparent? paper colour?
m_styleDef(Qt::SolidPattern),
m_styleSelect(Qt::SolidPattern)
{
setCacheMode(QGraphicsItem::NoCache);
setFlag(QGraphicsItem::ItemIsSelectable, true);
setFlag(QGraphicsItem::ItemIsMovable, false);
setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true);
setFlag(QGraphicsItem::ItemSendsGeometryChanges,true);
setAcceptHoverEvents(true);
isHighlighted = false;
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
App::Color fcColor = App::Color((uint32_t) hGrp->GetUnsigned("NormalColor", 0x00000000));
@ -61,15 +67,21 @@ QGIFace::QGIFace(int ref) :
fcColor.setPackedValue(hGrp->GetUnsigned("PreSelectColor", 0x00080800));
m_colPre = fcColor.asValue<QColor>();
//m_pen.setStyle(Qt::NoPen);
m_brush.setStyle(m_fill);
m_pen.setCosmetic(true);
m_pen.setColor(m_colNormal);
m_colNormalFill = m_colDefFill;
m_brush.setColor(m_colDefFill);
m_styleNormal = m_styleDef;
m_brush.setStyle(m_styleDef);
setPrettyNormal();
}
QVariant QGIFace::itemChange(GraphicsItemChange change, const QVariant &value)
{
if (change == ItemSelectedHasChanged && scene()) {
if(isSelected()) {
if(isSelected()) { //this is only QtGui Selected, not FC selected?
setPrettySel();
} else {
setPrettyNormal();
@ -80,46 +92,96 @@ QVariant QGIFace::itemChange(GraphicsItemChange change, const QVariant &value)
void QGIFace::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
setPrettyPre();
if (!isSelected() && !isHighlighted) {
setPrettyPre();
}
QGraphicsPathItem::hoverEnterEvent(event);
}
void QGIFace::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
QGIView *view = dynamic_cast<QGIView *> (parentItem());
if (!isSelected()) {
setPrettyNormal();
}
QGraphicsPathItem::hoverLeaveEvent(event);
}
if(!isSelected() && !view->isSelected()) {
void QGIFace::mousePressEvent(QGraphicsSceneMouseEvent * event)
{
QGraphicsItem::mousePressEvent(event);
}
void QGIFace::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
{
QGraphicsItem::mouseReleaseEvent(event);
}
void QGIFace::setPrettyNormal() {
m_colCurrent = m_colNormal;
m_colCurrFill = m_colNormalFill;
m_styleCurr = m_styleNormal;
update();
}
void QGIFace::setPrettyPre() {
m_colCurrent = m_colPre;
m_colCurrFill = m_colPre;
m_styleCurr = m_styleSelect;
update();
}
void QGIFace::setPrettySel() {
m_colCurrent = m_colSel;
m_colCurrFill = m_colSel;
m_styleCurr = m_styleSelect;
update();
}
void QGIFace::setHighlighted(bool b)
{
isHighlighted = b;
if(isHighlighted && isSelected()) {
setPrettySel();
} else if (isHighlighted) {
setPrettyPre();
} else {
setPrettyNormal();
}
}
void QGIFace::setPrettyNormal() {
m_pen.setColor(m_colNormal);
//m_brush.setColor(m_colNormal);
setPen(m_pen);
//setBrush(m_brush);
void QGIFace::setFill(QColor c, Qt::BrushStyle s) {
m_colNormalFill = c;
m_styleCurr = s;
}
void QGIFace::setPrettyPre() {
m_pen.setColor(m_colPre);
//m_brush.setColor(m_colPre);
setPen(m_pen);
//setBrush(m_brush);
void QGIFace::setFill(QBrush b) {
m_colNormalFill = b.color();
m_styleCurr = b.style();
}
void QGIFace::setPrettySel() {
m_pen.setColor(m_colSel);
//m_brush.setColor(m_colSel);
setPen(m_pen);
//setBrush(m_brush);
void QGIFace::resetFill() {
m_colNormalFill = m_colDefFill;
m_styleCurr = m_styleDef;
}
QRectF QGIFace::boundingRect() const
{
return shape().controlPointRect();
}
QPainterPath QGIFace::shape() const
{
return path();
}
void QGIFace::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
QStyleOptionGraphicsItem myOption(*option);
//myOption.state &= ~QStyle::State_Selected; //commented for debugging
myOption.state &= ~QStyle::State_Selected;
//m_pen.setColor(m_colCurrent);
//setPen(m_pen);
//m_brush.setStyle(m_fill);
m_pen.setColor(m_colCurrent);
setPen(m_pen);
m_brush.setStyle(m_styleCurr);
m_brush.setColor(m_colCurrFill);
setBrush(m_brush);
QGraphicsPathItem::paint (painter, &myOption, widget);
}

View File

@ -41,19 +41,27 @@ namespace TechDrawGui
class QGIFace : public QGraphicsPathItem
{
public:
explicit QGIFace(int ref = -1);
explicit QGIFace(int index = -1);
~QGIFace() {}
enum {Type = QGraphicsItem::UserType + 104};
int type() const { return Type;}
QRectF boundingRect() const;
QPainterPath shape() const;
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
public:
// QPainterPath shape() const;
int getReference() const { return reference; }
int getProjIndex() const { return projIndex; }
void setHighlighted(bool state);
void setPrettyNormal();
void setPrettyPre();
void setPrettySel();
void setFill(QColor c, Qt::BrushStyle s);
void setFill(QBrush b);
void resetFill(void);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * event);
protected:
// Preselection events:
@ -61,9 +69,11 @@ protected:
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
// Selection detection
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
virtual void mousePressEvent(QGraphicsSceneMouseEvent * event);
protected:
int reference;
int projIndex; //index of face in Projection. -1 for SectionFace.
bool isHighlighted;
private:
QPen m_pen;
@ -71,9 +81,17 @@ private:
QColor m_colNormal;
QColor m_colPre;
QColor m_colSel;
Qt::BrushStyle m_fill;
QColor m_colCurrent;
QColor m_defNormal; //pen default normal color
QColor m_colDefFill; //"no color"
QColor m_colCurrFill; //current color
QColor m_colNormalFill;
Qt::BrushStyle m_styleDef; //default Normal fill fill style
Qt::BrushStyle m_styleCurr; //current fill style
Qt::BrushStyle m_styleNormal; //Normal fill style
Qt::BrushStyle m_styleSelect; //Select/preSelect fill style
};
} // namespace MDIViewPageGui
}
#endif // DRAWINGGUI_QGRAPHICSITEMFACE_H

View File

@ -59,10 +59,12 @@ QGIHatch::QGIHatch(std::string parentHatch) :
//m_fill(Qt::CrossPattern)
//m_fill(Qt::Dense6Pattern)
{
setHandlesChildEvents(false);
setFlag(QGraphicsItem::ItemIsMovable, false);
setAcceptHoverEvents(true);
setCacheMode(QGraphicsItem::NoCache);
setFlag(QGraphicsItem::ItemIsSelectable, true);
setFlag(QGraphicsItem::ItemIsMovable, false);
setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true);
setFlag(QGraphicsItem::ItemSendsGeometryChanges,true);
setAcceptHoverEvents(true);
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");

View File

@ -40,7 +40,6 @@ namespace TechDrawGui
class TechDrawGuiExport QGIVertex : public QGraphicsEllipseItem
{
public:
//explicit QGIVertex(int ref = -1);
explicit QGIVertex(int index);
~QGIVertex() {}

View File

@ -66,10 +66,14 @@ QGIView::QGIView()
borderVisible(true),
m_innerView(false)
{
setFlag(QGraphicsItem::ItemIsSelectable,true);
setCacheMode(QGraphicsItem::NoCache);
setHandlesChildEvents(false);
setAcceptHoverEvents(true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true);
setFlag(QGraphicsItem::ItemSendsGeometryChanges,true);
setAcceptHoverEvents(true);
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
@ -188,12 +192,12 @@ void QGIView::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
void QGIView::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
// TODO don't like this but only solution at the minute
// TODO don't like this but only solution at the minute (MLP)
if (isSelected()) {
m_colCurrent = m_colSel;
} else {
m_colCurrent = m_colPre;
//if(shape().contains(event->pos())) { // TODO don't like this for determining preselect
//if(shape().contains(event->pos())) { // TODO don't like this for determining preselect (MLP)
// m_colCurrent = m_colPre;
//}
}
@ -382,4 +386,3 @@ void _debugRect(char* text, QRectF r) {
Base::Console().Message("TRACE - %s - rect: (%.3f,%.3f) x (%.3f,%.3f)\n",text,
r.left(),r.top(),r.right(),r.bottom());
}

View File

@ -57,10 +57,10 @@ using namespace TechDrawGui;
QGIViewAnnotation::QGIViewAnnotation()
{
setHandlesChildEvents(false);
setCacheMode(QGraphicsItem::NoCache);
setAcceptHoverEvents(true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
setFlag(QGraphicsItem::ItemIsMovable, true);
setAcceptHoverEvents(true);
m_textItem = new QGCustomText();
m_textItem->setTextInteractionFlags(Qt::NoTextInteraction);

View File

@ -62,10 +62,15 @@ const float vertexScaleFactor = 2.; // temp fiddle for devel
QGIViewPart::QGIViewPart()
{
setHandlesChildEvents(false);
setCacheMode(QGraphicsItem::NoCache);
setHandlesChildEvents(false);
setAcceptHoverEvents(true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true);
setFlag(QGraphicsItem::ItemSendsGeometryChanges,true);
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Drawing/Colors");
@ -83,12 +88,16 @@ QVariant QGIViewPart::itemChange(GraphicsItemChange change, const QVariant &valu
if (change == ItemSelectedHasChanged && scene()) {
QList<QGraphicsItem*> items = childItems();
for(QList<QGraphicsItem*>::iterator it = items.begin(); it != items.end(); ++it) {
//Highlight the children if this is highlighted!? seems to mess up Face selection?
QGIEdge *edge = dynamic_cast<QGIEdge *>(*it);
QGIVertex *vert = dynamic_cast<QGIVertex *>(*it);
QGIFace *face = dynamic_cast<QGIFace *>(*it);
if(edge) {
edge->setHighlighted(isSelected());
//edge->setHighlighted(isSelected());
} else if(vert){
vert->setHighlighted(isSelected());
//vert->setHighlighted(isSelected());
} else if(face){
//face->setHighlighted(isSelected());
}
}
} else if(change == ItemSceneChange && scene()) {
@ -238,6 +247,7 @@ void QGIViewPart::updateView(bool update)
viewPart->Scale.isTouched() ||
viewPart->ShowHiddenLines.isTouched()) {
// Remove all existing graphical representations (QGIxxxx) otherwise BRect only grows, never shrinks?
// is this where selection messes up?
prepareGeometryChange();
QList<QGraphicsItem*> items = childItems();
for(QList<QGraphicsItem*>::iterator it = items.begin(); it != items.end(); ++it) {
@ -292,15 +302,12 @@ void QGIViewPart::drawViewPart()
// Draw Faces
const std::vector<TechDrawGeometry::Face *> &faceGeoms = viewPart->getFaceGeometry();
std::vector<TechDrawGeometry::Face *>::const_iterator fit = faceGeoms.begin();
QPen facePen;
facePen.setCosmetic(true);
//QBrush faceBrush;
for(int i = 0 ; fit != faceGeoms.end(); fit++, i++) {
QGIFace* newFace = drawFace(*fit,i);
newFace->setPen(facePen);
newFace->setZValue(ZVALUE::FACE);
newFace->setFlag(QGraphicsItem::ItemIsSelectable, true);
//newFace->setBrush(faceBrush);
newFace->setAcceptHoverEvents(true);
newFace->setPrettyNormal();
}
#endif //#if MOD_TECHDRAW_HANDLE_FACES
@ -635,4 +642,3 @@ void _dumpPath(const char* text,QPainterPath path)
elem.type,typeName,elem.x,elem.y,elem.isMoveTo(),elem.isLineTo(),elem.isCurveTo());
}
}

View File

@ -67,8 +67,6 @@ void QGIViewSection::drawSectionFace()
return;
}
//Base::Console().Log("drawing section face\n");
std::vector<TechDrawGeometry::Face*> sectionFaces;
sectionFaces = section->getFaceGeometry();
if (sectionFaces.empty()) {
@ -76,21 +74,18 @@ void QGIViewSection::drawSectionFace()
return;
}
std::vector<TechDrawGeometry::Face *>::iterator fit = sectionFaces.begin();
QPen facePen;
facePen.setCosmetic(true);
QBrush faceBrush(QBrush(QColor(0,0,255,40))); //temp. sb preference or property.
QColor faceColor(0,0,255,40); //temp. sb preference or property.
for(; fit != sectionFaces.end(); fit++) {
QGIFace* newFace = drawFace(*fit,-1);
QGIFace* newFace = drawFace(*fit,-1); //TODO: do we need to know which sectionFace this QGIFace came from?
newFace->setZValue(ZVALUE::SECTIONFACE);
newFace->setBrush(faceBrush);
newFace->setPen(facePen);
//newFace->setEyeCandy()
newFace->setFill(faceColor, Qt::SolidPattern);
newFace->setFlag(QGraphicsItem::ItemIsSelectable, false);
newFace->setAcceptHoverEvents(false);
}
}
void QGIViewSection::updateView(bool update)
{
// Iterate
if(getViewObject() == 0 || !getViewObject()->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId()))
return;
@ -104,4 +99,3 @@ void QGIViewSection::updateView(bool update)
QGIViewPart::updateView();
}
}

View File

@ -35,6 +35,7 @@ QGIViewSpreadsheet::QGIViewSpreadsheet()
setCacheMode(QGraphicsItem::NoCache);
setAcceptHoverEvents(true);
setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
}

View File

@ -51,6 +51,7 @@ QGIViewSymbol::QGIViewSymbol()
setCacheMode(QGraphicsItem::NoCache);
setAcceptHoverEvents(true);
setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
m_svgRender = new QSvgRenderer();