Fix #11 View Selection In Tree
This commit is contained in:
parent
bca002ff09
commit
efe10e0fb9
|
@ -128,8 +128,6 @@ SET(TechDrawGuiView_SRCS
|
|||
QGIViewSpreadsheet.h
|
||||
QGIViewClip.cpp
|
||||
QGIViewClip.h
|
||||
QGIHatch.cpp
|
||||
QGIHatch.h
|
||||
TemplateTextField.cpp
|
||||
TemplateTextField.h
|
||||
ZVALUE.h
|
||||
|
|
|
@ -353,102 +353,6 @@ int MDIViewPage::attachView(App::DocumentObject *obj)
|
|||
}
|
||||
|
||||
|
||||
// wf: this is never executed???
|
||||
void MDIViewPage::preSelectionChanged(const QPoint &pos)
|
||||
{
|
||||
QObject *obj = QObject::sender();
|
||||
|
||||
if(!obj)
|
||||
return;
|
||||
|
||||
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) {
|
||||
ss << "Edge" << edge->getProjIndex();
|
||||
//bool accepted =
|
||||
static_cast<void> (Gui::Selection().setPreselect(viewObj->getDocument()->getName()
|
||||
,viewObj->getNameInDocument()
|
||||
,ss.str().c_str()
|
||||
,pos.x()
|
||||
,pos.y()
|
||||
,0));
|
||||
} else if(vert) {
|
||||
ss << "Vertex" << vert->getProjIndex();
|
||||
//bool accepted =
|
||||
static_cast<void> (Gui::Selection().setPreselect(viewObj->getDocument()->getName()
|
||||
,viewObj->getNameInDocument()
|
||||
,ss.str().c_str()
|
||||
,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 {
|
||||
ss << "";
|
||||
Gui::Selection().setPreselect(viewObj->getDocument()->getName()
|
||||
,viewObj->getNameInDocument()
|
||||
,ss.str().c_str()
|
||||
,pos.x()
|
||||
,pos.y()
|
||||
,0);
|
||||
}
|
||||
}
|
||||
|
||||
void MDIViewPage::blockSelection(const bool state)
|
||||
{
|
||||
isSelectionBlocked = state;
|
||||
}
|
||||
|
||||
|
||||
void MDIViewPage::clearSelection()
|
||||
{
|
||||
blockSelection(true);
|
||||
std::vector<QGIView *> views = m_view->getViews();
|
||||
|
||||
// Iterate through all views and unselect all
|
||||
for (std::vector<QGIView *>::iterator it = views.begin(); it != views.end(); ++it) {
|
||||
QGIView *item = *it;
|
||||
item->setSelected(false);
|
||||
item->updateView();
|
||||
}
|
||||
|
||||
blockSelection(false);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
if(view) {
|
||||
view->setSelected(isSelected);
|
||||
view->updateView();
|
||||
}
|
||||
blockSelection(false);
|
||||
}
|
||||
|
||||
|
||||
void MDIViewPage::updateTemplate(bool forceUpdate)
|
||||
{
|
||||
|
@ -899,23 +803,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) {
|
||||
|
||||
}
|
||||
else if (msg.Type == Gui::SelectionChanges::AddSelection ||
|
||||
msg.Type == Gui::SelectionChanges::RmvSelection) {
|
||||
//bool select = (msg.Type == Gui::SelectionChanges::AddSelection);
|
||||
// Check if it is a view object
|
||||
}
|
||||
else if (msg.Type == Gui::SelectionChanges::SetSelection) {
|
||||
// do nothing here
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MDIViewPage::setFrameState(bool state)
|
||||
{
|
||||
m_frameState = state;
|
||||
|
@ -929,7 +816,6 @@ PyObject* MDIViewPage::getPyObject()
|
|||
Py_Return;
|
||||
}
|
||||
|
||||
|
||||
void MDIViewPage::setRenderer(QAction *action)
|
||||
{
|
||||
#ifndef QT_NO_OPENGL
|
||||
|
@ -971,6 +857,129 @@ void MDIViewPage::saveSVG()
|
|||
m_view->saveSvg(fn);
|
||||
}
|
||||
|
||||
|
||||
/////////////// Selection Routines ///////////////////
|
||||
// wf: this is never executed???
|
||||
// needs a signal from Scene? hoverEvent? Scene does not emit signal for "preselect"
|
||||
void MDIViewPage::preSelectionChanged(const QPoint &pos)
|
||||
{
|
||||
QObject *obj = QObject::sender();
|
||||
|
||||
if(!obj)
|
||||
return;
|
||||
|
||||
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) {
|
||||
ss << "Edge" << edge->getProjIndex();
|
||||
//bool accepted =
|
||||
static_cast<void> (Gui::Selection().setPreselect(viewObj->getDocument()->getName()
|
||||
,viewObj->getNameInDocument()
|
||||
,ss.str().c_str()
|
||||
,pos.x()
|
||||
,pos.y()
|
||||
,0));
|
||||
} else if(vert) {
|
||||
ss << "Vertex" << vert->getProjIndex();
|
||||
//bool accepted =
|
||||
static_cast<void> (Gui::Selection().setPreselect(viewObj->getDocument()->getName()
|
||||
,viewObj->getNameInDocument()
|
||||
,ss.str().c_str()
|
||||
,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 {
|
||||
ss << "";
|
||||
Gui::Selection().setPreselect(viewObj->getDocument()->getName()
|
||||
,viewObj->getNameInDocument()
|
||||
,ss.str().c_str()
|
||||
,pos.x()
|
||||
,pos.y()
|
||||
,0);
|
||||
}
|
||||
}
|
||||
|
||||
void MDIViewPage::blockSelection(const bool state)
|
||||
{
|
||||
isSelectionBlocked = state;
|
||||
}
|
||||
|
||||
|
||||
void MDIViewPage::clearSelection()
|
||||
{
|
||||
blockSelection(true);
|
||||
std::vector<QGIView *> views = m_view->getViews();
|
||||
|
||||
// Iterate through all views and unselect all
|
||||
for (std::vector<QGIView *>::iterator it = views.begin(); it != views.end(); ++it) {
|
||||
QGIView *item = *it;
|
||||
item->setSelected(false);
|
||||
item->updateView();
|
||||
}
|
||||
|
||||
blockSelection(false);
|
||||
}
|
||||
|
||||
//!Update QGVPage's selection based on Selection made outside Drawing Interace
|
||||
//invoked from VPP
|
||||
void MDIViewPage::selectFeature(App::DocumentObject *obj, const bool isSelected)
|
||||
{
|
||||
App::DocumentObject* objCopy = obj;
|
||||
TechDraw::DrawHatch* hatchObj = dynamic_cast<TechDraw::DrawHatch*>(objCopy);
|
||||
if (hatchObj) { //Hatch does not have a QGIV of it's own. mark parent as selected.
|
||||
objCopy = hatchObj->getSourceView(); //possible to highlight subObject?
|
||||
}
|
||||
QGIView *view = m_view->findView(objCopy);
|
||||
|
||||
blockSelection(true);
|
||||
if(view) {
|
||||
view->setSelected(isSelected);
|
||||
view->updateView();
|
||||
}
|
||||
blockSelection(false);
|
||||
}
|
||||
|
||||
//! invoked by selection change made in Tree?
|
||||
// wf: seems redundant? executed, but no real logic.
|
||||
void MDIViewPage::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
if (msg.Type == Gui::SelectionChanges::ClrSelection) {
|
||||
|
||||
}
|
||||
else if (msg.Type == Gui::SelectionChanges::AddSelection ||
|
||||
msg.Type == Gui::SelectionChanges::RmvSelection) {
|
||||
//bool add = (msg.Type == Gui::SelectionChanges::AddSelection);
|
||||
// Check if it is a view object
|
||||
std::string feat = msg.pObjectName;
|
||||
std::string sub = msg.pSubName;
|
||||
}
|
||||
else if (msg.Type == Gui::SelectionChanges::SetSelection) {
|
||||
// do nothing here wf: handled by VPP::onSelectionChanged?
|
||||
}
|
||||
}
|
||||
|
||||
//! update FC Selection from QGraphicsScene selection
|
||||
//trigged by m_view->scene() signal
|
||||
void MDIViewPage::selectionChanged()
|
||||
{
|
||||
|
@ -1004,6 +1013,9 @@ void MDIViewPage::selectionChanged()
|
|||
static_cast<void> (Gui::Selection().addSelection(viewObj->getDocument()->getName(),
|
||||
viewObj->getNameInDocument(),
|
||||
ss.str().c_str()));
|
||||
showStatusMsg(viewObj->getDocument()->getName(),
|
||||
viewObj->getNameInDocument(),
|
||||
ss.str().c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1025,6 +1037,9 @@ void MDIViewPage::selectionChanged()
|
|||
static_cast<void> (Gui::Selection().addSelection(viewObj->getDocument()->getName(),
|
||||
viewObj->getNameInDocument(),
|
||||
ss.str().c_str()));
|
||||
showStatusMsg(viewObj->getDocument()->getName(),
|
||||
viewObj->getNameInDocument(),
|
||||
ss.str().c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1046,6 +1061,9 @@ void MDIViewPage::selectionChanged()
|
|||
static_cast<void> (Gui::Selection().addSelection(viewObj->getDocument()->getName(),
|
||||
viewObj->getNameInDocument(),
|
||||
ss.str().c_str()));
|
||||
showStatusMsg(viewObj->getDocument()->getName(),
|
||||
viewObj->getNameInDocument(),
|
||||
ss.str().c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1073,6 +1091,10 @@ void MDIViewPage::selectionChanged()
|
|||
std::string obj_name = viewObj->getNameInDocument();
|
||||
|
||||
Gui::Selection().addSelection(doc_name.c_str(), obj_name.c_str());
|
||||
showStatusMsg(doc_name.c_str(),
|
||||
obj_name.c_str(),
|
||||
"");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1081,4 +1103,19 @@ void MDIViewPage::selectionChanged()
|
|||
blockSelection(false);
|
||||
} // end MDIViewPage::selectionChanged()
|
||||
|
||||
///////////////////end Selection Routines //////////////////////
|
||||
|
||||
void MDIViewPage::showStatusMsg(const char* s1, const char* s2, const char* s3) const
|
||||
{
|
||||
QString msg = QString::fromUtf8("Selected: ");
|
||||
msg.append(QObject::tr(" %1.%2.%3 ")
|
||||
.arg(QString::fromUtf8(s1))
|
||||
.arg(QString::fromUtf8(s2))
|
||||
.arg(QString::fromUtf8(s3))
|
||||
);
|
||||
if (Gui::getMainWindow()) {
|
||||
Gui::getMainWindow()->showMessage(msg,3000);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_MDIViewPage.cpp"
|
||||
|
|
|
@ -95,6 +95,7 @@ protected:
|
|||
void findPrinterSettings(const QString&);
|
||||
QPrinter::PageSize getPageSize(int w, int h) const;
|
||||
void setDimensionGroups(void);
|
||||
void showStatusMsg(const char* s1, const char* s2, const char* s3) const;
|
||||
|
||||
private:
|
||||
QAction *m_nativeAction;
|
||||
|
|
|
@ -1,183 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2015 WandererFan <wandererfan@gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <QPainterPathStroker>
|
||||
# include <QPainter>
|
||||
# include <strstream>
|
||||
# include <math.h>
|
||||
# include <QGraphicsPathItem>
|
||||
# include <QGraphicsTextItem>
|
||||
#endif
|
||||
|
||||
#include <QBitmap>
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
#include <QString>
|
||||
#include <QSvgRenderer>
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Material.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Parameter.h>
|
||||
#include <Gui/Command.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawHatch.h>
|
||||
#include <Mod/TechDraw/App/DrawViewPart.h>
|
||||
|
||||
#include "QGIView.h"
|
||||
#include "QGIHatch.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
QGIHatch::QGIHatch(std::string parentHatch) :
|
||||
m_hatch(parentHatch),
|
||||
m_fill(Qt::NoBrush),
|
||||
m_lastFill("")
|
||||
//m_fill(Qt::Dense3Pattern)
|
||||
//m_fill(Qt::CrossPattern)
|
||||
//m_fill(Qt::Dense6Pattern)
|
||||
{
|
||||
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");
|
||||
App::Color fcColor = App::Color((uint32_t) hGrp->GetUnsigned("NormalColor", 0x00000000));
|
||||
m_colNormal = fcColor.asValue<QColor>();
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("SelectColor", 0x0000FF00));
|
||||
m_colSel = fcColor.asValue<QColor>();
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("PreSelectColor", 0x00080800));
|
||||
m_colPre = fcColor.asValue<QColor>();
|
||||
|
||||
m_pen.setCosmetic(true);
|
||||
m_pen.setWidthF(1.);
|
||||
//m_pen.setStyle(Qt::NoPen);
|
||||
m_pen.setColor(m_colNormal);
|
||||
m_brush.setStyle(m_fill);
|
||||
setPrettyNormal();
|
||||
}
|
||||
|
||||
QGIHatch::~QGIHatch()
|
||||
{
|
||||
}
|
||||
|
||||
QVariant QGIHatch::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
if (change == ItemSelectedHasChanged && scene()) {
|
||||
if(isSelected()) {
|
||||
setPrettySel();
|
||||
} else {
|
||||
setPrettyNormal();
|
||||
}
|
||||
}
|
||||
return QGraphicsItem::itemChange(change, value);
|
||||
}
|
||||
|
||||
void QGIHatch::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
setPrettyPre();
|
||||
}
|
||||
|
||||
void QGIHatch::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
QGIView *view = dynamic_cast<QGIView *> (parentItem());
|
||||
|
||||
if(!isSelected() && !view->isSelected()) {
|
||||
setPrettyNormal();
|
||||
}
|
||||
}
|
||||
|
||||
void QGIHatch::setPrettyNormal()
|
||||
{
|
||||
m_pen.setColor(m_colNormal);
|
||||
m_brush.setColor(m_colNormal);
|
||||
setPen(m_pen);
|
||||
setBrush(m_brush);
|
||||
}
|
||||
|
||||
void QGIHatch::setPrettyPre()
|
||||
{
|
||||
m_pen.setColor(m_colPre);
|
||||
m_brush.setColor(m_colPre);
|
||||
setPen(m_pen);
|
||||
setBrush(m_brush);
|
||||
}
|
||||
|
||||
void QGIHatch::setPrettySel()
|
||||
{
|
||||
m_pen.setColor(m_colSel);
|
||||
m_brush.setColor(m_colSel);
|
||||
setPen(m_pen);
|
||||
setBrush(m_brush);
|
||||
}
|
||||
|
||||
void QGIHatch::setFill(std::string fillSpec)
|
||||
{
|
||||
if (fillSpec.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (fillSpec == m_lastFill) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString qs(QString::fromStdString(fillSpec));
|
||||
m_lastFill = fillSpec;
|
||||
//QString qs(QString::fromUtf8("../src/Mod/Drawing/patterns/simple.svg"));
|
||||
//QString qs(QString::fromUtf8("../src/Mod/Drawing/patterns/square.svg"));
|
||||
QSvgRenderer renderer(qs);
|
||||
//QBitmap pixMap(64,64); //this size is scene units (mm) instead of pixels?
|
||||
//QPixmap::fromImage(m_image);
|
||||
//QImage(qt_patternForBrush(style, 0), 8, 8, 1, QImage::Format_MonoLSB);
|
||||
//QPixmap::scaled(QSize,QTAspectmode,QTTransformmode)
|
||||
QBitmap pixMap(renderer.defaultSize());
|
||||
pixMap.fill(Qt::white); //try Qt::transparent?
|
||||
QPainter painter(&pixMap);
|
||||
renderer.render(&painter); //svg texture -> bitmap
|
||||
|
||||
m_texture = pixMap;
|
||||
m_brush = QBrush(m_texture);
|
||||
m_brush.setStyle(Qt::TexturePattern);
|
||||
//m_brush = QBrush(Qt::CrossPattern);
|
||||
//m_brush = QBrush(Qt::DiagCrossPattern);
|
||||
}
|
||||
|
||||
void QGIHatch::setColor(App::Color c)
|
||||
{
|
||||
m_colNormal = c.asValue<QColor>();
|
||||
}
|
||||
|
||||
void QGIHatch::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
|
||||
QStyleOptionGraphicsItem myOption(*option);
|
||||
myOption.state &= ~QStyle::State_Selected;
|
||||
painter->setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform ); //doesn't seem to change much
|
||||
setPen(m_pen);
|
||||
setBrush(m_brush);
|
||||
QGraphicsPathItem::paint (painter, &myOption, widget);
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2015 WandererFan <wandererfan@gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef DRAWINGGUI_QGRAPHICSITEMHATCH_H
|
||||
#define DRAWINGGUI_QGRAPHICSITEMHATCH_H
|
||||
|
||||
#include <Qt>
|
||||
#include <QGraphicsItem>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
#include <QBitmap>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QPainter;
|
||||
class QStyleOptionGraphicsItem;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace App {
|
||||
class Color;
|
||||
}
|
||||
|
||||
namespace TechDraw {
|
||||
class DrawHatch;
|
||||
}
|
||||
|
||||
namespace TechDrawGeometry {
|
||||
class BaseGeom;
|
||||
}
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
|
||||
class TechDrawGuiExport QGIHatch : public QGraphicsPathItem
|
||||
{
|
||||
|
||||
public:
|
||||
explicit QGIHatch(std::string parentHatch);
|
||||
~QGIHatch();
|
||||
|
||||
enum {Type = QGraphicsItem::UserType + 122};
|
||||
int type() const { return Type;}
|
||||
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||
|
||||
public:
|
||||
std::string getHatchName() const { return m_hatch; }
|
||||
void setPrettyNormal();
|
||||
void setPrettyPre();
|
||||
void setPrettySel();
|
||||
void setFill(std::string fillSpec);
|
||||
void setColor(App::Color c);
|
||||
|
||||
protected:
|
||||
// Preselection events:
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||
// Selection detection
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
||||
|
||||
protected:
|
||||
std::string m_hatch;
|
||||
|
||||
private:
|
||||
QPen m_pen;
|
||||
QBrush m_brush;
|
||||
QColor m_colNormal;
|
||||
QColor m_colPre;
|
||||
QColor m_colSel;
|
||||
QBitmap m_texture;
|
||||
Qt::BrushStyle m_fill;
|
||||
std::string m_lastFill;
|
||||
};
|
||||
|
||||
} // namespace MDIViewPageGui
|
||||
|
||||
#endif // DRAWINGGUI_QGRAPHICSITEMHATCH_H
|
|
@ -259,8 +259,7 @@ void QGIViewPart::updateView(bool update)
|
|||
for(QList<QGraphicsItem*>::iterator it = items.begin(); it != items.end(); ++it) {
|
||||
if (dynamic_cast<QGIEdge *> (*it) ||
|
||||
dynamic_cast<QGIFace *>(*it) ||
|
||||
dynamic_cast<QGIVertex *>(*it) ||
|
||||
dynamic_cast<QGIHatch *>(*it)) {
|
||||
dynamic_cast<QGIVertex *>(*it)) {
|
||||
removeFromGroup(*it);
|
||||
scene()->removeItem(*it);
|
||||
|
||||
|
@ -326,62 +325,6 @@ void QGIViewPart::drawViewPart()
|
|||
}
|
||||
#endif //#if MOD_TECHDRAW_HANDLE_FACES
|
||||
|
||||
#if 0
|
||||
// Draw Hatches
|
||||
std::vector<TechDraw::DrawHatch*> hatchObjs = viewPart->getHatches();
|
||||
if (!hatchObjs.empty()) {
|
||||
std::vector<TechDraw::DrawHatch*>::iterator itHatch = hatchObjs.begin();
|
||||
for(; itHatch != hatchObjs.end(); itHatch++) {
|
||||
//if hatchdirection == viewPartdirection {
|
||||
TechDraw::DrawHatch* feat = (*itHatch);
|
||||
const std::vector<std::string> &sourceNames = feat->Source.getSubValues();
|
||||
std::vector<TechDrawGeometry::BaseGeom*> unChained;
|
||||
if (TechDraw::DrawUtil::getGeomTypeFromName(sourceNames.at(0)) == "Face") {
|
||||
int idxFace = TechDraw::DrawUtil::getIndexFromName(sourceNames.at(0));
|
||||
unChained = viewPart->getProjFaceByIndex(idxFace);
|
||||
} else {
|
||||
std::vector<std::string>::const_iterator itEdge = sourceNames.begin();
|
||||
//get all edge geometries for this hatch
|
||||
for (; itEdge != sourceNames.end(); itEdge++) {
|
||||
int idxEdge = TechDraw::DrawUtil::getIndexFromName((*itEdge));
|
||||
TechDrawGeometry::BaseGeom* edgeGeom = viewPart->getProjEdgeByIndex(idxEdge);
|
||||
if (!edgeGeom) {
|
||||
Base::Console().Log("Error - qgivp::drawViewPart - edgeGeom: %d is NULL\n",idxEdge);
|
||||
}
|
||||
unChained.push_back(edgeGeom);
|
||||
}
|
||||
}
|
||||
|
||||
//chain edges tail to nose into a closed region
|
||||
auto chained( TechDrawGeometry::GeometryUtils::chainGeoms(unChained) );
|
||||
|
||||
//iterate through the chain to make QPainterPath
|
||||
std::vector<TechDrawGeometry::BaseGeom*>::iterator itChain = chained.begin();
|
||||
QPainterPath hatchPath;
|
||||
for (; itChain != chained.end(); itChain++) {
|
||||
QPainterPath subPath;
|
||||
if ((*itChain)->reversed) {
|
||||
subPath = drawPainterPath((*itChain)).toReversed();
|
||||
} else {
|
||||
subPath = drawPainterPath((*itChain));
|
||||
}
|
||||
hatchPath.connectPath(subPath);
|
||||
//_dumpPath("subpath",subPath);
|
||||
}
|
||||
|
||||
QGIHatch* hatch = new QGIHatch(feat->getNameInDocument());
|
||||
addToGroup(hatch);
|
||||
hatch->setPos(0.0,0.0);
|
||||
hatch->setPath(hatchPath);
|
||||
hatch->setFill(feat->HatchPattern.getValue());
|
||||
hatch->setColor(feat->HatchColor.getValue());
|
||||
//_dumpPath("hatchPath",hatchPath);
|
||||
hatch->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
hatch->setZValue(ZVALUE::HATCH);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Draw Edges
|
||||
const std::vector<TechDrawGeometry::BaseGeom *> &geoms = viewPart->getEdgeGeometry();
|
||||
std::vector<TechDrawGeometry::BaseGeom *>::const_iterator itEdge = geoms.begin();
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include "QGIFace.h"
|
||||
#include "QGIEdge.h"
|
||||
#include "QGIVertex.h"
|
||||
#include "QGIHatch.h"
|
||||
#include "../App/Geometry.h"
|
||||
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ namespace TechDrawGui
|
|||
class QGIView;
|
||||
class QGIViewDimension;
|
||||
class QGITemplate;
|
||||
class QGIHatch;
|
||||
|
||||
class TechDrawGuiExport QGVPage : public QGraphicsView
|
||||
{
|
||||
|
|
|
@ -270,33 +270,31 @@ void ViewProviderPage::onSelectionChanged(const Gui::SelectionChanges& msg)
|
|||
|
||||
for (std::vector<Gui::SelectionSingleton::SelObj>::iterator it = objs.begin(); it != objs.end(); ++it) {
|
||||
Gui::SelectionSingleton::SelObj selObj = *it;
|
||||
|
||||
if(selObj.pObject == getPageObject())
|
||||
continue;
|
||||
|
||||
std::string str = msg.pSubName;
|
||||
// If it's a subfeature, dont select feature
|
||||
if (!str.empty()) {
|
||||
if (TechDraw::DrawUtil::getGeomTypeFromName(str) == "Edge" ||
|
||||
if (TechDraw::DrawUtil::getGeomTypeFromName(str) == "Face" ||
|
||||
TechDraw::DrawUtil::getGeomTypeFromName(str) == "Edge" ||
|
||||
TechDraw::DrawUtil::getGeomTypeFromName(str) == "Vertex") {
|
||||
//TODO: handle Faces
|
||||
// TODO implement me
|
||||
} else {
|
||||
view->selectFeature(selObj.pObject, true);
|
||||
// TODO implement me wf: don't think this is ever executed
|
||||
}
|
||||
} else {
|
||||
view->selectFeature(selObj.pObject, true);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
bool selectState = (msg.Type == Gui::SelectionChanges::AddSelection) ? true : false;
|
||||
Gui::Document* doc = Gui::Application::Instance->getDocument(pcObject->getDocument());
|
||||
App::DocumentObject *obj = doc->getDocument()->getObject(msg.pObjectName);
|
||||
if(obj) {
|
||||
|
||||
std::string str = msg.pSubName;
|
||||
// If it's a subfeature, dont select feature
|
||||
if (!str.empty()) {
|
||||
if (TechDraw::DrawUtil::getGeomTypeFromName(str) == "Edge" ||
|
||||
if (TechDraw::DrawUtil::getGeomTypeFromName(str) == "Face" ||
|
||||
TechDraw::DrawUtil::getGeomTypeFromName(str) == "Edge" ||
|
||||
TechDraw::DrawUtil::getGeomTypeFromName(str) == "Vertex") {
|
||||
// TODO implement me
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user