[TD]dialog for Detail #4221

This commit is contained in:
wandererfan
2020-04-07 11:30:57 -04:00
committed by WandererFan
parent bbea2dbb7c
commit b44044f95b
18 changed files with 2813 additions and 1424 deletions

View File

@@ -570,6 +570,13 @@ Base::Vector3d DrawUtil::invertY(Base::Vector3d v)
return result;
}
QPointF DrawUtil::invertY(QPointF v)
{
QPointF result(v.x(), -v.y());
return result;
}
//obs? was used in CSV prototype of Cosmetics
std::vector<std::string> DrawUtil::split(std::string csvLine)
{

View File

@@ -110,6 +110,7 @@ class TechDrawExport DrawUtil {
static std::string shapeToString(TopoDS_Shape s);
static TopoDS_Shape shapeFromString(std::string s);
static Base::Vector3d invertY(Base::Vector3d v);
static QPointF invertY(QPointF p);
static std::vector<std::string> split(std::string csvLine);
static std::vector<std::string> tokenize(std::string csvLine, std::string delimiter = ",$$$,");
static App::Color pyTupleToColor(PyObject* pColor);

View File

@@ -100,8 +100,6 @@ using namespace std;
PROPERTY_SOURCE(TechDraw::DrawViewDetail, TechDraw::DrawViewPart)
DrawViewDetail::DrawViewDetail()
// :
// m_mattingStyle(0)
{
static const char *dgroup = "Detail";

View File

@@ -70,6 +70,8 @@ set(TechDrawGui_MOC_HDRS
QGIWeldSymbol.h
SymbolChooser.h
TaskActiveView.h
TaskDetail.h
QGIGhostHighlight.h
)
fc_wrap_cpp(TechDrawGui_MOC_SRCS ${TechDrawGui_MOC_HDRS})
@@ -103,6 +105,7 @@ set(TechDrawGui_UIC_SRCS
TaskWeldingSymbol.ui
SymbolChooser.ui
TaskActiveView.ui
TaskDetail.ui
)
if(BUILD_QT5)
@@ -203,6 +206,9 @@ SET(TechDrawGui_SRCS
TaskActiveView.h
Grabber3d.cpp
Grabber3d.h
TaskDetail.ui
TaskDetail.cpp
TaskDetail.h
)
SET(TechDrawGuiView_SRCS
@@ -299,6 +305,8 @@ SET(TechDrawGuiView_SRCS
TemplateTextField.cpp
TemplateTextField.h
ZVALUE.h
QGIGhostHighlight.cpp
QGIGhostHighlight.h
)
SET(TechDrawGuiViewProvider_SRCS
ViewProviderPage.cpp
@@ -366,6 +374,7 @@ SET(TechDrawGuiTaskDlgs_SRCS
TaskWeldingSymbol.ui
SymbolChooser.ui
TaskActiveView.ui
TaskDetail.ui
)
SOURCE_GROUP("TaskDialogs" FILES ${TechDrawGuiTaskDlgs_SRCS})

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,115 @@
/***************************************************************************
* Copyright (c) 2020 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 <QPainter>
#include <QPainterPathStroker>
#include <QStyleOptionGraphicsItem>
#include <QPen>
#include <QColor>
#endif
#include <App/Application.h>
#include <App/Material.h>
#include <Base/Console.h>
#include <Base/Parameter.h>
#include <Mod/TechDraw/App/DrawUtil.h>
#include <qmath.h>
#include "Rez.h"
#include "DrawGuiUtil.h"
#include "QGIView.h"
#include "QGIGhostHighlight.h"
using namespace TechDrawGui;
using namespace TechDraw;
QGIGhostHighlight::QGIGhostHighlight()
{
setInteractive(true);
m_dragging = false;
//make the ghost very visible
QFont f(QGIView::getPrefFont());
double fontSize = QGIView::getPrefFontSize();
setFont(f, fontSize);
setReference("drag");
setStyle(Qt::SolidLine);
setColor(prefSelectColor());
setWidth(Rez::guiX(1.0));
setRadius(10.0); //placeholder
}
QGIGhostHighlight::~QGIGhostHighlight()
{
}
QVariant QGIGhostHighlight::itemChange(GraphicsItemChange change, const QVariant &value)
{
if (change == ItemPositionHasChanged && scene()) {
// nothing to do here?
}
return QGIHighlight::itemChange(change, value);
}
void QGIGhostHighlight::mousePressEvent(QGraphicsSceneMouseEvent * event)
{
// Base::Console().Message("QGIGhostHighlight::mousePress() - %X\n", this);
if ( (event->button() == Qt::LeftButton) &&
(flags() && QGraphicsItem::ItemIsMovable) ) {
m_dragging = true;
event->accept();
}
QGIHighlight::mousePressEvent(event);
}
void QGIGhostHighlight::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
{
// Base::Console().Message("QGIGhostHighlight::mouseRelease() - pos: %s scenePos: %s\n",
// DrawUtil::formatVector(pos()).c_str(),
// DrawUtil::formatVector(mapToScene(pos())).c_str());
if (m_dragging) {
m_dragging = false;
Q_EMIT positionChange(scenePos());
event->accept();
}
QGIHighlight::mouseReleaseEvent(event);
}
void QGIGhostHighlight::setInteractive(bool state)
{
setFlag(QGraphicsItem::ItemIsSelectable, state);
setFlag(QGraphicsItem::ItemIsMovable, state);
setFlag(QGraphicsItem::ItemSendsScenePositionChanges, state);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, state);
}
//radius should scaled, but not Rez::guix()
void QGIGhostHighlight::setRadius(double r)
{
setBounds(-r, r, r, -r);
}
#include <Mod/TechDraw/Gui/moc_QGIGhostHighlight.cpp>

View File

@@ -0,0 +1,66 @@
/***************************************************************************
* Copyright (c) 2020 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 TECHDRAWGUI_QGIGHOSTHIGHLIGHT_H
#define TECHDRAWGUI_QGIGHOSTHIGHLIGHT_H
#include <QObject>
#include <QGraphicsScene>
#include <QGraphicsSceneEvent>
#include <QPointF>
#include "QGIHighlight.h"
//a movable, selectable surrogate for detail highlights in QGIVPart
namespace TechDrawGui
{
class TechDrawGuiExport QGIGhostHighlight : public QObject, public QGIHighlight
{
Q_OBJECT
public:
explicit QGIGhostHighlight();
~QGIGhostHighlight();
enum {Type = QGraphicsItem::UserType + 177};
int type() const { return Type;}
void setInteractive(bool state);
void setRadius(double r);
Q_SIGNALS:
void positionChange(QPointF p);
protected:
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
bool m_dragging;
private:
};
}
#endif // TECHDRAWGUI_QGIGHOSTHIGHLIGHT_H

View File

@@ -46,19 +46,65 @@ QGIHighlight::QGIHighlight()
{
m_refText = "";
m_refSize = 0.0;
setInteractive(false);
m_circle = new QGraphicsEllipseItem();
addToGroup(m_circle);
m_circle->setFlag(QGraphicsItem::ItemIsSelectable, false);
m_rect = new QGCustomRect();
addToGroup(m_rect);
m_rect->setFlag(QGraphicsItem::ItemIsSelectable, false);
m_reference = new QGCustomText();
addToGroup(m_reference);
m_reference->setFlag(QGraphicsItem::ItemIsSelectable, false);
setWidth(Rez::guiX(0.75));
setStyle(getHighlightStyle());
setColor(getHighlightColor());
}
QGIHighlight::~QGIHighlight()
{
}
//really only want to emit signal at end of movement
//QVariant QGIHighlight::itemChange(GraphicsItemChange change, const QVariant &value)
//{
// if (change == ItemPositionHasChanged && scene()) {
// // nothing to do here
// }
// return QGraphicsItem::itemChange(change, value);
//}
//void QGIHighlight::mousePressEvent(QGraphicsSceneMouseEvent * event)
//{
// Base::Console().Message("QGIHighlight::mousePress() - %X\n", this);
//// if(scene() && m_reference == scene()->mouseGrabberItem()) {
// if ( (event->button() == Qt::LeftButton) &&
// (flags() && QGraphicsItem::ItemIsMovable) ) {
// m_dragging = true;
// }
//// }
// QGIDecoration::mousePressEvent(event);
//}
//void QGIHighlight::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
//{
// Base::Console().Message("QGIHighlight::mouseRelease() - %X grabber: %X\n", this, scene()->mouseGrabberItem());
//// if(scene() && this == scene()->mouseGrabberItem()) {
// if (m_dragging) {
// m_dragging = false;
//// QString itemName = data(0).toString();
// Q_EMIT positionChange(pos());
// return;
// }
//// }
// QGIDecoration::mouseReleaseEvent(event);
//}
void QGIHighlight::draw()
{
prepareGeometryChange();
@@ -100,6 +146,15 @@ void QGIHighlight::makeReference()
}
}
void QGIHighlight::setInteractive(bool state)
{
// setAcceptHoverEvents(state);
setFlag(QGraphicsItem::ItemIsSelectable, state);
setFlag(QGraphicsItem::ItemIsMovable, state);
setFlag(QGraphicsItem::ItemSendsScenePositionChanges, state);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, state);
}
void QGIHighlight::setBounds(double x1,double y1,double x2,double y2)
{
m_start = QPointF(Rez::guiX(x1),Rez::guiX(-y1));
@@ -142,10 +197,9 @@ int QGIHighlight::getHoleStyle()
return style;
}
void QGIHighlight::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
// myOption.state &= ~QStyle::State_Selected;
setTools();
// painter->drawRect(boundingRect()); //good for debugging
@@ -165,3 +219,4 @@ void QGIHighlight::setTools()
m_reference->setDefaultTextColor(m_colCurrent);
}

View File

@@ -25,9 +25,12 @@
#include <QFont>
#include <QPointF>
#include <QObject>
#include <QGraphicsTextItem>
#include <QGraphicsRectItem>
#include <QGraphicsEllipseItem>
#include <QGraphicsScene>
#include <QGraphicsSceneEvent>
#include <QPainterPath>
#include <QColor>
@@ -45,19 +48,25 @@ class TechDrawGuiExport QGIHighlight : public QGIDecoration
{
public:
explicit QGIHighlight();
~QGIHighlight() {}
~QGIHighlight();
enum {Type = QGraphicsItem::UserType + 172};
enum {Type = QGraphicsItem::UserType + 176};
int type() const { return Type;}
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
virtual void paint(QPainter * painter,
const QStyleOptionGraphicsItem * option,
QWidget * widget = 0 ) override;
void setBounds(double x1,double y1,double x2,double y2);
void setReference(char* sym);
void setFont(QFont f, double fsize);
virtual void draw();
void setInteractive(bool state);
protected:
/* virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;*/
/* virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override;*/
/* virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;*/
QColor getHighlightColor();
Qt::PenStyle getHighlightStyle();
void makeHighlight();
@@ -65,6 +74,7 @@ protected:
void setTools();
int getHoleStyle(void);
/* bool m_dragging;*/
private:
char* m_refText;

View File

@@ -1,26 +1,26 @@
/*
Derived QGraphicsItem Classes type() Values
Derived QGI Classes type() Values
Qt First UserType>> QGraphicsItem::UserType = 65536
QGraphicsItemView : 101
QGraphicsItemViewPart : 102
QGraphicsItemEdge: 103
QGraphicsItemFace: 104
QGraphicsItemVertex: 105
QGraphicsItemViewDimension : 106
QGraphicsItemViewBalloon : 140
QGraphicsItemBalloonLabel : 141
QGraphicsItemDatumLabel : 107
QGraphicsItemViewSection : 108
QGraphicsItemArrow: 109
QGraphicsItemViewCollection : 110
QGraphicsItemViewOrthographic : 113
QGraphicsItemViewAnnotation : 120
QGraphicsItemViewSymbol : 121
QGraphicsItemHatch : 122 //obsolete
QGraphicsItemClip : 123
QGraphicsItemSpreadsheet : 124
QGIView : 101
QGIViewPart : 102
QGIEdge: 103
QGIFace: 104
QGIVertex: 105
QGIViewDimension : 106
QGIViewBalloon : 140
QGIBalloonLabel : 141
QGIDatumLabel : 107
QGIViewSection : 108
QGIArrow: 109
QGIViewCollection : 110
QGIProjGroup : 113
QGIViewAnnotation : 120
QGIViewSymbol : 121
QGIHatch : 122 //obsolete
QGIClip : 123
QGISpreadsheet : 124
QGCustomText: 130
QGCustomSvg: 131
QGCustomClip: 132
@@ -28,9 +28,9 @@ QGCustomRect: 133
QGCustomLabel:135
QGCustomBorder: 136
QGDisplayArea: 137
QGraphicsItemTemplate: 150
QGraphicsItemDrawingTemplate: 151
QGraphicsItemSVGTemplate: 153
QGITemplate: 150
QGIDrawingTemplate: 151
QGISVGTemplate: 153
TemplateTextField: 160
QGIPrimPath: 170
QGICMark: 171
@@ -38,6 +38,8 @@ QGISectionLine: 172
QGIDecoration: 173
QGICenterLine: 174
QGIDimLines: 175
QGIHighlight: 176
QGIGhostHighlight: 177
QGICaption: 180
QGIViewImage: 200
QGCustomImage: 201

View File

@@ -121,6 +121,11 @@ public:
static int calculateFontPixelWidth(const QFont &font);
static const double DefaultFontSizeInMM;
static QString getPrefFont(void);
static double getPrefFontSize(void);
static double getDimFontSize(void);
MDIViewPage* getMDIViewPage(void) const;
virtual void removeChild(QGIView* child);
@@ -145,9 +150,9 @@ protected:
virtual QRectF customChildrenBoundingRect(void) const;
void dumpRect(const char* text, QRectF r);
QString getPrefFont(void);
double getPrefFontSize(void);
double getDimFontSize(void);
/* QString getPrefFont(void);*/
/* double getPrefFontSize(void);*/
/* double getDimFontSize(void);*/
Base::Reference<ParameterGrp> getParmGroupCol(void);

View File

@@ -67,6 +67,11 @@ Base::Vector2d Rez::guiX(Base::Vector3d v, bool planar)
return Base::Vector2d(guiX(v.x), guiX(v.y));
}
QPointF Rez::guiX(QPointF p)
{
return Rez::guiPt(p);
}
//turn Gui side value to App side value
double Rez::appX(double x)
{
@@ -85,6 +90,7 @@ QPointF Rez::appX(QPointF p)
}
//Misc conversions
QPointF Rez::guiPt(QPointF p)
{

View File

@@ -43,6 +43,8 @@ public:
static double guiX(double x);
static Base::Vector3d guiX(Base::Vector3d v);
static Base::Vector2d guiX(Base::Vector3d v, bool planar);
static QPointF guiX(QPointF p);
//turn Gui side value to App side value
static double appX(double x);
static Base::Vector3d appX(Base::Vector3d v);

View File

@@ -0,0 +1,585 @@
/***************************************************************************
* Copyright (c) 2020 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 <QGraphicsScene>
#include <QStatusBar>
#endif // #ifndef _PreComp_
#include <Base/Console.h>
#include <Base/Tools.h>
#include <Base/Quantity.h>
#include <Base/UnitsApi.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>
#include <Gui/Control.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/Selection.h>
#include <Gui/ViewProvider.h>
#include <Gui/WaitCursor.h>
#include <Mod/TechDraw/App/DrawPage.h>
#include <Mod/TechDraw/App/DrawUtil.h>
#include <Mod/TechDraw/App/DrawView.h>
#include <Mod/TechDraw/App/DrawViewPart.h>
#include <Mod/TechDraw/App/DrawViewDetail.h>
#include <Mod/TechDraw/Gui/ui_TaskDetail.h>
#include "DrawGuiStd.h"
#include "QGVPage.h"
#include "QGIView.h"
#include "QGIPrimPath.h"
#include "QGIGhostHighlight.h"
#include "MDIViewPage.h"
#include "ViewProviderPage.h"
#include "Rez.h"
#include "QGIViewPart.h"
#include "TaskDetail.h"
using namespace TechDrawGui;
using namespace TechDraw;
using namespace Gui;
#define CREATEMODE 0
#define EDITMODE 1
//creation ctor
TaskDetail::TaskDetail(TechDraw::DrawViewPart* baseFeat):
ui(new Ui_TaskDetail),
m_detailFeat(nullptr),
m_baseFeat(baseFeat),
m_basePage(nullptr),
m_inProgressLock(false),
m_saveAnchor(Base::Vector3d(0.0, 0.0, 0.0)),
m_saveRadius(0.0),
m_baseName(std::string()),
m_pageName(std::string()),
m_detailName(std::string()),
m_doc(nullptr),
m_mode(CREATEMODE),
m_created(false)
{
if (m_baseFeat == nullptr) {
//should be caught in CMD caller
Base::Console().Error("TaskDetail - bad parameters - base feature. Can not proceed.\n");
return;
}
m_basePage = m_baseFeat->findParentPage();
if (m_basePage == nullptr) {
Base::Console().Error("TaskDetail - bad parameters - base page. Can not proceed.\n");
}
m_baseName = m_baseFeat->getNameInDocument();
m_doc = m_baseFeat->getDocument();
m_pageName = m_basePage->getNameInDocument();
ui->setupUi(this);
Gui::Document* activeGui = Gui::Application::Instance->getDocument(m_doc);
Gui::ViewProvider* vp = activeGui->getViewProvider(m_basePage);
ViewProviderPage* vpp = static_cast<ViewProviderPage*>(vp);
m_mdi = vpp->getMDIViewPage();
m_scene = m_mdi->m_scene;
m_view = m_mdi->getQGVPage();
createDetail();
setUiFromFeat();
setWindowTitle(QObject::tr("New Detail"));
connect(ui->pbDragger, SIGNAL(clicked(bool)),
this, SLOT(onDraggerClicked(bool)));
connect(ui->qsbX, SIGNAL(editingFinished()),
this, SLOT(onXEdit()));
connect(ui->qsbY, SIGNAL(editingFinished()),
this, SLOT(onYEdit()));
connect(ui->qsbRadius, SIGNAL(editingFinished()),
this, SLOT(onRadiusEdit()));
m_ghost = new QGIGhostHighlight();
m_scene->addItem(m_ghost);
m_ghost->hide();
connect(m_ghost, SIGNAL(positionChange(QPointF)),
this, SLOT(onHighlightMoved(QPointF)));
}
//edit ctor
TaskDetail::TaskDetail(TechDraw::DrawViewDetail* detailFeat):
ui(new Ui_TaskDetail),
m_detailFeat(detailFeat),
m_baseFeat(nullptr),
m_basePage(nullptr),
m_inProgressLock(false),
m_saveAnchor(Base::Vector3d(0.0, 0.0, 0.0)),
m_saveRadius(0.0),
m_baseName(std::string()),
m_pageName(std::string()),
m_detailName(std::string()),
m_doc(nullptr),
m_mode(EDITMODE),
m_created(false)
{
if (m_detailFeat == nullptr) {
//should be caught in CMD caller
Base::Console().Error("TaskDetail - bad parameters. Can not proceed.\n");
return;
}
m_doc = m_detailFeat->getDocument();
m_detailName = m_detailFeat->getNameInDocument();
m_basePage = m_detailFeat->findParentPage();
if (m_basePage != nullptr) {
m_pageName = m_basePage->getNameInDocument();
}
App::DocumentObject* baseObj = m_detailFeat->BaseView.getValue();
m_baseFeat = dynamic_cast<TechDraw::DrawViewPart*>(baseObj);
if (m_baseFeat != nullptr) {
m_baseName = m_baseFeat->getNameInDocument();
} else {
Base::Console().Error("TaskDetail - no BaseView. Can not proceed.\n");
return;
}
ui->setupUi(this);
Gui::Document* activeGui = Gui::Application::Instance->getDocument(m_basePage->getDocument());
Gui::ViewProvider* vp = activeGui->getViewProvider(m_basePage);
ViewProviderPage* vpp = static_cast<ViewProviderPage*>(vp);
m_mdi = vpp->getMDIViewPage();
m_scene = m_mdi->m_scene;
m_view = m_mdi->getQGVPage();
saveDetailState();
setUiFromFeat();
setWindowTitle(QObject::tr("Edit Detail"));
connect(ui->pbDragger, SIGNAL(clicked(bool)),
this, SLOT(onDraggerClicked(bool)));
connect(ui->qsbX, SIGNAL(editingFinished()),
this, SLOT(onXEdit()));
connect(ui->qsbY, SIGNAL(editingFinished()),
this, SLOT(onYEdit()));
connect(ui->qsbRadius, SIGNAL(editingFinished()),
this, SLOT(onRadiusEdit()));
connect(ui->aeReference, SIGNAL(editingFinished()),
this, SLOT(onReferenceEdit()));
m_ghost = new QGIGhostHighlight();
m_scene->addItem(m_ghost);
m_ghost->hide();
connect(m_ghost, SIGNAL(positionChange(QPointF)),
this, SLOT(onHighlightMoved(QPointF)));
}
TaskDetail::~TaskDetail()
{
delete ui;
}
void TaskDetail::updateTask()
{
// blockUpdate = true;
// blockUpdate = false;
}
void TaskDetail::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
ui->retranslateUi(this);
}
}
//save the start conditions
void TaskDetail::saveDetailState()
{
// Base::Console().Message("TD::saveDetailState()\n");
TechDraw::DrawViewDetail* dvd = getDetailFeat();
m_saveAnchor = dvd->AnchorPoint.getValue();
m_saveRadius = dvd->Radius.getValue();
m_saved = true;
}
void TaskDetail::restoreDetailState()
{
// Base::Console().Message("TD::restoreDetailState()\n");
TechDraw::DrawViewDetail* dvd = getDetailFeat();
dvd->AnchorPoint.setValue(m_saveAnchor);
dvd->Radius.setValue(m_saveRadius);
}
//***** ui stuff ***************************************************************
void TaskDetail::setUiFromFeat()
{
// Base::Console().Message("TD::setUIFromFeat()\n");
if (m_baseFeat != nullptr) {
std::string baseName = getBaseFeat()->getNameInDocument();
ui->leBaseView->setText(Base::Tools::fromStdString(baseName));
}
Base::Vector3d anchor;
double radius;
TechDraw::DrawViewDetail* detailFeat = getDetailFeat();
QString detailDisplay = QString::fromUtf8(detailFeat->getNameInDocument()) +
QString::fromUtf8(" / ") +
QString::fromUtf8(detailFeat->Label.getValue());
ui->leDetailView->setText(detailDisplay);
anchor = detailFeat->AnchorPoint.getValue();
radius = detailFeat->Radius.getValue();
QString ref = QString::fromUtf8(detailFeat->Reference.getValue());
ui->pbDragger->setText(QString::fromUtf8("Drag Highlight"));
ui->pbDragger->setEnabled(true);
int decimals = Base::UnitsApi::getDecimals();
ui->qsbX->setUnit(Base::Unit::Length);
ui->qsbX->setDecimals(decimals);
ui->qsbY->setUnit(Base::Unit::Length);
ui->qsbY->setDecimals(decimals);
ui->qsbRadius->setDecimals(decimals);
ui->qsbRadius->setUnit(Base::Unit::Length);
ui->qsbX->setValue(anchor.x);
ui->qsbY->setValue(anchor.y);
ui->qsbRadius->setValue(radius);
ui->aeReference->setText(ref);
}
//update ui point fields after tracker finishes
void TaskDetail::updateUi(QPointF p)
{
ui->qsbX->setValue(p.x());
ui->qsbY->setValue(- p.y());
}
void TaskDetail::enableInputFields(bool b)
{
ui->qsbX->setEnabled(b);
ui->qsbY->setEnabled(b);
ui->qsbRadius->setEnabled(b);
ui->aeReference->setEnabled(b);
}
void TaskDetail::onXEdit()
{
updateDetail();
}
void TaskDetail::onYEdit()
{
updateDetail();
}
void TaskDetail::onRadiusEdit()
{
updateDetail();
}
void TaskDetail::onReferenceEdit()
{
updateDetail();
}
void TaskDetail::onDraggerClicked(bool b)
{
Q_UNUSED(b);
ui->pbDragger->setEnabled(false);
enableInputFields(false);
editByHighlight();
return;
}
void TaskDetail::editByHighlight()
{
// Base::Console().Message("TD::editByHighlight()\n");
if (m_ghost == nullptr) {
Base::Console().Error("TaskDetail::editByHighlight - no ghost object\n");
return;
}
m_scene->clearSelection();
m_ghost->setSelected(true);
m_ghost->setPos(getAnchorScene());
m_ghost->draw();
m_ghost->show();
}
//dragEnd is in scene coords.
void TaskDetail::onHighlightMoved(QPointF dragEnd)
{
// Base::Console().Message("TD::onHighlightMoved(%s) - highlight: %X\n",
// DrawUtil::formatVector(dragEnd).c_str(), m_ghost);
ui->pbDragger->setEnabled(true);
double scale = getBaseFeat()->getScale();
double x = Rez::guiX(getBaseFeat()->X.getValue()) * scale;
double y = Rez::guiX(getBaseFeat()->Y.getValue()) * scale;
QPointF basePosScene(x, -y); //base position in scene coords
QPointF anchorDisplace = dragEnd - basePosScene;
QPointF newAnchorPos = Rez::appX(anchorDisplace) / scale;
updateUi(newAnchorPos);
updateDetail();
enableInputFields(true);
m_ghost->setSelected(false);
m_ghost->hide();
}
void TaskDetail::saveButtons(QPushButton* btnOK,
QPushButton* btnCancel)
{
m_btnOK = btnOK;
m_btnCancel = btnCancel;
}
void TaskDetail::enableTaskButtons(bool b)
{
m_btnOK->setEnabled(b);
m_btnCancel->setEnabled(b);
}
//***** Feature create & edit stuff *******************************************
void TaskDetail::createDetail()
{
// Base::Console().Message("TD::createDetail()\n");
Gui::Command::openCommand("Create Detail");
m_detailName = m_doc->getUniqueObjectName("Detail");
Gui::Command::doCommand(Command::Doc,"App.activeDocument().addObject('TechDraw::DrawViewDetail','%s')",
m_detailName.c_str());
App::DocumentObject *docObj = m_doc->getObject(m_detailName.c_str());
TechDraw::DrawViewDetail* dvd = dynamic_cast<TechDraw::DrawViewDetail *>(docObj);
if (!dvd) {
throw Base::TypeError("TaskDetail - new detail not found\n");
}
m_detailFeat = dvd;
dvd->Source.setValues(getBaseFeat()->Source.getValues());
Gui::Command::doCommand(Command::Doc,"App.activeDocument().%s.BaseView = App.activeDocument().%s",
m_detailName.c_str(),m_baseName.c_str());
Gui::Command::doCommand(Command::Doc,"App.activeDocument().%s.Direction = App.activeDocument().%s.Direction",
m_detailName.c_str(),m_baseName.c_str());
Gui::Command::doCommand(Command::Doc,"App.activeDocument().%s.XDirection = App.activeDocument().%s.XDirection",
m_detailName.c_str(),m_baseName.c_str());
Gui::Command::doCommand(Command::Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",
m_pageName.c_str(), m_detailName.c_str());
Gui::Command::updateActive();
Gui::Command::commitCommand();
getBaseFeat()->requestPaint();
m_created = true;
}
void TaskDetail::updateDetail()
{
// Base::Console().Message("TD::updateDetail()\n");
Gui::Command::openCommand("Update Detail");
double x = ui->qsbX->rawValue();
double y = ui->qsbY->rawValue();
Base::Vector3d temp(x, y, 0.0);
TechDraw::DrawViewDetail* detailFeat = getDetailFeat();
detailFeat->AnchorPoint.setValue(temp);
double radius = ui->qsbRadius->rawValue();
detailFeat->Radius.setValue(radius);
QString qRef = ui->aeReference->text();
std::string ref = Base::Tools::toStdString(qRef);
detailFeat->Reference.setValue(ref);
detailFeat->recomputeFeature();
getBaseFeat()->requestPaint();
Gui::Command::updateActive();
Gui::Command::commitCommand();
}
//***** Getters ****************************************************************
//get the current Anchor highlight position in scene coords
QPointF TaskDetail::getAnchorScene()
{
TechDraw::DrawViewPart* dvp = getBaseFeat();
TechDraw::DrawViewDetail* dvd = getDetailFeat();
Base::Vector3d anchorPos = dvd->AnchorPoint.getValue();
double x = dvp->X.getValue();
double y = dvp->Y.getValue();
Base::Vector3d basePos(x, y, 0.0);
Base::Vector3d netPos = basePos + anchorPos;
netPos = Rez::guiX(netPos * dvp->getScale());
QPointF qAnchor(netPos.x, - netPos.y);
return qAnchor;
}
// protects against stale pointers
DrawViewPart* TaskDetail::getBaseFeat()
{
// Base::Console().Message("TD::getBaseFeat()\n");
DrawViewPart* result = nullptr;
if (m_doc != nullptr) {
App::DocumentObject* baseObj = m_doc->getObject(m_baseName.c_str());
if (baseObj != nullptr) {
result = static_cast<DrawViewPart*>(baseObj);
}
}
if (result == nullptr) {
std::string msg = "TaskDetail - base feature " +
m_baseName +
" not found \n";
throw Base::TypeError(msg);
}
return result;
}
// protects against stale pointers
DrawViewDetail* TaskDetail::getDetailFeat()
{
// Base::Console().Message("TD::getDetailFeat()\n");
DrawViewDetail* result = nullptr;
if (m_doc != nullptr) {
App::DocumentObject* detailObj = m_doc->getObject(m_detailName.c_str());
if (detailObj != nullptr) {
result = static_cast<DrawViewDetail*>(detailObj);
}
}
if (result == nullptr) {
std::string msg = "TaskDetail - detail feature " +
m_detailName +
" not found \n";
// throw Base::TypeError("TaskDetail - detail feature not found\n");
throw Base::TypeError(msg);
}
return result;
}
//******************************************************************************
bool TaskDetail::accept()
{
// Base::Console().Message("TD::accept()\n");
Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument());
if (!doc) return false;
getDetailFeat()->requestPaint();
getBaseFeat()->requestPaint();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
return true;
}
bool TaskDetail::reject()
{
// Base::Console().Message("TD::reject()\n");
Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument());
if (!doc) return false;
if (m_mode == CREATEMODE) {
if (m_created) {
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().removeObject('%s')",
m_detailName.c_str());
}
} else {
restoreDetailState();
getDetailFeat()->recomputeFeature();
getBaseFeat()->requestPaint();
}
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().recompute()");
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
return false;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TaskDlgDetail::TaskDlgDetail(TechDraw::DrawViewPart* baseFeat)
: TaskDialog()
{
widget = new TaskDetail(baseFeat);
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-DetailView"),
widget->windowTitle(), true, 0);
taskbox->groupLayout()->addWidget(widget);
Content.push_back(taskbox);
}
TaskDlgDetail::TaskDlgDetail(TechDraw::DrawViewDetail* detailFeat)
: TaskDialog()
{
widget = new TaskDetail(detailFeat);
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-DetailView"),
widget->windowTitle(), true, 0);
taskbox->groupLayout()->addWidget(widget);
Content.push_back(taskbox);
}
TaskDlgDetail::~TaskDlgDetail()
{
}
void TaskDlgDetail::update()
{
// widget->updateTask();
}
void TaskDlgDetail::modifyStandardButtons(QDialogButtonBox* box)
{
QPushButton* btnOK = box->button(QDialogButtonBox::Ok);
QPushButton* btnCancel = box->button(QDialogButtonBox::Cancel);
widget->saveButtons(btnOK, btnCancel);
}
//==== calls from the TaskView ===============================================================
void TaskDlgDetail::open()
{
}
void TaskDlgDetail::clicked(int)
{
}
bool TaskDlgDetail::accept()
{
widget->accept();
return true;
}
bool TaskDlgDetail::reject()
{
widget->reject();
return true;
}
#include <Mod/TechDraw/Gui/moc_TaskDetail.cpp>

View File

@@ -0,0 +1,179 @@
/***************************************************************************
* Copyright (c) 2020 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 TECHDRAWGUI_TASKCOSVERTEX_H
#define TECHDRAWGUI_TASKCOSVERTEX_H
#include <App/DocumentObject.h>
#include <Base/Vector3D.h>
#include <Gui/TaskView/TaskView.h>
#include <Gui/TaskView/TaskDialog.h>
#include <Mod/TechDraw/Gui/ui_TaskDetail.h>
//TODO: make this a proper enum
#define TRACKERPICK 0
#define TRACKEREDIT 1
#define TRACKERCANCEL 2
#define TRACKERCANCELEDIT 3
class Ui_TaskDetail;
namespace App {
class DocumentObject;
}
namespace TechDraw
{
class DrawPage;
class DrawView;
class DrawDetail;
class DrawViewPart;
}
namespace TechDrawGui
{
class QGVPage;
class QGIView;
class QGIPrimPath;
class MDIViewPage;
class QGEPath;
class QGIDetail;
class QGIGhostHighlight;
class ViewProviderLeader;
class TaskDetail : public QWidget
{
Q_OBJECT
public:
TaskDetail(TechDraw::DrawViewPart* baseFeat);
TaskDetail(TechDraw::DrawViewDetail* detailFeat);
~TaskDetail();
public Q_SLOTS:
void onDraggerClicked(bool b);
void onHighlightMoved(QPointF newPos);
void onXEdit();
void onYEdit();
void onRadiusEdit();
void onReferenceEdit();
public:
virtual bool accept();
virtual bool reject();
void updateTask();
void saveButtons(QPushButton* btnOK,
QPushButton* btnCancel);
void enableTaskButtons(bool b);
protected:
void changeEvent(QEvent *e);
void startDragger(void);
void createDetail();
void updateDetail();
void editByHighlight();
void blockButtons(bool b);
void setUiFromFeat(void);
void updateUi(QPointF p);
void enableInputFields(bool b);
void saveDetailState();
void restoreDetailState();
QPointF getAnchorScene();
TechDraw::DrawViewPart* getBaseFeat();
TechDraw::DrawViewDetail* getDetailFeat();
private:
Ui_TaskDetail * ui;
bool blockUpdate;
QGIGhostHighlight* m_ghost;
MDIViewPage* m_mdi;
QGraphicsScene* m_scene;
QGVPage* m_view;
TechDraw::DrawViewDetail* m_detailFeat;
TechDraw::DrawViewPart* m_baseFeat;
TechDraw::DrawPage* m_basePage;
QGIView* m_qgParent;
std::string m_qgParentName;
bool m_inProgressLock;
QPushButton* m_btnOK;
QPushButton* m_btnCancel;
Base::Vector3d m_saveAnchor;
double m_saveRadius;
bool m_saved;
QPointF m_dragStart;
std::string m_baseName;
std::string m_pageName;
std::string m_detailName;
App::Document* m_doc;
bool m_mode;
bool m_created;
};
class TaskDlgDetail : public Gui::TaskView::TaskDialog
{
Q_OBJECT
public:
TaskDlgDetail(TechDraw::DrawViewPart* baseFeat);
TaskDlgDetail(TechDraw::DrawViewDetail* detailFeat);
~TaskDlgDetail();
public:
/// is called the TaskView when the dialog is opened
virtual void open();
/// is called by the framework if an button is clicked which has no accept or reject role
virtual void clicked(int);
/// is called by the framework if the dialog is accepted (Ok)
virtual bool accept();
/// is called by the framework if the dialog is rejected (Cancel)
virtual bool reject();
/// is called by the framework if the user presses the help button
virtual void helpRequested() { return;}
virtual bool isAllowedAlterDocument(void) const
{ return false; }
void update();
void modifyStandardButtons(QDialogButtonBox* box);
protected:
private:
TaskDetail * widget;
Gui::TaskView::TaskBox* taskbox;
};
} //namespace TechDrawGui
#endif // #ifndef TECHDRAWGUI_TASKCOSVERTEX_H

View File

@@ -0,0 +1,296 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TechDrawGui::TaskDetail</class>
<widget class="QWidget" name="TechDrawGui::TaskDetail">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>381</width>
<height>405</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Detail Anchor</string>
</property>
<property name="windowIcon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/actions/techdraw-DetailView.svg</normaloff>:/icons/actions/techdraw-DetailView.svg</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>300</height>
</size>
</property>
<property name="baseSize">
<size>
<width>300</width>
<height>300</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLineEdit" name="leBaseView">
<property name="enabled">
<bool>false</bool>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Base View</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Detail View</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="leDetailView">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pbDragger">
<property name="toolTip">
<string>Click to drag detail highlight to new position</string>
</property>
<property name="text">
<string>Drag Highlight</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2" columnstretch="2,1,2">
<item row="2" column="2">
<widget class="Gui::QuantitySpinBox" name="qsbRadius">
<property name="toolTip">
<string>size of detail view</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
<property name="value">
<double>10.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>X</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Y</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="Gui::QuantitySpinBox" name="qsbX">
<property name="toolTip">
<string>x position of detail highlight within view</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="Gui::QuantitySpinBox" name="qsbY">
<property name="toolTip">
<string>y position of detail highlight within view</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Radius</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Reference</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="Gui::AccelLineEdit" name="aeReference">
<property name="toolTip">
<string>Detail identifier</string>
</property>
<property name="text">
<string>1</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::AccelLineEdit</class>
<extends>QLineEdit</extends>
<header>Gui/Widgets.h</header>
</customwidget>
<customwidget>
<class>Gui::QuantitySpinBox</class>
<extends>QWidget</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="Resources/TechDraw.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -37,19 +37,29 @@
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Gui/Application.h>
#include <Gui/Command.h>
#include <Gui/Control.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/Selection.h>
#include <Gui/ViewProvider.h>
#include <Gui/WaitCursor.h>
#include <Mod/TechDraw/App/DrawViewDimension.h>
#include <Mod/TechDraw/App/DrawViewBalloon.h>
#include <Mod/TechDraw/App/DrawLeaderLine.h>
#include <Mod/TechDraw/App/DrawRichAnno.h>
#include <Mod/TechDraw/App/DrawViewMulti.h>
#include <Mod/TechDraw/App/DrawViewDetail.h>
#include <Mod/TechDraw/App/DrawHatch.h>
#include <Mod/TechDraw/App/DrawGeomHatch.h>
#include <Mod/TechDraw/App/DrawWeldSymbol.h>
#include <Mod/TechDraw/App/LineGroup.h>
#include<Mod/TechDraw/App/DrawPage.h>
#include "QGIView.h"
#include "TaskDetail.h"
#include "ViewProviderViewPart.h"
using namespace TechDrawGui;
@@ -166,8 +176,11 @@ void ViewProviderViewPart::onChanged(const App::Property* prop)
void ViewProviderViewPart::attach(App::DocumentObject *pcFeat)
{
TechDraw::DrawViewMulti* dvm = dynamic_cast<TechDraw::DrawViewMulti*>(pcFeat);
TechDraw::DrawViewDetail* dvd = dynamic_cast<TechDraw::DrawViewDetail*>(pcFeat);
if (dvm != nullptr) {
sPixmap = "TechDraw_Tree_Multi";
} else if (dvd != nullptr) {
sPixmap = "actions/techdraw-DetailView";
}
ViewProviderDrawingView::attach(pcFeat);
@@ -232,6 +245,57 @@ std::vector<App::DocumentObject*> ViewProviderViewPart::claimChildren(void) cons
return tmp;
}
}
bool ViewProviderViewPart::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Default ) {
if (Gui::Control().activeDialog()) { //TaskPanel already open!
return false;
}
TechDraw::DrawViewPart* dvp = getViewObject();
TechDraw::DrawViewDetail* dvd = dynamic_cast<TechDraw::DrawViewDetail*>(dvp);
if (dvd != nullptr) {
// clear the selection (convenience)
Gui::Selection().clearSelection();
Gui::Control().showDialog(new TaskDlgDetail(dvd));
// Gui::Selection().clearSelection();
// flush any lingering gui objects
Gui::Selection().addSelection(dvd->getDocument()->getName(),
dvd->getNameInDocument());
Gui::Selection().clearSelection();
Gui::Selection().addSelection(dvd->getDocument()->getName(),
dvd->getNameInDocument());
//Gui.ActiveDocument.resetEdit()
//>>> # Gui.Selection.addSelection('aaStart121','Detail')
//>>> # Gui.Selection.clearSelection()
//>>> # Gui.Selection.addSelection('aaStart121','Detail')
//>>> # Gui.Selection.addSelection('aaStart121','Detail')
//>>> # Gui.Selection.clearSelection()
//>>> # Gui.Selection.addSelection('aaStart121','Detail')
return true;
}
} else {
return ViewProviderDrawingView::setEdit(ModNum);
}
return true;
}
void ViewProviderViewPart::unsetEdit(int ModNum)
{
Q_UNUSED(ModNum);
if (ModNum == ViewProvider::Default) {
Gui::Control().closeDialog();
}
else {
ViewProviderDrawingView::unsetEdit(ModNum);
}
}
bool ViewProviderViewPart::doubleClicked(void)
{
setEdit(ViewProvider::Default);
return true;
}
TechDraw::DrawViewPart* ViewProviderViewPart::getViewObject() const
{

View File

@@ -68,6 +68,9 @@ public:
virtual std::vector<std::string> getDisplayModes(void) const;
virtual bool onDelete(const std::vector<std::string> &);
virtual bool canDelete(App::DocumentObject* obj) const;
virtual bool setEdit(int ModNum);
virtual void unsetEdit(int ModNum);
virtual bool doubleClicked(void);
public:
virtual void onChanged(const App::Property *prop);