[TD]implement navigation styles
This commit is contained in:
committed by
WandererFan
parent
4791575e31
commit
db89eec8e3
@@ -286,6 +286,21 @@ int DrawViewBalloon::prefEnd(void) const
|
||||
return Preferences::balloonArrow();
|
||||
}
|
||||
|
||||
QPointF DrawViewBalloon::getOrigin()
|
||||
{
|
||||
double x = OriginX.getValue();
|
||||
double y = OriginY.getValue();
|
||||
QPointF result(x, y);
|
||||
return result;
|
||||
}
|
||||
|
||||
void DrawViewBalloon::setOrigin(QPointF p)
|
||||
{
|
||||
OriginX.setValue(p.x());
|
||||
OriginY.setValue(p.y());
|
||||
origin = p;
|
||||
}
|
||||
|
||||
Base::Vector3d DrawViewBalloon::getOriginOffset() const
|
||||
{
|
||||
double x = X.getValue();
|
||||
|
||||
@@ -62,7 +62,9 @@ public:
|
||||
short mustExecute() const override;
|
||||
|
||||
DrawViewPart* getViewPart() const;
|
||||
QPointF origin;
|
||||
QPointF origin; //WF never used??
|
||||
QPointF getOrigin();
|
||||
void setOrigin(QPointF p);
|
||||
|
||||
//virtual PyObject *getPyObject(void);
|
||||
|
||||
|
||||
@@ -146,9 +146,6 @@ SET(TechDrawGui_SRCS
|
||||
DlgPrefsTechDrawHLR.ui
|
||||
DlgPrefsTechDrawHLRImp.cpp
|
||||
DlgPrefsTechDrawHLRImp.h
|
||||
TaskLinkDim.ui
|
||||
TaskLinkDim.cpp
|
||||
TaskLinkDim.h
|
||||
DlgTemplateField.ui
|
||||
DlgTemplateField.cpp
|
||||
DlgTemplateField.h
|
||||
@@ -182,6 +179,9 @@ SET(TechDrawGui_SRCS
|
||||
TaskLineDecor.ui
|
||||
TaskLineDecor.cpp
|
||||
TaskLineDecor.h
|
||||
TaskLinkDim.ui
|
||||
TaskLinkDim.cpp
|
||||
TaskLinkDim.h
|
||||
TaskRestoreLines.ui
|
||||
TaskWeldingSymbol.ui
|
||||
TaskWeldingSymbol.cpp
|
||||
@@ -223,6 +223,8 @@ SET(TechDrawGuiView_SRCS
|
||||
MDIViewPage.h
|
||||
QGVPage.cpp
|
||||
QGVPage.h
|
||||
QGSPage.cpp
|
||||
QGSPage.h
|
||||
QGCustomText.cpp
|
||||
QGCustomText.h
|
||||
QGICaption.cpp
|
||||
@@ -315,6 +317,32 @@ SET(TechDrawGuiView_SRCS
|
||||
QGIGhostHighlight.cpp
|
||||
QGIGhostHighlight.h
|
||||
)
|
||||
|
||||
SET(TechDrawGuiNav_SRCS
|
||||
QGVNavStyle.cpp
|
||||
QGVNavStyle.h
|
||||
QGVNavStyleBlender.cpp
|
||||
QGVNavStyleBlender.h
|
||||
QGVNavStyleCAD.cpp
|
||||
QGVNavStyleCAD.h
|
||||
QGVNavStyleGesture.cpp
|
||||
QGVNavStyleGesture.h
|
||||
QGVNavStyleInventor.cpp
|
||||
QGVNavStyleInventor.h
|
||||
QGVNavStyleMaya.cpp
|
||||
QGVNavStyleMaya.h
|
||||
QGVNavStyleOCC.cpp
|
||||
QGVNavStyleOCC.h
|
||||
QGVNavStyleOpenSCAD.cpp
|
||||
QGVNavStyleOpenSCAD.h
|
||||
QGVNavStyleRevit.cpp
|
||||
QGVNavStyleRevit.h
|
||||
QGVNavStyleTinkerCAD.cpp
|
||||
QGVNavStyleTinkerCAD.h
|
||||
QGVNavStyleTouchpad.cpp
|
||||
QGVNavStyleTouchpad.h
|
||||
)
|
||||
|
||||
SET(TechDrawGuiViewProvider_SRCS
|
||||
ViewProviderPage.cpp
|
||||
ViewProviderPage.h
|
||||
@@ -360,11 +388,6 @@ SET(TechDrawGuiViewProvider_SRCS
|
||||
ViewProviderCosmeticExtension.h
|
||||
)
|
||||
|
||||
SOURCE_GROUP("MRTE" FILES ${MRTE_SRCS})
|
||||
SOURCE_GROUP("Mod" FILES ${TechDrawGui_SRCS})
|
||||
SOURCE_GROUP("SVG-View" FILES ${TechDrawGuiView_SRCS})
|
||||
SOURCE_GROUP("ViewProvider" FILES ${TechDrawGuiViewProvider_SRCS})
|
||||
|
||||
SET(TechDrawGuiTaskDlgs_SRCS
|
||||
TaskProjGroup.ui
|
||||
TaskLinkDim.ui
|
||||
@@ -389,8 +412,13 @@ SET(TechDrawGuiTaskDlgs_SRCS
|
||||
TaskCustomizeFormat.ui
|
||||
TaskMoveView.ui
|
||||
TaskProjection.ui
|
||||
|
||||
)
|
||||
|
||||
SOURCE_GROUP("MRTE" FILES ${MRTE_SRCS})
|
||||
SOURCE_GROUP("Mod" FILES ${TechDrawGui_SRCS})
|
||||
SOURCE_GROUP("View" FILES ${TechDrawGuiView_SRCS})
|
||||
SOURCE_GROUP("Nav" FILES ${TechDrawGuiNav_SRCS})
|
||||
SOURCE_GROUP("ViewProvider" FILES ${TechDrawGuiViewProvider_SRCS})
|
||||
SOURCE_GROUP("TaskDialogs" FILES ${TechDrawGuiTaskDlgs_SRCS})
|
||||
|
||||
SET(TechDrawGuiIcon_SVG
|
||||
@@ -406,12 +434,13 @@ SET(TechDrawGuiFonts
|
||||
if(FREECAD_USE_PCH)
|
||||
add_definitions(-D_PreComp_)
|
||||
GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${TechDrawGui_SRCS} ${TechDrawGuiView_SRCS}
|
||||
${TechDrawGuiNav_SRCS}
|
||||
${TechDrawGuiViewProvider_SRCS} ${MRTE_SRCS})
|
||||
ADD_MSVC_PRECOMPILED_HEADER(TechDrawGui PreCompiled.h PreCompiled.cpp PCH_SRCS)
|
||||
endif(FREECAD_USE_PCH)
|
||||
|
||||
add_library(TechDrawGui SHARED ${TechDrawGui_SRCS} ${TechDrawGuiView_SRCS} ${TechDrawGuiViewProvider_SRCS}
|
||||
${TechDrawGuiIcon_SVG} ${TechDrawGuiFonts} ${MRTE_SRCS})
|
||||
${TechDrawGuiNav_SRCS} ${TechDrawGuiIcon_SVG} ${TechDrawGuiFonts} ${MRTE_SRCS})
|
||||
target_link_libraries(TechDrawGui ${TechDrawGui_LIBS})
|
||||
|
||||
fc_copy_sources(TechDrawGui "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/TechDraw/" ${TechDrawGuiIcon_SVG})
|
||||
|
||||
@@ -85,9 +85,10 @@
|
||||
#include <Mod/TechDraw/App/DrawViewDetail.h>
|
||||
#include <Mod/TechDraw/App/DrawViewArch.h>
|
||||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
#include <Mod/TechDraw/Gui/QGVPage.h>
|
||||
|
||||
#include "DrawGuiUtil.h"
|
||||
#include "QGSPage.h"
|
||||
#include "QGVPage.h"
|
||||
#include "MDIViewPage.h"
|
||||
#include "PreferencesGui.h"
|
||||
#include "QGIViewPart.h"
|
||||
@@ -890,13 +891,14 @@ void CmdTechDrawBalloon::activated(int iMsg)
|
||||
|
||||
if (pageVP && partVP) {
|
||||
QGVPage* viewPage = pageVP->getGraphicsView();
|
||||
QGSPage* scenePage = pageVP->getGraphicsScene();
|
||||
if (viewPage) {
|
||||
viewPage->startBalloonPlacing();
|
||||
|
||||
QGIViewPart* viewPart = dynamic_cast<QGIViewPart*>(partVP->getQView());
|
||||
QPointF placement;
|
||||
if (viewPart && _checkDirectPlacement(viewPart, selection[0].getSubNames(), placement)) {
|
||||
viewPage->createBalloon(placement, objFeat);
|
||||
scenePage->createBalloon(placement, objFeat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
# include <Mod/TechDraw/App/DrawViewBalloon.h>
|
||||
|
||||
# include "ViewProviderBalloon.h"
|
||||
# include "QGSPage.h"
|
||||
# include "QGVPage.h"
|
||||
# include "DrawGuiUtil.h"
|
||||
# include "ViewProviderPage.h"
|
||||
@@ -1884,9 +1885,9 @@ namespace TechDrawGui {
|
||||
Gui::Document* guiDoc = Gui::Application::Instance->getDocument(page->getDocument());
|
||||
ViewProviderPage* pageVP = dynamic_cast<ViewProviderPage*>(guiDoc->getViewProvider(page));
|
||||
if (pageVP) {
|
||||
QGVPage* viewPage = pageVP->getGraphicsView();
|
||||
featName = viewPage->getDrawPage()->getDocument()->getUniqueObjectName("Balloon");
|
||||
std::string pageName = viewPage->getDrawPage()->getNameInDocument();
|
||||
QGSPage* scenePage = pageVP->getGraphicsScene();
|
||||
featName = scenePage->getDrawPage()->getDocument()->getUniqueObjectName("Balloon");
|
||||
std::string pageName = scenePage->getDrawPage()->getNameInDocument();
|
||||
cmd->doCommand(cmd->Doc, "App.activeDocument().addObject('TechDraw::DrawViewBalloon','%s')",
|
||||
featName.c_str());
|
||||
cmd->doCommand(cmd->Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)",
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
#include <Mod/TechDraw/App/Geometry.h>
|
||||
#include <Mod/TechDraw/App/ArrowPropEnum.h>
|
||||
|
||||
#include "QGSPage.h"
|
||||
#include "QGVPage.h"
|
||||
#include "MDIViewPage.h"
|
||||
#include "ViewProviderPage.h"
|
||||
@@ -128,7 +129,7 @@ TechDraw::DrawPage* DrawGuiUtil::findPage(Gui::Command* cmd)
|
||||
MDIViewPage* mvp = dynamic_cast<MDIViewPage*>(mv);
|
||||
if (mvp) {
|
||||
QString windowTitle = mvp->windowTitle();
|
||||
QGVPage* qp = mvp->getQGVPage();
|
||||
QGSPage* qp = mvp->getQGSPage();
|
||||
page = qp->getDrawPage();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -101,6 +101,7 @@
|
||||
#include "QGIEdge.h"
|
||||
#include "QGIFace.h"
|
||||
#include "ViewProviderPage.h"
|
||||
#include "QGSPage.h"
|
||||
#include "QGVPage.h"
|
||||
#include "QGILeaderLine.h"
|
||||
#include "QGIRichAnno.h"
|
||||
@@ -126,7 +127,7 @@ MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget*
|
||||
{
|
||||
|
||||
setMouseTracking(true);
|
||||
m_scene = new QGraphicsScene(this);
|
||||
m_scene = new QGSPage(pageVp, this);
|
||||
m_scene->setItemIndexMethod(QGraphicsScene::NoIndex); //this prevents crash when deleting dims.
|
||||
//scene(view?) indices of dirty regions gets
|
||||
//out of sync. missing prepareGeometryChange
|
||||
@@ -161,7 +162,7 @@ MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget*
|
||||
|
||||
// Connect Signals and Slots
|
||||
QObject::connect(
|
||||
m_view->scene(), SIGNAL(selectionChanged()),
|
||||
m_scene, SIGNAL(selectionChanged()),
|
||||
this , SLOT (sceneSelectionChanged())
|
||||
);
|
||||
|
||||
@@ -169,6 +170,8 @@ MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget*
|
||||
App::Document* appDoc = m_vpPage->getDocument()->getDocument();
|
||||
auto bnd = boost::bind(&MDIViewPage::onDeleteObject, this, bp::_1);
|
||||
connectDeletedObject = appDoc->signalDeletedObject.connect(bnd);
|
||||
|
||||
// setContextMenuPolicy(Qt::NoContextMenu);
|
||||
}
|
||||
|
||||
|
||||
@@ -218,22 +221,22 @@ void MDIViewPage::matchSceneRectToTemplate(void)
|
||||
//make sceneRect 1 pagesize bigger in every direction
|
||||
double width = Rez::guiX(pageTemplate->Width.getValue());
|
||||
double height = Rez::guiX(pageTemplate->Height.getValue());
|
||||
m_view->scene()->setSceneRect(QRectF(-width,-2.0 * height,3.0*width,3.0*height));
|
||||
m_scene->setSceneRect(QRectF(-width,-2.0 * height,3.0*width,3.0*height));
|
||||
}
|
||||
}
|
||||
|
||||
void MDIViewPage::setDimensionGroups(void)
|
||||
{
|
||||
const std::vector<QGIView *> &allItems = m_view->getViews();
|
||||
const std::vector<QGIView *> &allItems = m_scene->getViews();
|
||||
std::vector<QGIView *>::const_iterator itInspect;
|
||||
int dimItemType = QGraphicsItem::UserType + 106;
|
||||
|
||||
for (itInspect = allItems.begin(); itInspect != allItems.end(); itInspect++) {
|
||||
if (((*itInspect)->type() == dimItemType) && (!(*itInspect)->group())) {
|
||||
QGIView* parent = m_view->findParent((*itInspect));
|
||||
QGIView* parent = m_scene->findParent((*itInspect));
|
||||
if (parent) {
|
||||
QGIViewDimension* dim = dynamic_cast<QGIViewDimension*>((*itInspect));
|
||||
m_view->addDimToParent(dim,parent);
|
||||
m_scene->addDimToParent(dim,parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -241,16 +244,16 @@ void MDIViewPage::setDimensionGroups(void)
|
||||
|
||||
void MDIViewPage::setBalloonGroups(void)
|
||||
{
|
||||
const std::vector<QGIView *> &allItems = m_view->getViews();
|
||||
const std::vector<QGIView *> &allItems = m_scene->getViews();
|
||||
std::vector<QGIView *>::const_iterator itInspect;
|
||||
int balloonItemType = QGraphicsItem::UserType + 140;
|
||||
|
||||
for (itInspect = allItems.begin(); itInspect != allItems.end(); itInspect++) {
|
||||
if (((*itInspect)->type() == balloonItemType) && (!(*itInspect)->group())) {
|
||||
QGIView* parent = m_view->findParent((*itInspect));
|
||||
QGIView* parent = m_scene->findParent((*itInspect));
|
||||
if (parent) {
|
||||
QGIViewBalloon* balloon = dynamic_cast<QGIViewBalloon*>((*itInspect));
|
||||
m_view->addBalloonToParent(balloon,parent);
|
||||
m_scene->addBalloonToParent(balloon,parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -259,7 +262,7 @@ void MDIViewPage::setBalloonGroups(void)
|
||||
void MDIViewPage::setLeaderGroups(void)
|
||||
{
|
||||
// Base::Console().Message("MDIVP::setLeaderGroups()\n");
|
||||
const std::vector<QGIView *> &allItems = m_view->getViews();
|
||||
const std::vector<QGIView *> &allItems = m_scene->getViews();
|
||||
std::vector<QGIView *>::const_iterator itInspect;
|
||||
int leadItemType = QGraphicsItem::UserType + 232;
|
||||
|
||||
@@ -267,10 +270,10 @@ void MDIViewPage::setLeaderGroups(void)
|
||||
//quite possibly redundant
|
||||
for (itInspect = allItems.begin(); itInspect != allItems.end(); itInspect++) {
|
||||
if (((*itInspect)->type() == leadItemType) && (!(*itInspect)->group())) {
|
||||
QGIView* parent = m_view->findParent((*itInspect));
|
||||
QGIView* parent = m_scene->findParent((*itInspect));
|
||||
if (parent) {
|
||||
QGILeaderLine* lead = dynamic_cast<QGILeaderLine*>((*itInspect));
|
||||
m_view->addLeaderToParent(lead,parent);
|
||||
m_scene->addLeaderToParent(lead,parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -309,7 +312,7 @@ void MDIViewPage::closeEvent(QCloseEvent* ev)
|
||||
|
||||
void MDIViewPage::attachTemplate(TechDraw::DrawTemplate *obj)
|
||||
{
|
||||
m_view->setPageTemplate(obj);
|
||||
m_scene->setPageTemplate(obj);
|
||||
pagewidth = obj->Width.getValue();
|
||||
pageheight = obj->Height.getValue();
|
||||
m_paperSize = QPageSize::id(QSizeF(pagewidth, pageheight), QPageSize::Millimeter, QPageSize::FuzzyOrientationMatch);
|
||||
@@ -350,46 +353,46 @@ bool MDIViewPage::attachView(App::DocumentObject *obj)
|
||||
QGIView *qview(nullptr);
|
||||
|
||||
if (typeId.isDerivedFrom(TechDraw::DrawViewSection::getClassTypeId()) ) {
|
||||
qview = m_view->addViewSection( static_cast<TechDraw::DrawViewSection *>(obj) );
|
||||
qview = m_scene->addViewSection( static_cast<TechDraw::DrawViewSection *>(obj) );
|
||||
|
||||
} else if (typeId.isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId()) ) {
|
||||
qview = m_view->addViewPart( static_cast<TechDraw::DrawViewPart *>(obj) );
|
||||
qview = m_scene->addViewPart( static_cast<TechDraw::DrawViewPart *>(obj) );
|
||||
|
||||
} else if (typeId.isDerivedFrom(TechDraw::DrawProjGroup::getClassTypeId()) ) {
|
||||
qview = m_view->addProjectionGroup( static_cast<TechDraw::DrawProjGroup *>(obj) );
|
||||
qview = m_scene->addProjectionGroup( static_cast<TechDraw::DrawProjGroup *>(obj) );
|
||||
|
||||
} else if (typeId.isDerivedFrom(TechDraw::DrawViewCollection::getClassTypeId()) ) {
|
||||
qview = m_view->addDrawView( static_cast<TechDraw::DrawViewCollection *>(obj) );
|
||||
qview = m_scene->addDrawView( static_cast<TechDraw::DrawViewCollection *>(obj) );
|
||||
|
||||
} else if (typeId.isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId()) ) {
|
||||
qview = m_view->addViewDimension( static_cast<TechDraw::DrawViewDimension *>(obj) );
|
||||
qview = m_scene->addViewDimension( static_cast<TechDraw::DrawViewDimension *>(obj) );
|
||||
|
||||
} else if (typeId.isDerivedFrom(TechDraw::DrawViewBalloon::getClassTypeId()) ) {
|
||||
qview = m_view->addViewBalloon( static_cast<TechDraw::DrawViewBalloon *>(obj) );
|
||||
qview = m_scene->addViewBalloon( static_cast<TechDraw::DrawViewBalloon *>(obj) );
|
||||
|
||||
} else if (typeId.isDerivedFrom(TechDraw::DrawViewAnnotation::getClassTypeId()) ) {
|
||||
qview = m_view->addDrawViewAnnotation( static_cast<TechDraw::DrawViewAnnotation *>(obj) );
|
||||
qview = m_scene->addDrawViewAnnotation( static_cast<TechDraw::DrawViewAnnotation *>(obj) );
|
||||
|
||||
} else if (typeId.isDerivedFrom(TechDraw::DrawViewSymbol::getClassTypeId()) ) {
|
||||
qview = m_view->addDrawViewSymbol( static_cast<TechDraw::DrawViewSymbol *>(obj) );
|
||||
qview = m_scene->addDrawViewSymbol( static_cast<TechDraw::DrawViewSymbol *>(obj) );
|
||||
|
||||
} else if (typeId.isDerivedFrom(TechDraw::DrawViewClip::getClassTypeId()) ) {
|
||||
qview = m_view->addDrawViewClip( static_cast<TechDraw::DrawViewClip *>(obj) );
|
||||
qview = m_scene->addDrawViewClip( static_cast<TechDraw::DrawViewClip *>(obj) );
|
||||
|
||||
} else if (typeId.isDerivedFrom(TechDraw::DrawViewSpreadsheet::getClassTypeId()) ) {
|
||||
qview = m_view->addDrawViewSpreadsheet( static_cast<TechDraw::DrawViewSpreadsheet *>(obj) );
|
||||
qview = m_scene->addDrawViewSpreadsheet( static_cast<TechDraw::DrawViewSpreadsheet *>(obj) );
|
||||
|
||||
} else if (typeId.isDerivedFrom(TechDraw::DrawViewImage::getClassTypeId()) ) {
|
||||
qview = m_view->addDrawViewImage( static_cast<TechDraw::DrawViewImage *>(obj) );
|
||||
qview = m_scene->addDrawViewImage( static_cast<TechDraw::DrawViewImage *>(obj) );
|
||||
|
||||
} else if (typeId.isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId()) ) {
|
||||
qview = m_view->addViewLeader( static_cast<TechDraw::DrawLeaderLine *>(obj) );
|
||||
qview = m_scene->addViewLeader( static_cast<TechDraw::DrawLeaderLine *>(obj) );
|
||||
|
||||
} else if (typeId.isDerivedFrom(TechDraw::DrawRichAnno::getClassTypeId()) ) {
|
||||
qview = m_view->addRichAnno( static_cast<TechDraw::DrawRichAnno*>(obj) );
|
||||
qview = m_scene->addRichAnno( static_cast<TechDraw::DrawRichAnno*>(obj) );
|
||||
|
||||
} else if (typeId.isDerivedFrom(TechDraw::DrawWeldSymbol::getClassTypeId()) ) {
|
||||
qview = m_view->addWeldSymbol( static_cast<TechDraw::DrawWeldSymbol*>(obj) );
|
||||
qview = m_scene->addWeldSymbol( static_cast<TechDraw::DrawWeldSymbol*>(obj) );
|
||||
|
||||
} else if (typeId.isDerivedFrom(TechDraw::DrawHatch::getClassTypeId()) ) {
|
||||
//Hatch is not attached like other Views (since it isn't really a View)
|
||||
@@ -408,7 +411,7 @@ void MDIViewPage::onDeleteObject(const App::DocumentObject& obj)
|
||||
//if this page has a QView for this obj, delete it.
|
||||
blockSceneSelection(true);
|
||||
if (obj.isDerivedFrom(TechDraw::DrawView::getClassTypeId())) {
|
||||
(void) m_view->removeQViewByName(obj.getNameInDocument());
|
||||
(void) m_scene->removeQViewByName(obj.getNameInDocument());
|
||||
}
|
||||
blockSceneSelection(false);
|
||||
}
|
||||
@@ -432,7 +435,7 @@ void MDIViewPage::updateTemplate(bool forceUpdate)
|
||||
if(forceUpdate ||
|
||||
(templObj && templObj->isTouched() && templObj->isDerivedFrom(TechDraw::DrawTemplate::getClassTypeId())) ) {
|
||||
|
||||
QGITemplate *qItemTemplate = m_view->getTemplate();
|
||||
QGITemplate *qItemTemplate = m_scene->getTemplate();
|
||||
|
||||
if(qItemTemplate) {
|
||||
TechDraw::DrawTemplate *pageTemplate = dynamic_cast<TechDraw::DrawTemplate *>(templObj);
|
||||
@@ -470,13 +473,13 @@ void MDIViewPage::fixOrphans(bool force)
|
||||
if (dv->isRemoving()) {
|
||||
continue;
|
||||
}
|
||||
QGIView* qv = m_view->findQViewForDocObj(dv);
|
||||
QGIView* qv = m_scene->findQViewForDocObj(dv);
|
||||
if (qv == nullptr) {
|
||||
attachView(dv);
|
||||
}
|
||||
}
|
||||
// if qView doesn't have a Feature on this Page, delete it
|
||||
std::vector<QGIView*> qvss = m_view->getViews();
|
||||
std::vector<QGIView*> qvss = m_scene->getViews();
|
||||
// qvss may contain an item and its child item(s) and to avoid to access a deleted item a QPointer is needed
|
||||
std::vector<QPointer<QGIView>> qvs;
|
||||
std::for_each(qvss.begin(), qvss.end(), [&qvs](QGIView* v) {
|
||||
@@ -489,21 +492,21 @@ void MDIViewPage::fixOrphans(bool force)
|
||||
App::DocumentObject* obj = doc->getObject(qv->getViewName());
|
||||
if (obj == nullptr) {
|
||||
//no DrawView anywhere in Document
|
||||
m_view->removeQView(qv);
|
||||
m_scene->removeQView(qv);
|
||||
} else {
|
||||
//DrawView exists in Document. Does it belong to this DrawPage?
|
||||
int numParentPages = qv->getViewObject()->countParentPages();
|
||||
if (numParentPages == 0) {
|
||||
//DrawView does not belong to any DrawPage
|
||||
//remove QGItem from QGScene
|
||||
m_view->removeQView(qv);
|
||||
m_scene->removeQView(qv);
|
||||
} else if (numParentPages == 1) {
|
||||
//Does DrawView belong to this DrawPage?
|
||||
TechDraw::DrawPage* pp = qv->getViewObject()->findParentPage();
|
||||
if (thisPage != pp) {
|
||||
//DrawView does not belong to this DrawPage
|
||||
//remove QGItem from QGScene
|
||||
m_view->removeQView(qv);
|
||||
m_scene->removeQView(qv);
|
||||
}
|
||||
} else if (numParentPages > 1) {
|
||||
//DrawView belongs to multiple DrawPages
|
||||
@@ -519,7 +522,7 @@ void MDIViewPage::fixOrphans(bool force)
|
||||
}
|
||||
if (!found) {
|
||||
//none of the parent Pages for View correspond to this Page
|
||||
m_view->removeQView(qv);
|
||||
m_scene->removeQView(qv);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -529,7 +532,7 @@ void MDIViewPage::fixOrphans(bool force)
|
||||
//NOTE: this doesn't add missing views. see fixOrphans()
|
||||
void MDIViewPage::redrawAllViews()
|
||||
{
|
||||
const std::vector<QGIView *> &upviews = m_view->getViews();
|
||||
const std::vector<QGIView *> &upviews = m_scene->getViews();
|
||||
for(std::vector<QGIView *>::const_iterator it = upviews.begin(); it != upviews.end(); ++it) {
|
||||
(*it)->updateView(true);
|
||||
}
|
||||
@@ -539,7 +542,7 @@ void MDIViewPage::redrawAllViews()
|
||||
void MDIViewPage::redraw1View(TechDraw::DrawView* dv)
|
||||
{
|
||||
std::string dvName = dv->getNameInDocument();
|
||||
const std::vector<QGIView *> &upviews = m_view->getViews();
|
||||
const std::vector<QGIView *> &upviews = m_scene->getViews();
|
||||
for(std::vector<QGIView *>::const_iterator it = upviews.begin(); it != upviews.end(); ++it) {
|
||||
std::string qgivName = (*it)->getViewName();
|
||||
if(dvName == qgivName) {
|
||||
@@ -572,7 +575,7 @@ void MDIViewPage::findMissingViews(const std::vector<App::DocumentObject*> &list
|
||||
/// Helper function
|
||||
bool MDIViewPage::hasQView(App::DocumentObject *obj)
|
||||
{
|
||||
const std::vector<QGIView *> &views = m_view->getViews();
|
||||
const std::vector<QGIView *> &views = m_scene->getViews();
|
||||
std::vector<QGIView *>::const_iterator qview = views.begin();
|
||||
|
||||
while(qview != views.end()) {
|
||||
@@ -807,7 +810,7 @@ void MDIViewPage::print(QPrinter* printer)
|
||||
bool saveState = m_vpPage->getFrameState();
|
||||
m_vpPage->setFrameState(false);
|
||||
m_vpPage->setTemplateMarkers(false);
|
||||
m_view->refreshViews();
|
||||
m_scene->refreshViews();
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
|
||||
@@ -821,12 +824,12 @@ void MDIViewPage::print(QPrinter* printer)
|
||||
}
|
||||
QRectF sourceRect(0.0,-height,width,height);
|
||||
|
||||
m_view->scene()->render(&p, targetRect,sourceRect);
|
||||
m_scene->render(&p, targetRect,sourceRect);
|
||||
|
||||
// Reset
|
||||
m_vpPage->setFrameState(saveState);
|
||||
m_vpPage->setTemplateMarkers(saveState);
|
||||
m_view->refreshViews();
|
||||
m_scene->refreshViews();
|
||||
//bool block =
|
||||
static_cast<void> (blockSelection(false));
|
||||
}
|
||||
@@ -842,6 +845,7 @@ PyObject* MDIViewPage::getPyObject()
|
||||
|
||||
void MDIViewPage::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
// Base::Console().Message("MDIVP::contextMenuEvent() - reason: %d\n", event->reason());
|
||||
QMenu menu;
|
||||
menu.addAction(m_toggleFrameAction);
|
||||
menu.addAction(m_toggleKeepUpdatedAction);
|
||||
@@ -864,8 +868,7 @@ void MDIViewPage::toggleKeepUpdated(void)
|
||||
|
||||
void MDIViewPage::viewAll()
|
||||
{
|
||||
//m_view->fitInView(m_view->scene()->sceneRect(), Qt::KeepAspectRatio);
|
||||
m_view->fitInView(m_view->scene()->itemsBoundingRect(), Qt::KeepAspectRatio);
|
||||
m_view->fitInView(m_scene->itemsBoundingRect(), Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
void MDIViewPage::saveSVG()
|
||||
@@ -880,7 +883,7 @@ void MDIViewPage::saveSVG()
|
||||
}
|
||||
static_cast<void> (blockSelection(true)); // avoid to be notified by itself
|
||||
|
||||
m_view->saveSvg(fn);
|
||||
m_scene->saveSvg(fn);
|
||||
}
|
||||
|
||||
void MDIViewPage::saveSVG(std::string file)
|
||||
@@ -890,7 +893,7 @@ void MDIViewPage::saveSVG(std::string file)
|
||||
return;
|
||||
}
|
||||
QString filename = QString::fromUtf8(file.data(),file.size());
|
||||
m_view->saveSvg(filename);
|
||||
m_scene->saveSvg(filename);
|
||||
}
|
||||
|
||||
void MDIViewPage::saveDXF()
|
||||
@@ -1007,7 +1010,7 @@ void MDIViewPage::clearSceneSelection()
|
||||
blockSceneSelection(true);
|
||||
m_qgSceneSelected.clear();
|
||||
|
||||
std::vector<QGIView *> views = m_view->getViews();
|
||||
std::vector<QGIView *> views = m_scene->getViews();
|
||||
|
||||
// Iterate through all views and unselect all
|
||||
for (std::vector<QGIView *>::iterator it = views.begin(); it != views.end(); ++it) {
|
||||
@@ -1037,7 +1040,7 @@ void MDIViewPage::clearSceneSelection()
|
||||
//!Update QGIView's selection state based on Selection made outside Drawing Interface
|
||||
void MDIViewPage::selectQGIView(App::DocumentObject *obj, const bool isSelected)
|
||||
{
|
||||
QGIView *view = m_view->findQViewForDocObj(obj);
|
||||
QGIView *view = m_scene->findQViewForDocObj(obj);
|
||||
|
||||
blockSceneSelection(true);
|
||||
if(view) {
|
||||
@@ -1081,7 +1084,7 @@ void MDIViewPage::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
void MDIViewPage::sceneSelectionManager()
|
||||
{
|
||||
// Base::Console().Message("MDIVP::sceneSelectionManager()\n");
|
||||
QList<QGraphicsItem*> sceneSel = m_view->scene()->selectedItems();
|
||||
QList<QGraphicsItem*> sceneSel = m_scene->selectedItems();
|
||||
|
||||
if (sceneSel.isEmpty()) {
|
||||
m_qgSceneSelected.clear(); //TODO: need to signal somebody? Tree? handled elsewhere
|
||||
@@ -1124,13 +1127,11 @@ void MDIViewPage::sceneSelectionManager()
|
||||
}
|
||||
|
||||
//! update Tree Selection from QGraphicsScene selection
|
||||
//triggered by m_view->scene() signal
|
||||
//triggered by m_scene signal
|
||||
void MDIViewPage::sceneSelectionChanged()
|
||||
{
|
||||
sceneSelectionManager();
|
||||
|
||||
// QList<QGraphicsItem*> dbsceneSel = m_view->scene()->selectedItems();
|
||||
|
||||
if(isSelectionBlocked) {
|
||||
return;
|
||||
}
|
||||
@@ -1393,7 +1394,8 @@ void MDIViewPage::showStatusMsg(const char* s1, const char* s2, const char* s3)
|
||||
}
|
||||
}
|
||||
|
||||
MDIViewPage *MDIViewPage::getFromScene(const QGraphicsScene *scene)
|
||||
//return the MDIViewPage that owns the scene
|
||||
MDIViewPage *MDIViewPage::getFromScene(const QGSPage *scene)
|
||||
{
|
||||
if (scene != nullptr && scene->parent() != nullptr) {
|
||||
return dynamic_cast<MDIViewPage *>(scene->parent());
|
||||
|
||||
@@ -51,6 +51,7 @@ namespace TechDrawGui
|
||||
|
||||
class ViewProviderPage;
|
||||
class QGVPage;
|
||||
class QGSPage;
|
||||
class QGIView;
|
||||
|
||||
class TechDrawGuiExport MDIViewPage : public Gui::MDIView, public Gui::SelectionObserver
|
||||
@@ -98,8 +99,8 @@ public:
|
||||
TechDraw::DrawPage * getPage() { return m_vpPage->getDrawPage(); }
|
||||
|
||||
QGVPage* getQGVPage(void) {return m_view;}
|
||||
|
||||
QGraphicsScene* m_scene;
|
||||
QGSPage* getQGSPage(void) {return m_scene;}
|
||||
ViewProviderPage* getViewProviderPage() {return m_vpPage;}
|
||||
|
||||
QPointF getTemplateCenter(TechDraw::DrawTemplate *obj);
|
||||
void centerOnPage(void);
|
||||
@@ -111,7 +112,7 @@ public:
|
||||
|
||||
bool addView(const App::DocumentObject *obj);
|
||||
|
||||
static MDIViewPage *getFromScene(const QGraphicsScene *scene);
|
||||
static MDIViewPage *getFromScene(const QGSPage *scene);
|
||||
|
||||
public Q_SLOTS:
|
||||
void viewAll();
|
||||
@@ -129,7 +130,7 @@ protected:
|
||||
bool hasQView(App::DocumentObject *obj);
|
||||
bool orphanExists(const char *viewName, const std::vector<App::DocumentObject*> &list);
|
||||
|
||||
/// Attaches view of obj to m_view. Returns true on success, false otherwise
|
||||
/// Attaches view of obj to m_scene. Returns true on success, false otherwise
|
||||
bool attachView(App::DocumentObject *obj);
|
||||
|
||||
void contextMenuEvent(QContextMenuEvent *event);
|
||||
@@ -161,6 +162,7 @@ private:
|
||||
std::string m_objectName;
|
||||
std::string m_documentName;
|
||||
bool isSelectionBlocked;
|
||||
QGSPage* m_scene;
|
||||
QGVPage *m_view;
|
||||
QTimer *m_timer;
|
||||
|
||||
@@ -171,7 +173,7 @@ private:
|
||||
ViewProviderPage *m_vpPage;
|
||||
|
||||
QList<QGraphicsItem*> m_qgSceneSelected; //items in selection order
|
||||
QList<QGIView *> deleteItems;
|
||||
// QList<QGIView *> deleteItems;
|
||||
};
|
||||
|
||||
class MDIViewPagePy : public Py::PythonExtension<MDIViewPagePy>
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
QGIDrawingTemplate::QGIDrawingTemplate(QGraphicsScene *scene) : QGITemplate(scene),
|
||||
QGIDrawingTemplate::QGIDrawingTemplate(QGSPage* scene) : QGITemplate(scene),
|
||||
pathItem(nullptr)
|
||||
{
|
||||
pathItem = new QGraphicsPathItem;
|
||||
|
||||
@@ -36,13 +36,14 @@ class DrawParametricTemplate;
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGSPage;
|
||||
|
||||
class TechDrawGuiExport QGIDrawingTemplate : public QGITemplate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QGIDrawingTemplate(QGraphicsScene *);
|
||||
QGIDrawingTemplate(QGSPage *);
|
||||
~QGIDrawingTemplate();
|
||||
|
||||
enum {Type = QGraphicsItem::UserType + 151};
|
||||
|
||||
@@ -48,12 +48,13 @@
|
||||
|
||||
#include "Rez.h"
|
||||
#include "ZVALUE.h"
|
||||
#include "QGSPage.h"
|
||||
#include "TemplateTextField.h"
|
||||
#include "QGISVGTemplate.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
QGISVGTemplate::QGISVGTemplate(QGraphicsScene *scene)
|
||||
QGISVGTemplate::QGISVGTemplate(QGSPage* scene)
|
||||
: QGITemplate(scene),
|
||||
firstTime(true)
|
||||
{
|
||||
|
||||
@@ -39,13 +39,14 @@ class DrawSVGTemplate;
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGSPage;
|
||||
|
||||
class TechDrawGuiExport QGISVGTemplate : public QGITemplate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QGISVGTemplate(QGraphicsScene *scene);
|
||||
QGISVGTemplate(QGSPage* scene);
|
||||
virtual ~QGISVGTemplate();
|
||||
|
||||
enum {Type = QGraphicsItem::UserType + 153};
|
||||
|
||||
@@ -32,11 +32,12 @@
|
||||
|
||||
#include "ZVALUE.h"
|
||||
#include "TemplateTextField.h"
|
||||
#include "QGSPage.h"
|
||||
#include "QGITemplate.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
QGITemplate::QGITemplate(QGraphicsScene *scene) : QGraphicsItemGroup(),
|
||||
QGITemplate::QGITemplate(QGSPage *scene) : QGraphicsItemGroup(),
|
||||
pageTemplate(nullptr)
|
||||
{
|
||||
setHandlesChildEvents(false);
|
||||
|
||||
@@ -37,13 +37,14 @@ class DrawTemplate;
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class TemplateTextField;
|
||||
class QGSPage;
|
||||
|
||||
class TechDrawGuiExport QGITemplate : public QObject, public QGraphicsItemGroup
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QGITemplate(QGraphicsScene *);
|
||||
QGITemplate(QGSPage *);
|
||||
~QGITemplate();
|
||||
|
||||
enum {Type = QGraphicsItem::UserType + 150};
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include "Rez.h"
|
||||
#include "ZVALUE.h"
|
||||
#include "DrawGuiUtil.h"
|
||||
#include "QGSPage.h"
|
||||
#include "QGVPage.h"
|
||||
#include "QGCustomLabel.h"
|
||||
#include "QGCustomBorder.h"
|
||||
@@ -628,9 +629,24 @@ QGVPage* QGIView::getGraphicsView(TechDraw::DrawView* dv)
|
||||
return graphicsView;
|
||||
}
|
||||
|
||||
QGSPage* QGIView::getGraphicsScene(TechDraw::DrawView* dv)
|
||||
{
|
||||
QGSPage* graphicsScene = nullptr;
|
||||
Gui::ViewProvider* vp = getViewProvider(dv);
|
||||
ViewProviderDrawingView* vpdv = dynamic_cast<ViewProviderDrawingView*>(vp);
|
||||
if (vpdv != nullptr) {
|
||||
MDIViewPage* mdi = vpdv->getMDIViewPage();
|
||||
if (mdi != nullptr) {
|
||||
graphicsScene = mdi->getQGSPage();
|
||||
}
|
||||
}
|
||||
return graphicsScene;
|
||||
}
|
||||
|
||||
MDIViewPage* QGIView::getMDIViewPage(void) const
|
||||
{
|
||||
return MDIViewPage::getFromScene(scene());
|
||||
QGSPage* qgsp = static_cast<QGSPage*>(scene());
|
||||
return MDIViewPage::getFromScene(qgsp);
|
||||
}
|
||||
|
||||
//remove a child of this from scene while keeping scene indexes valid
|
||||
|
||||
@@ -58,6 +58,7 @@ class DrawView;
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGSPage;
|
||||
class QGVPage;
|
||||
class QGCustomBorder;
|
||||
class QGCustomLabel;
|
||||
@@ -129,6 +130,7 @@ public:
|
||||
|
||||
static Gui::ViewProvider* getViewProvider(App::DocumentObject* obj);
|
||||
static QGVPage* getGraphicsView(TechDraw::DrawView* dv);
|
||||
static QGSPage* getGraphicsScene(TechDraw::DrawView* dv);
|
||||
static int calculateFontPixelSize(double sizeInMillimetres);
|
||||
static int calculateFontPixelWidth(const QFont &font);
|
||||
static const double DefaultFontSizeInMM;
|
||||
|
||||
@@ -578,7 +578,6 @@ void QGIViewBalloon::placeBalloon(QPointF pos)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QGIView* qgivParent = nullptr;
|
||||
QPointF viewPos;
|
||||
Gui::ViewProvider* objVp = QGIView::getViewProvider(balloonParent);
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#ifndef DRAWINGGUI_QGRAPHICSITEMVIEWDIMENSION_H
|
||||
#define DRAWINGGUI_QGRAPHICSITEMVIEWDIMENSION_H
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include <QColor>
|
||||
#include <QFont>
|
||||
#include <QGraphicsItem>
|
||||
@@ -47,6 +49,7 @@ class AOC;
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGCustomText;
|
||||
class QGIArrow;
|
||||
class QGIDimLines;
|
||||
class QGIViewDimension;
|
||||
|
||||
910
src/Mod/TechDraw/Gui/QGSPage.cpp
Normal file
910
src/Mod/TechDraw/Gui/QGSPage.cpp
Normal file
@@ -0,0 +1,910 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2020 Wanderer Fan <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 <QAction>
|
||||
# include <QApplication>
|
||||
# include <QContextMenuEvent>
|
||||
# include <QFileInfo>
|
||||
# include <QFileDialog>
|
||||
# include <QGLWidget>
|
||||
# include <QGraphicsEffect>
|
||||
# include <QMouseEvent>
|
||||
# include <QPainter>
|
||||
# include <QPaintEvent>
|
||||
# include <QSvgGenerator>
|
||||
#include <QScrollBar>
|
||||
# include <QWheelEvent>
|
||||
#include <QTemporaryFile>
|
||||
#include <QDomDocument>
|
||||
#include <QTextStream>
|
||||
#include <QFile>
|
||||
#include <QLabel>
|
||||
#include <QTextCodec>
|
||||
#include <cmath>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/Material.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Parameter.h>
|
||||
#include <Base/Stream.h>
|
||||
#include <Gui/FileDialog.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/WaitCursor.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/View3DInventor.h>
|
||||
#include <Gui/View3DInventorViewer.h>
|
||||
|
||||
#include <Mod/TechDraw/App/Geometry.h>
|
||||
#include <Mod/TechDraw/App/DrawPage.h>
|
||||
#include <Mod/TechDraw/App/DrawTemplate.h>
|
||||
#include <Mod/TechDraw/App/DrawSVGTemplate.h>
|
||||
#include <Mod/TechDraw/App/DrawParametricTemplate.h>
|
||||
#include <Mod/TechDraw/App/DrawViewCollection.h>
|
||||
#include <Mod/TechDraw/App/DrawViewBalloon.h>
|
||||
#include <Mod/TechDraw/App/DrawViewDimension.h>
|
||||
//#include <Mod/TechDraw/App/LandmarkDimension.h>
|
||||
#include <Mod/TechDraw/App/DrawProjGroup.h>
|
||||
#include <Mod/TechDraw/App/DrawViewPart.h>
|
||||
#include <Mod/TechDraw/App/DrawViewAnnotation.h>
|
||||
#include <Mod/TechDraw/App/DrawViewSymbol.h>
|
||||
#include <Mod/TechDraw/App/DrawViewClip.h>
|
||||
#include <Mod/TechDraw/App/DrawHatch.h>
|
||||
#include <Mod/TechDraw/App/DrawViewSpreadsheet.h>
|
||||
#include <Mod/TechDraw/App/DrawViewImage.h>
|
||||
#include <Mod/TechDraw/App/DrawLeaderLine.h>
|
||||
#include <Mod/TechDraw/App/DrawRichAnno.h>
|
||||
#include <Mod/TechDraw/App/DrawWeldSymbol.h>
|
||||
#include <Mod/TechDraw/App/DrawTile.h>
|
||||
#include <Mod/TechDraw/App/DrawTileWeld.h>
|
||||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
|
||||
#include "Rez.h"
|
||||
#include "PreferencesGui.h"
|
||||
#include "QGIDrawingTemplate.h"
|
||||
#include "QGITemplate.h"
|
||||
#include "QGISVGTemplate.h"
|
||||
#include "TemplateTextField.h"
|
||||
#include "QGIViewCollection.h"
|
||||
#include "QGIViewDimension.h"
|
||||
#include "QGIViewBalloon.h"
|
||||
#include "QGIProjGroup.h"
|
||||
#include "QGIViewPart.h"
|
||||
#include "QGIViewSection.h"
|
||||
#include "QGIViewAnnotation.h"
|
||||
#include "QGIViewSymbol.h"
|
||||
#include "QGIViewClip.h"
|
||||
#include "QGIViewSpreadsheet.h"
|
||||
#include "QGIViewImage.h"
|
||||
#include "QGIFace.h"
|
||||
#include "QGILeaderLine.h"
|
||||
#include "QGIRichAnno.h"
|
||||
#include "QGIWeldSymbol.h"
|
||||
#include "QGITile.h"
|
||||
|
||||
#include "ZVALUE.h"
|
||||
#include "ViewProviderPage.h"
|
||||
#include "QGSPage.h"
|
||||
#include "MDIViewPage.h"
|
||||
|
||||
// used SVG namespaces
|
||||
#define CC_NS_URI "http://creativecommons.org/ns#"
|
||||
#define DC_NS_URI "http://purl.org/dc/elements/1.1/"
|
||||
#define RDF_NS_URI "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
#define INKSCAPE_NS_URI "http://www.inkscape.org/namespaces/inkscape"
|
||||
#define SODIPODI_NS_URI "http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
|
||||
using namespace Gui;
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGui;
|
||||
|
||||
QGSPage::QGSPage(ViewProviderPage *vp, QWidget *parent)
|
||||
: QGraphicsScene(parent),
|
||||
pageTemplate(nullptr),
|
||||
m_renderer(Native),
|
||||
drawBkg(true),
|
||||
m_vpPage(nullptr)
|
||||
{
|
||||
assert(vp);
|
||||
m_vpPage = vp;
|
||||
const char* name = vp->getDrawPage()->getNameInDocument();
|
||||
setObjectName(QString::fromLocal8Bit(name));
|
||||
m_vpPage->setGraphicsScene(this);
|
||||
|
||||
bkgBrush = new QBrush(getBackgroundColor());
|
||||
|
||||
}
|
||||
|
||||
QGSPage::~QGSPage()
|
||||
{
|
||||
delete bkgBrush;
|
||||
|
||||
}
|
||||
|
||||
//! retrieve the QGIView objects currently in the scene
|
||||
std::vector<QGIView *> QGSPage::getViews() const
|
||||
{
|
||||
std::vector<QGIView*> result;
|
||||
QList<QGraphicsItem*> items = this->items();
|
||||
for (auto& v:items) {
|
||||
QGIView* qv = dynamic_cast<QGIView*>(v);
|
||||
if (qv != nullptr) {
|
||||
result.push_back(qv);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int QGSPage::addQView(QGIView *view)
|
||||
{
|
||||
//don't add twice!
|
||||
QGIView* existing = getQGIVByName(view->getViewName());
|
||||
if (existing == nullptr) {
|
||||
addItem(view);
|
||||
|
||||
// Find if it belongs to a parent
|
||||
QGIView *parent = nullptr;
|
||||
parent = findParent(view);
|
||||
|
||||
QPointF viewPos(Rez::guiX(view->getViewObject()->X.getValue()),
|
||||
Rez::guiX(view->getViewObject()->Y.getValue() * -1));
|
||||
|
||||
if(parent) {
|
||||
// move child view to center of parent
|
||||
QPointF posRef(0.,0.);
|
||||
QPointF mapPos = view->mapToItem(parent, posRef);
|
||||
view->moveBy(-mapPos.x(), -mapPos.y());
|
||||
|
||||
parent->addToGroup(view);
|
||||
}
|
||||
|
||||
view->setPos(viewPos);
|
||||
view->updateView(true);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int QGSPage::removeQView(QGIView *view)
|
||||
{
|
||||
if (view != nullptr) {
|
||||
removeQViewFromScene(view);
|
||||
delete view;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int QGSPage::removeQViewByName(const char* name)
|
||||
{
|
||||
std::vector<QGIView*> items = getViews();
|
||||
QString qsName = QString::fromUtf8(name);
|
||||
bool found = false;
|
||||
QGIView* ourItem = nullptr;
|
||||
for (auto& i:items) {
|
||||
if (qsName == i->data(1).toString()) { //is there a QGIV with this name in scene?
|
||||
found = true;
|
||||
ourItem = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
int balloonItemType = QGraphicsItem::UserType + 140;
|
||||
if (ourItem->type() == balloonItemType) {
|
||||
QGIViewBalloon* balloon = dynamic_cast<QGIViewBalloon*>(ourItem);
|
||||
balloon->disconnect();
|
||||
}
|
||||
removeQViewFromScene(ourItem);
|
||||
delete ourItem; //commenting this prevents crash but means a small memory waste.
|
||||
//alternate fix(?) is to change indexing/caching option in scene/view
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QGSPage::removeQViewFromScene(QGIView *view)
|
||||
{
|
||||
QGIView* qgParent = dynamic_cast<QGIView*>(view->parentItem());
|
||||
if (qgParent != nullptr) {
|
||||
qgParent->removeChild(view);
|
||||
} else {
|
||||
removeItem(view);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QGIView * QGSPage::addViewPart(TechDraw::DrawViewPart *part)
|
||||
{
|
||||
// Base::Console().Message("QGSP::addViewPart(%s)\n", part->getNameInDocument());
|
||||
QGIView* existing = findQViewForDocObj(part);
|
||||
if (existing != nullptr) {
|
||||
return existing;
|
||||
}
|
||||
|
||||
auto viewPart( new QGIViewPart );
|
||||
|
||||
viewPart->setViewPartFeature(part);
|
||||
|
||||
addQView(viewPart);
|
||||
return viewPart;
|
||||
}
|
||||
|
||||
QGIView * QGSPage::addViewSection(TechDraw::DrawViewPart *part)
|
||||
{
|
||||
auto viewSection( new QGIViewSection );
|
||||
|
||||
viewSection->setViewPartFeature(part);
|
||||
|
||||
addQView(viewSection);
|
||||
return viewSection;
|
||||
}
|
||||
|
||||
QGIView * QGSPage::addProjectionGroup(TechDraw::DrawProjGroup *view) {
|
||||
auto qview( new QGIProjGroup );
|
||||
|
||||
qview->setViewFeature(view);
|
||||
addQView(qview);
|
||||
return qview;
|
||||
}
|
||||
|
||||
QGIView * QGSPage::addDrawView(TechDraw::DrawView *view)
|
||||
{
|
||||
auto qview( new QGIView );
|
||||
|
||||
qview->setViewFeature(view);
|
||||
addQView(qview);
|
||||
return qview;
|
||||
}
|
||||
|
||||
QGIView * QGSPage::addDrawViewCollection(TechDraw::DrawViewCollection *view)
|
||||
{
|
||||
auto qview( new QGIViewCollection );
|
||||
|
||||
qview->setViewFeature(view);
|
||||
addQView(qview);
|
||||
return qview;
|
||||
}
|
||||
|
||||
QGIView * QGSPage::addDrawViewAnnotation(TechDraw::DrawViewAnnotation *view)
|
||||
{
|
||||
auto qview( new QGIViewAnnotation );
|
||||
|
||||
qview->setViewAnnoFeature(view);
|
||||
|
||||
addQView(qview);
|
||||
return qview;
|
||||
}
|
||||
|
||||
QGIView * QGSPage::addDrawViewSymbol(TechDraw::DrawViewSymbol *view)
|
||||
{
|
||||
auto qview( new QGIViewSymbol );
|
||||
|
||||
qview->setViewFeature(view);
|
||||
|
||||
addQView(qview);
|
||||
return qview;
|
||||
}
|
||||
|
||||
QGIView * QGSPage::addDrawViewClip(TechDraw::DrawViewClip *view)
|
||||
{
|
||||
auto qview( new QGIViewClip );
|
||||
|
||||
qview->setPosition(Rez::guiX(view->X.getValue()), Rez::guiX(view->Y.getValue()));
|
||||
qview->setViewFeature(view);
|
||||
|
||||
addQView(qview);
|
||||
return qview;
|
||||
}
|
||||
|
||||
QGIView * QGSPage::addDrawViewSpreadsheet(TechDraw::DrawViewSpreadsheet *view)
|
||||
{
|
||||
auto qview( new QGIViewSpreadsheet );
|
||||
|
||||
qview->setViewFeature(view);
|
||||
|
||||
addQView(qview);
|
||||
return qview;
|
||||
}
|
||||
|
||||
QGIView * QGSPage::addDrawViewImage(TechDraw::DrawViewImage *view)
|
||||
{
|
||||
auto qview( new QGIViewImage );
|
||||
|
||||
qview->setViewFeature(view);
|
||||
|
||||
addQView(qview);
|
||||
return qview;
|
||||
}
|
||||
|
||||
QGIView * QGSPage::addViewBalloon(TechDraw::DrawViewBalloon *balloon)
|
||||
{
|
||||
// Base::Console().Message("QGSP::addViewBalloon(%s)\n", balloon->getNameInDocument());
|
||||
auto vBalloon( new QGIViewBalloon );
|
||||
|
||||
addItem(vBalloon);
|
||||
|
||||
vBalloon->setViewPartFeature(balloon);
|
||||
vBalloon->dvBalloon = balloon;
|
||||
|
||||
QGIView *parent = nullptr;
|
||||
parent = findParent(vBalloon);
|
||||
|
||||
if (parent) {
|
||||
addBalloonToParent(vBalloon,parent);
|
||||
}
|
||||
|
||||
return vBalloon;
|
||||
}
|
||||
|
||||
void QGSPage::addBalloonToParent(QGIViewBalloon* balloon, QGIView* parent)
|
||||
{
|
||||
// Base::Console().Message("QGSP::addBalloonToParent()\n");
|
||||
assert(balloon);
|
||||
assert(parent); //blow up if we don't have Dimension or Parent
|
||||
QPointF posRef(0.,0.);
|
||||
QPointF mapPos = balloon->mapToItem(parent, posRef);
|
||||
balloon->moveBy(-mapPos.x(), -mapPos.y());
|
||||
parent->addToGroup(balloon);
|
||||
balloon->setZValue(ZVALUE::DIMENSION);
|
||||
}
|
||||
|
||||
//origin is in scene coordinates from QGViewPage
|
||||
void QGSPage::createBalloon(QPointF origin, DrawViewPart *parent)
|
||||
{
|
||||
// Base::Console().Message("QGSP::createBalloon(%s)\n", DrawUtil::formatVector(origin).c_str());
|
||||
std::string featName = getDrawPage()->getDocument()->getUniqueObjectName("Balloon");
|
||||
std::string pageName = getDrawPage()->getNameInDocument();
|
||||
|
||||
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create Balloon"));
|
||||
Command::doCommand(Command::Doc, "App.activeDocument().addObject('TechDraw::DrawViewBalloon','%s')", featName.c_str());
|
||||
TechDraw::DrawViewBalloon *balloon = dynamic_cast<TechDraw::DrawViewBalloon *>(getDrawPage()->getDocument()->getObject(featName.c_str()));
|
||||
if (!balloon) {
|
||||
throw Base::TypeError("QGSP::createBalloon - balloon not found\n");
|
||||
}
|
||||
Command::doCommand(Command::Doc,"App.activeDocument().%s.SourceView = (App.activeDocument().%s)",
|
||||
featName.c_str(), parent->getNameInDocument());
|
||||
|
||||
QGIView* qgParent = getQGIVByName(parent->getNameInDocument());
|
||||
//convert from scene coords to qgParent coords and unscale
|
||||
QPointF parentOrigin = qgParent->mapFromScene(origin) / parent->getScale();
|
||||
balloon->setOrigin(parentOrigin);
|
||||
//convert origin to App side coords
|
||||
QPointF appOrigin = Rez::appPt(parentOrigin);
|
||||
appOrigin = DrawUtil::invertY(appOrigin);
|
||||
balloon->OriginX.setValue(appOrigin.x());
|
||||
balloon->OriginY.setValue(appOrigin.y());
|
||||
double textOffset = 20.0 / parent->getScale();
|
||||
balloon->X.setValue(appOrigin.x() + textOffset);
|
||||
balloon->Y.setValue(appOrigin.y() + textOffset);
|
||||
|
||||
int idx = getDrawPage()->getNextBalloonIndex();
|
||||
QString labelText = QString::number(idx);
|
||||
balloon->Text.setValue(std::to_string(idx).c_str());
|
||||
|
||||
Command::doCommand(Command::Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", pageName.c_str(), featName.c_str());
|
||||
|
||||
Gui::Command::commitCommand();
|
||||
}
|
||||
|
||||
QGIView * QGSPage::addViewDimension(TechDraw::DrawViewDimension *dim)
|
||||
{
|
||||
auto dimGroup( new QGIViewDimension );
|
||||
|
||||
addItem(dimGroup);
|
||||
|
||||
dimGroup->setViewPartFeature(dim);
|
||||
dimGroup->dvDimension = dim;
|
||||
|
||||
// Find if it belongs to a parent
|
||||
QGIView *parent = nullptr;
|
||||
parent = findParent(dimGroup);
|
||||
|
||||
if(parent) {
|
||||
addDimToParent(dimGroup,parent);
|
||||
}
|
||||
|
||||
return dimGroup;
|
||||
}
|
||||
|
||||
void QGSPage::addDimToParent(QGIViewDimension* dim, QGIView* parent)
|
||||
{
|
||||
// Base::Console().Message("QGVP::addDimToParent()\n");
|
||||
assert(dim);
|
||||
assert(parent); //blow up if we don't have Dimension or Parent
|
||||
QPointF posRef(0.,0.);
|
||||
QPointF mapPos = dim->mapToItem(parent, posRef);
|
||||
dim->moveBy(-mapPos.x(), -mapPos.y());
|
||||
parent->addToGroup(dim);
|
||||
dim->setZValue(ZVALUE::DIMENSION);
|
||||
}
|
||||
|
||||
QGIView * QGSPage::addViewLeader(TechDraw::DrawLeaderLine *leader)
|
||||
{
|
||||
// Base::Console().Message("QGVP::addViewLeader(%s)\n",leader->getNameInDocument());
|
||||
QGILeaderLine* leaderGroup = new QGILeaderLine();
|
||||
addItem(leaderGroup);
|
||||
|
||||
leaderGroup->setLeaderFeature(leader);
|
||||
|
||||
QGIView *parent = nullptr;
|
||||
parent = findParent(leaderGroup);
|
||||
|
||||
if(parent) {
|
||||
addLeaderToParent(leaderGroup,parent);
|
||||
}
|
||||
|
||||
leaderGroup->updateView(true);
|
||||
|
||||
return leaderGroup;
|
||||
}
|
||||
|
||||
void QGSPage::addLeaderToParent(QGILeaderLine* lead, QGIView* parent)
|
||||
{
|
||||
// Base::Console().Message("QGVP::addLeaderToParent()\n");
|
||||
parent->addToGroup(lead);
|
||||
lead->setZValue(ZVALUE::DIMENSION);
|
||||
}
|
||||
|
||||
QGIView * QGSPage::addRichAnno(TechDraw::DrawRichAnno* anno)
|
||||
{
|
||||
QGIRichAnno* annoGroup = nullptr;
|
||||
TechDraw::DrawView* parentDV = nullptr;
|
||||
|
||||
App::DocumentObject* parentObj = anno->AnnoParent.getValue();
|
||||
if (parentObj != nullptr) {
|
||||
parentDV = dynamic_cast<TechDraw::DrawView*>(parentObj);
|
||||
}
|
||||
if (parentDV != nullptr) {
|
||||
QGIView* parentQV = findQViewForDocObj(parentObj);
|
||||
annoGroup = new QGIRichAnno(parentQV, anno);
|
||||
annoGroup->updateView(true);
|
||||
} else {
|
||||
annoGroup = new QGIRichAnno(nullptr, anno);
|
||||
addItem(annoGroup);
|
||||
annoGroup->updateView(true);
|
||||
}
|
||||
return annoGroup;
|
||||
}
|
||||
|
||||
QGIView * QGSPage::addWeldSymbol(TechDraw::DrawWeldSymbol* weld)
|
||||
{
|
||||
// Base::Console().Message("QGVP::addWeldSymbol()\n");
|
||||
QGIWeldSymbol* weldGroup = nullptr;
|
||||
TechDraw::DrawView* parentDV = nullptr;
|
||||
|
||||
App::DocumentObject* parentObj = weld->Leader.getValue();
|
||||
if (parentObj != nullptr) {
|
||||
parentDV = dynamic_cast<TechDraw::DrawView*>(parentObj);
|
||||
} else {
|
||||
// Base::Console().Message("QGVP::addWeldSymbol - no parent doc obj\n");
|
||||
}
|
||||
if (parentDV != nullptr) {
|
||||
QGIView* parentQV = findQViewForDocObj(parentObj);
|
||||
QGILeaderLine* leadParent = dynamic_cast<QGILeaderLine*>(parentQV);
|
||||
if (leadParent != nullptr) {
|
||||
weldGroup = new QGIWeldSymbol(leadParent);
|
||||
weldGroup->setFeature(weld); //for QGIWS
|
||||
weldGroup->setViewFeature(weld); //for QGIV
|
||||
weldGroup->updateView(true);
|
||||
} else {
|
||||
Base::Console().Error("QGVP::addWeldSymbol - no parent QGILL\n");
|
||||
}
|
||||
} else {
|
||||
Base::Console().Error("QGVP::addWeldSymbol - parent is not DV!\n");
|
||||
}
|
||||
return weldGroup;
|
||||
}
|
||||
|
||||
|
||||
//! find the graphic for a DocumentObject
|
||||
QGIView * QGSPage::findQViewForDocObj(App::DocumentObject *obj) const
|
||||
{
|
||||
if(obj) {
|
||||
const std::vector<QGIView *> qviews = getViews();
|
||||
for(std::vector<QGIView *>::const_iterator it = qviews.begin(); it != qviews.end(); ++it) {
|
||||
if(strcmp(obj->getNameInDocument(), (*it)->getViewName()) == 0)
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//! find the graphic for DocumentObject with name
|
||||
QGIView* QGSPage::getQGIVByName(std::string name)
|
||||
{
|
||||
QList<QGraphicsItem*> qgItems = items();
|
||||
QList<QGraphicsItem*>::iterator it = qgItems.begin();
|
||||
for (; it != qgItems.end(); it++) {
|
||||
QGIView* qv = dynamic_cast<QGIView*>((*it));
|
||||
if (qv) {
|
||||
const char* qvName = qv->getViewName();
|
||||
if(name.compare(qvName) == 0) {
|
||||
return (qv);
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//find the parent of a QGIV based on the corresponding feature's parentage
|
||||
QGIView * QGSPage::findParent(QGIView *view) const
|
||||
{
|
||||
const std::vector<QGIView *> qviews = getViews();
|
||||
TechDraw::DrawView *myFeat = view->getViewObject();
|
||||
|
||||
//If type is dimension we check references first
|
||||
TechDraw::DrawViewDimension *dim = nullptr;
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(myFeat);
|
||||
if(dim) {
|
||||
std::vector<App::DocumentObject *> objs = dim->References2D.getValues();
|
||||
|
||||
if(objs.size() > 0) {
|
||||
std::vector<App::DocumentObject *> objs = dim->References2D.getValues();
|
||||
// Attach the dimension to the first object's group
|
||||
for(std::vector<QGIView *>::const_iterator it = qviews.begin(); it != qviews.end(); ++it) {
|
||||
if(strcmp((*it)->getViewName(), objs.at(0)->getNameInDocument()) == 0) {
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If type is balloon we check references first
|
||||
TechDraw::DrawViewBalloon *balloon = nullptr;
|
||||
balloon = dynamic_cast<TechDraw::DrawViewBalloon *>(myFeat);
|
||||
|
||||
if(balloon) {
|
||||
App::DocumentObject* obj = balloon->SourceView.getValue();
|
||||
|
||||
if(obj) {
|
||||
// Attach the dimension to the first object's group
|
||||
for(std::vector<QGIView *>::const_iterator it = qviews.begin(); it != qviews.end(); ++it) {
|
||||
if(strcmp((*it)->getViewName(), obj->getNameInDocument()) == 0) {
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if part of view collection
|
||||
for(std::vector<QGIView *>::const_iterator it = qviews.begin(); it != qviews.end(); ++it) {
|
||||
QGIViewCollection *grp = nullptr;
|
||||
grp = dynamic_cast<QGIViewCollection *>(*it);
|
||||
if(grp) {
|
||||
TechDraw::DrawViewCollection *collection = nullptr;
|
||||
collection = dynamic_cast<TechDraw::DrawViewCollection *>(grp->getViewObject());
|
||||
if(collection) {
|
||||
std::vector<App::DocumentObject *> objs = collection->Views.getValues();
|
||||
for( std::vector<App::DocumentObject *>::iterator it = objs.begin(); it != objs.end(); ++it) {
|
||||
if(strcmp(myFeat->getNameInDocument(), (*it)->getNameInDocument()) == 0)
|
||||
|
||||
return grp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If type is LeaderLine we check LeaderParent
|
||||
TechDraw::DrawLeaderLine *lead = nullptr;
|
||||
lead = dynamic_cast<TechDraw::DrawLeaderLine *>(myFeat);
|
||||
|
||||
if(lead) {
|
||||
App::DocumentObject* obj = lead->LeaderParent.getValue();
|
||||
if(obj != nullptr) {
|
||||
std::string parentName = obj->getNameInDocument();
|
||||
for(std::vector<QGIView *>::const_iterator it = qviews.begin(); it != qviews.end(); ++it) {
|
||||
if(strcmp((*it)->getViewName(), parentName.c_str()) == 0) {
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Not found a parent
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void QGSPage::setPageTemplate(TechDraw::DrawTemplate *obj)
|
||||
{
|
||||
removeTemplate();
|
||||
|
||||
if(obj->isDerivedFrom(TechDraw::DrawParametricTemplate::getClassTypeId())) {
|
||||
pageTemplate = new QGIDrawingTemplate(this);
|
||||
} else if(obj->isDerivedFrom(TechDraw::DrawSVGTemplate::getClassTypeId())) {
|
||||
pageTemplate = new QGISVGTemplate(this);
|
||||
}
|
||||
pageTemplate->setTemplate(obj);
|
||||
pageTemplate->updateView();
|
||||
}
|
||||
|
||||
QGITemplate* QGSPage::getTemplate() const
|
||||
{
|
||||
return pageTemplate;
|
||||
}
|
||||
|
||||
void QGSPage::removeTemplate()
|
||||
{
|
||||
if(pageTemplate) {
|
||||
removeItem(pageTemplate);
|
||||
pageTemplate->deleteLater();
|
||||
pageTemplate = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void QGSPage::refreshViews(void)
|
||||
{
|
||||
// Base::Console().Message("QGVP::refreshViews()\n");
|
||||
QList<QGraphicsItem*> list = items();
|
||||
QList<QGraphicsItem*> qgiv;
|
||||
//find only QGIV's
|
||||
for (auto q: list) {
|
||||
QString viewFamily = QString::fromUtf8("QGIV");
|
||||
if (viewFamily == q->data(0).toString()) {
|
||||
qgiv.push_back(q);
|
||||
}
|
||||
}
|
||||
for (auto q: qgiv) {
|
||||
QGIView *itemView = dynamic_cast<QGIView *>(q);
|
||||
if(itemView) {
|
||||
itemView->updateView(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QGSPage::setExporting(bool enable)
|
||||
{
|
||||
QList<QGraphicsItem*> sceneItems = items();
|
||||
std::vector<QGIViewPart*> dvps;
|
||||
for (auto& qgi:sceneItems) {
|
||||
QGIViewPart* qgiPart = dynamic_cast<QGIViewPart *>(qgi);
|
||||
QGIRichAnno* qgiRTA = dynamic_cast<QGIRichAnno *>(qgi);
|
||||
if(qgiPart) {
|
||||
qgiPart->setExporting(enable);
|
||||
dvps.push_back(qgiPart);
|
||||
}
|
||||
if (qgiRTA) {
|
||||
qgiRTA->setExporting(enable);
|
||||
}
|
||||
}
|
||||
for (auto& v: dvps) {
|
||||
v->draw();
|
||||
}
|
||||
}
|
||||
|
||||
void QGSPage::saveSvg(QString filename)
|
||||
{
|
||||
// TODO: We only have m_vpPage because constructor gets passed a view provider...
|
||||
//NOTE: this makes wrong size pages in low-Rez
|
||||
TechDraw::DrawPage *page( m_vpPage->getDrawPage() );
|
||||
|
||||
const QString docName( QString::fromUtf8(page->getDocument()->getName()) );
|
||||
const QString pageName( QString::fromUtf8(page->getNameInDocument()) );
|
||||
QString svgDescription = QString::fromUtf8("Drawing page: ") +
|
||||
pageName +
|
||||
QString::fromUtf8(" exported from FreeCAD document: ") +
|
||||
docName;
|
||||
|
||||
QSvgGenerator svgGen;
|
||||
QTemporaryFile temporaryFile;
|
||||
svgGen.setOutputDevice(&temporaryFile);
|
||||
|
||||
// Set resolution in DPI. Use the actual one, i.e. Rez::guiX(inch)
|
||||
svgGen.setResolution(Rez::guiX(25.4));
|
||||
|
||||
// Set size in pixels, which Qt recomputes using DPI to mm.
|
||||
int pixelWidth = Rez::guiX(page->getPageWidth());
|
||||
int pixelHeight = Rez::guiX(page->getPageHeight());
|
||||
svgGen.setSize(QSize(pixelWidth, pixelHeight));
|
||||
|
||||
//"By default this property is set to QSize(-1, -1), which indicates that the generator should not output
|
||||
// the width and height attributes of the <svg> element." >> but Inkscape won't read it without size info??
|
||||
svgGen.setViewBox(QRect(0, 0, pixelWidth, pixelHeight));
|
||||
|
||||
svgGen.setTitle(QString::fromUtf8("FreeCAD SVG Export"));
|
||||
svgGen.setDescription(svgDescription);
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
|
||||
bool saveState = m_vpPage->getFrameState();
|
||||
m_vpPage->setFrameState(false);
|
||||
m_vpPage->setTemplateMarkers(false);
|
||||
setExporting(true);
|
||||
|
||||
// Here we temporarily hide the page template, because Qt would otherwise convert the SVG template
|
||||
// texts into series of paths, making the later document edits practically unfeasible.
|
||||
// We will insert the SVG template ourselves in the final XML postprocessing operation.
|
||||
QGISVGTemplate *svgTemplate = dynamic_cast<QGISVGTemplate *>(pageTemplate);
|
||||
bool templateVisible = false;
|
||||
if (svgTemplate) {
|
||||
templateVisible = svgTemplate->isVisible();
|
||||
svgTemplate->hide();
|
||||
}
|
||||
|
||||
refreshViews();
|
||||
// viewport()->repaint();
|
||||
|
||||
double width = Rez::guiX(page->getPageWidth());
|
||||
double height = Rez::guiX(page->getPageHeight());
|
||||
QRectF sourceRect(0.0,-height,width,height);
|
||||
QRectF targetRect(0.0,0.0,width,height);
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
QPainter p;
|
||||
|
||||
p.begin(&svgGen);
|
||||
render(&p, targetRect,sourceRect); //note: scene render, not item render!
|
||||
p.end();
|
||||
|
||||
m_vpPage->setFrameState(saveState);
|
||||
m_vpPage->setTemplateMarkers(saveState);
|
||||
setExporting(false);
|
||||
if (templateVisible && svgTemplate) {
|
||||
svgTemplate->show();
|
||||
}
|
||||
|
||||
refreshViews();
|
||||
// viewport()->repaint();
|
||||
|
||||
temporaryFile.close();
|
||||
postProcessXml(temporaryFile, filename, pageName);
|
||||
}
|
||||
|
||||
static void removeEmptyGroups(QDomElement e)
|
||||
{
|
||||
while (!e.isNull()) {
|
||||
QDomElement next = e.nextSiblingElement();
|
||||
if (e.hasChildNodes()) {
|
||||
removeEmptyGroups(e.firstChildElement());
|
||||
} else if (e.tagName() == QLatin1String("g")) {
|
||||
e.parentNode().removeChild(e);
|
||||
}
|
||||
e = next;
|
||||
}
|
||||
}
|
||||
|
||||
void QGSPage::postProcessXml(QTemporaryFile& temporaryFile, QString fileName, QString pageName)
|
||||
{
|
||||
QDomDocument exportDoc(QString::fromUtf8("SvgDoc"));
|
||||
QFile file(temporaryFile.fileName());
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
Base::Console().Message("QGSPage::ppsvg - tempfile open error\n");
|
||||
return;
|
||||
}
|
||||
if (!exportDoc.setContent(&file)) {
|
||||
Base::Console().Message("QGSPage::ppsvg - xml error\n");
|
||||
file.close();
|
||||
return;
|
||||
}
|
||||
file.close();
|
||||
|
||||
QDomElement exportDocElem = exportDoc.documentElement(); //root <svg>
|
||||
|
||||
// Insert Freecad SVG namespace into namespace declarations
|
||||
exportDocElem.setAttribute(QString::fromUtf8("xmlns:freecad"),
|
||||
QString::fromUtf8(FREECAD_SVG_NS_URI));
|
||||
// Insert all namespaces used by TechDraw's page template SVGs
|
||||
exportDocElem.setAttribute(QString::fromUtf8("xmlns:svg"),
|
||||
QString::fromUtf8(SVG_NS_URI));
|
||||
exportDocElem.setAttribute(QString::fromUtf8("xmlns:cc"),
|
||||
QString::fromUtf8(CC_NS_URI));
|
||||
exportDocElem.setAttribute(QString::fromUtf8("xmlns:dc"),
|
||||
QString::fromUtf8(DC_NS_URI));
|
||||
exportDocElem.setAttribute(QString::fromUtf8("xmlns:rdf"),
|
||||
QString::fromUtf8(RDF_NS_URI));
|
||||
exportDocElem.setAttribute(QString::fromUtf8("xmlns:inkscape"),
|
||||
QString::fromUtf8(INKSCAPE_NS_URI));
|
||||
exportDocElem.setAttribute(QString::fromUtf8("xmlns:sodipodi"),
|
||||
QString::fromUtf8(SODIPODI_NS_URI));
|
||||
|
||||
// Create the root group which will host the drawing group and the template group
|
||||
QDomElement rootGroup = exportDoc.createElement(QString::fromUtf8("g"));
|
||||
rootGroup.setAttribute(QString::fromUtf8("id"), pageName);
|
||||
rootGroup.setAttribute(QString::fromUtf8("inkscape:groupmode"),
|
||||
QString::fromUtf8("layer"));
|
||||
rootGroup.setAttribute(QString::fromUtf8("inkscape:label"),
|
||||
QString::fromUtf8("TechDraw"));
|
||||
|
||||
// Now insert our template
|
||||
QGISVGTemplate *svgTemplate = dynamic_cast<QGISVGTemplate *>(pageTemplate);
|
||||
if (svgTemplate) {
|
||||
DrawSVGTemplate *drawTemplate = svgTemplate->getSVGTemplate();
|
||||
if (drawTemplate) {
|
||||
QFile templateResultFile(QString::fromUtf8(drawTemplate->PageResult.getValue()));
|
||||
if (templateResultFile.open(QIODevice::ReadOnly)) {
|
||||
QDomDocument templateResultDoc(QString::fromUtf8("SvgDoc"));
|
||||
if (templateResultDoc.setContent(&templateResultFile)) {
|
||||
QDomElement templateDocElem = templateResultDoc.documentElement();
|
||||
|
||||
// Insert the template into a new group with id set to template name
|
||||
QDomElement templateGroup = exportDoc.createElement(QString::fromUtf8("g"));
|
||||
Base::FileInfo fi(drawTemplate->Template.getValue());
|
||||
templateGroup.setAttribute(QString::fromUtf8("id"),
|
||||
QString::fromUtf8(fi.fileName().c_str()));
|
||||
templateGroup.setAttribute(QString::fromUtf8("style"),
|
||||
QString::fromUtf8("stroke: none;"));
|
||||
|
||||
// Scale the template group correctly
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
templateGroup.setAttribute(QString::fromUtf8("transform"),
|
||||
QString().sprintf("scale(%f, %f)", Rez::guiX(1.0), Rez::guiX(1.0)));
|
||||
#else
|
||||
templateGroup.setAttribute(QString::fromUtf8("transform"),
|
||||
QString::fromLatin1("scale(%1, %2)").arg(Rez::guiX(1.0), 0, 'f').arg(Rez::guiX(1.0), 0, 'f'));
|
||||
#endif
|
||||
|
||||
// Finally, transfer all template document child nodes under the template group
|
||||
while (!templateDocElem.firstChild().isNull()) {
|
||||
templateGroup.appendChild(templateDocElem.firstChild());
|
||||
}
|
||||
|
||||
rootGroup.appendChild(templateGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Obtain the drawing group element, move it under root node and set its id to "DrawingContent"
|
||||
QDomElement drawingGroup = exportDocElem.firstChildElement(QLatin1String("g"));
|
||||
if (!drawingGroup.isNull()) {
|
||||
drawingGroup.setAttribute(QString::fromUtf8("id"), QString::fromUtf8("DrawingContent"));
|
||||
rootGroup.appendChild(drawingGroup);
|
||||
}
|
||||
exportDocElem.appendChild(rootGroup);
|
||||
|
||||
// As icing on the cake, get rid of the empty <g>'s Qt SVG generator painting inserts.
|
||||
removeEmptyGroups(exportDocElem);
|
||||
|
||||
// Time to save our product
|
||||
QFile outFile( fileName );
|
||||
if( !outFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) {
|
||||
Base::Console().Message("QGVP::ppxml - failed to open file for writing: %s\n",qPrintable(fileName) );
|
||||
}
|
||||
|
||||
QTextStream stream( &outFile );
|
||||
stream.setGenerateByteOrderMark(false);
|
||||
stream.setCodec("UTF-8");
|
||||
|
||||
stream << exportDoc.toByteArray();
|
||||
outFile.close();
|
||||
}
|
||||
|
||||
TechDraw::DrawPage* QGSPage::getDrawPage()
|
||||
{
|
||||
return m_vpPage->getDrawPage();
|
||||
}
|
||||
|
||||
QColor QGSPage::getBackgroundColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("Background", 0x70707000));
|
||||
return fcColor.asValue<QColor>();
|
||||
}
|
||||
|
||||
|
||||
#include <Mod/TechDraw/Gui/moc_QGSPage.cpp>
|
||||
149
src/Mod/TechDraw/Gui/QGSPage.h
Normal file
149
src/Mod/TechDraw/Gui/QGSPage.h
Normal file
@@ -0,0 +1,149 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 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_QGSCENE_H
|
||||
#define TECHDRAWGUI_QGSCENE_H
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include <QGraphicsScene>
|
||||
|
||||
class QTemporaryFile;
|
||||
class QLabel;
|
||||
|
||||
namespace App {
|
||||
class DocumentObject;
|
||||
}
|
||||
|
||||
namespace TechDraw {
|
||||
class DrawView;
|
||||
class DrawViewPart;
|
||||
class DrawProjGroup;
|
||||
class DrawViewDimension;
|
||||
class DrawPage;
|
||||
class DrawTemplate;
|
||||
class DrawViewAnnotation;
|
||||
class DrawViewSymbol;
|
||||
class DrawViewClip;
|
||||
class DrawViewCollection;
|
||||
class DrawViewSpreadsheet;
|
||||
class DrawViewImage;
|
||||
class DrawLeaderLine;
|
||||
class DrawViewBalloon;
|
||||
class DrawRichAnno;
|
||||
class DrawWeldSymbol;
|
||||
}
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGIView;
|
||||
class QGIViewDimension;
|
||||
class QGITemplate;
|
||||
class ViewProviderPage;
|
||||
class QGIViewBalloon;
|
||||
class QGILeaderLine;
|
||||
class QGIRichAnno;
|
||||
class QGITile;
|
||||
|
||||
class TechDrawGuiExport QGSPage : public QGraphicsScene
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum RendererType { Native, OpenGL, Image };
|
||||
|
||||
QGSPage(ViewProviderPage *vp, QWidget *parent = nullptr);
|
||||
virtual ~QGSPage();
|
||||
|
||||
QGIView * addViewDimension(TechDraw::DrawViewDimension *dim);
|
||||
QGIView * addViewBalloon(TechDraw::DrawViewBalloon *balloon);
|
||||
QGIView * addProjectionGroup(TechDraw::DrawProjGroup *view);
|
||||
QGIView * addViewPart(TechDraw::DrawViewPart *part);
|
||||
QGIView * addViewSection(TechDraw::DrawViewPart *part);
|
||||
QGIView * addDrawView(TechDraw::DrawView *view);
|
||||
QGIView * addDrawViewCollection(TechDraw::DrawViewCollection *view);
|
||||
QGIView * addDrawViewAnnotation(TechDraw::DrawViewAnnotation *view);
|
||||
QGIView * addDrawViewSymbol(TechDraw::DrawViewSymbol *view);
|
||||
QGIView * addDrawViewClip(TechDraw::DrawViewClip *view);
|
||||
QGIView * addDrawViewSpreadsheet(TechDraw::DrawViewSpreadsheet *view);
|
||||
QGIView * addDrawViewImage(TechDraw::DrawViewImage *view);
|
||||
QGIView * addViewLeader(TechDraw::DrawLeaderLine* view);
|
||||
QGIView * addRichAnno(TechDraw::DrawRichAnno* anno);
|
||||
QGIView * addWeldSymbol(TechDraw::DrawWeldSymbol* weld);
|
||||
|
||||
QGIView* findQViewForDocObj(App::DocumentObject *obj) const;
|
||||
QGIView* getQGIVByName(std::string name);
|
||||
QGIView* findParent(QGIView *) const;
|
||||
|
||||
void addBalloonToParent(QGIViewBalloon* balloon, QGIView* parent);
|
||||
void createBalloon(QPointF origin, TechDraw::DrawViewPart *parent);
|
||||
|
||||
void addDimToParent(QGIViewDimension* dim, QGIView* parent);
|
||||
void addLeaderToParent(QGILeaderLine* lead, QGIView* parent);
|
||||
|
||||
std::vector<QGIView *> getViews() const;
|
||||
|
||||
int addQView(QGIView * view);
|
||||
int removeQView(QGIView *view);
|
||||
int removeQViewByName(const char* name);
|
||||
void removeQViewFromScene(QGIView *view);
|
||||
|
||||
void setPageTemplate(TechDraw::DrawTemplate *pageTemplate);
|
||||
|
||||
QGITemplate * getTemplate() const;
|
||||
void removeTemplate();
|
||||
|
||||
TechDraw::DrawPage * getDrawPage();
|
||||
|
||||
void setExporting(bool enable);
|
||||
virtual void refreshViews(void);
|
||||
|
||||
/// Renders the page to SVG with filename.
|
||||
void saveSvg(QString filename);
|
||||
void postProcessXml(QTemporaryFile& tempFile, QString filename, QString pagename);
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
protected:
|
||||
static QColor SelectColor;
|
||||
static QColor PreselectColor;
|
||||
QColor getBackgroundColor();
|
||||
|
||||
|
||||
QGITemplate *pageTemplate;
|
||||
|
||||
private:
|
||||
RendererType m_renderer;
|
||||
|
||||
bool drawBkg;
|
||||
QBrush* bkgBrush;
|
||||
QImage m_image;
|
||||
ViewProviderPage *m_vpPage;
|
||||
|
||||
QLabel *balloonCursor;
|
||||
QPoint balloonCursorPos;
|
||||
QPoint balloonHotspot;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // TECHDRAWGUI_QGSCENE_H
|
||||
@@ -46,13 +46,14 @@
|
||||
|
||||
#include "Rez.h"
|
||||
#include "ZVALUE.h"
|
||||
#include "QGSPage.h"
|
||||
#include "DrawGuiUtil.h"
|
||||
#include "QGIView.h"
|
||||
#include "QGTracker.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
QGTracker::QGTracker(QGraphicsScene* inScene, TrackerMode m):
|
||||
QGTracker::QGTracker(QGSPage* inScene, TrackerMode m):
|
||||
m_sleep(false),
|
||||
m_qgParent(nullptr),
|
||||
m_lastClick(QPointF(FLT_MAX,FLT_MAX))
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#ifndef DRAWINGGUI_TRACKER_H
|
||||
#define DRAWINGGUI_TRACKER_H
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include <QGraphicsItem>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -37,13 +39,16 @@ QT_END_NAMESPACE
|
||||
namespace TechDrawGui
|
||||
{
|
||||
|
||||
class QGSPage;
|
||||
class QGIView;
|
||||
|
||||
class TechDrawGuiExport QGTracker : public QObject, public QGIPrimPath
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum TrackerMode { None, Line, Circle, Rectangle, Point };
|
||||
|
||||
explicit QGTracker(QGraphicsScene* scene = nullptr, QGTracker::TrackerMode m = QGTracker::TrackerMode::None);
|
||||
explicit QGTracker(QGSPage* scene = nullptr, QGTracker::TrackerMode m = QGTracker::TrackerMode::None);
|
||||
~QGTracker();
|
||||
|
||||
|
||||
|
||||
414
src/Mod/TechDraw/Gui/QGVNavStyle.cpp
Normal file
414
src/Mod/TechDraw/Gui/QGVNavStyle.cpp
Normal file
@@ -0,0 +1,414 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 <QApplication>
|
||||
#include <QKeyEvent>
|
||||
#include <QScrollBar>
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Parameter.h>
|
||||
|
||||
#include <App/Application.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawPage.h>
|
||||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
|
||||
#include "QGVNavStyle.h"
|
||||
#include "QGVPage.h"
|
||||
#include "QGSPage.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
QGVNavStyle::QGVNavStyle() : m_viewer(nullptr)
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
|
||||
QGVNavStyle::~QGVNavStyle()
|
||||
{
|
||||
}
|
||||
|
||||
void QGVNavStyle::initialize()
|
||||
{
|
||||
this->button1down = false;
|
||||
this->button2down = false;
|
||||
this->button3down = false;
|
||||
this->ctrldown = false;
|
||||
this->shiftdown = false;
|
||||
this->altdown = false;
|
||||
this->invertZoom = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View")->GetBool("InvertZoom",true);
|
||||
this->zoomAtCursor = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View")->GetBool("ZoomAtCursor",true);
|
||||
this->zoomStep = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View")->GetFloat("ZoomStep",0.2f);
|
||||
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
|
||||
m_reversePan = hGrp->GetInt("KbPan",1);
|
||||
m_reverseScroll = hGrp->GetInt("KbScroll",1);
|
||||
|
||||
panningActive = false;
|
||||
zoomingActive = false;
|
||||
m_clickPending = false;
|
||||
m_panPending = false;
|
||||
m_zoomPending = false;
|
||||
m_clickButton = Qt::NoButton;
|
||||
}
|
||||
|
||||
void QGVNavStyle::setAnchor()
|
||||
{
|
||||
if (m_viewer != nullptr) {
|
||||
if (zoomAtCursor) {
|
||||
m_viewer->setResizeAnchor(QGraphicsView::AnchorUnderMouse);
|
||||
m_viewer->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
||||
} else {
|
||||
m_viewer->setResizeAnchor(QGraphicsView::AnchorViewCenter);
|
||||
m_viewer->setTransformationAnchor(QGraphicsView::AnchorViewCenter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyle::handleEnterEvent(QEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
getViewer()->getBalloonCursor()->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyle::handleFocusOutEvent(QFocusEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
getViewer()->cancelBalloonPlacing();
|
||||
}
|
||||
|
||||
void QGVNavStyle::handleKeyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if(event->modifiers().testFlag(Qt::ControlModifier)) {
|
||||
switch(event->key()) {
|
||||
case Qt::Key_Plus: {
|
||||
zoom(1.0 + zoomStep);
|
||||
event->accept();
|
||||
break;
|
||||
}
|
||||
case Qt::Key_Minus: {
|
||||
zoom(1.0 - zoomStep);
|
||||
event->accept();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(event->modifiers().testFlag( Qt::NoModifier)) {
|
||||
switch(event->key()) {
|
||||
case Qt::Key_Left: {
|
||||
getViewer()->kbPanScroll(1, 0);
|
||||
event->accept();
|
||||
break;
|
||||
}
|
||||
case Qt::Key_Up: {
|
||||
getViewer()->kbPanScroll(0, 1);
|
||||
event->accept();
|
||||
break;
|
||||
}
|
||||
case Qt::Key_Right: {
|
||||
getViewer()->kbPanScroll(-1, 0);
|
||||
event->accept();
|
||||
break;
|
||||
}
|
||||
case Qt::Key_Down: {
|
||||
getViewer()->kbPanScroll(0, -1);
|
||||
event->accept();
|
||||
break;
|
||||
}
|
||||
case Qt::Key_Escape: {
|
||||
getViewer()->cancelBalloonPlacing();
|
||||
event->accept();
|
||||
break;
|
||||
}
|
||||
case Qt::Key_Shift: {
|
||||
this->shiftdown = true;
|
||||
Base::Console().Message("QGVNS::handleKeyPressEvent - shift pressed\n");
|
||||
event->accept();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyle::handleKeyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
// Q_UNUSED(event);
|
||||
if(event->modifiers().testFlag( Qt::NoModifier)) {
|
||||
switch(event->key()) {
|
||||
case Qt::Key_Shift: {
|
||||
this->shiftdown = false;
|
||||
Base::Console().Message("QGVNS::handleKeyPressEvent - shift released\n");
|
||||
event->accept();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyle::handleLeaveEvent(QEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
int left_x;
|
||||
if (getViewer()->getBalloonCursorPos().x() < 32)
|
||||
left_x = 0;
|
||||
else if (getViewer()->getBalloonCursorPos().x() > (getViewer()->contentsRect().right() - 32))
|
||||
left_x = getViewer()->contentsRect().right() - 32;
|
||||
else
|
||||
left_x = getViewer()->getBalloonCursorPos().x();
|
||||
|
||||
int left_y;
|
||||
if (getViewer()->getBalloonCursorPos().y() < 32)
|
||||
left_y = 0;
|
||||
else if (getViewer()->getBalloonCursorPos().y() > (getViewer()->contentsRect().bottom() - 32))
|
||||
left_y = getViewer()->contentsRect().bottom() - 32;
|
||||
else
|
||||
left_y = getViewer()->getBalloonCursorPos().y();
|
||||
|
||||
/* When cursor leave the page, display getViewer()->balloonCursor where it left */
|
||||
getViewer()->getBalloonCursor()->setGeometry(left_x ,left_y, 32, 32);
|
||||
getViewer()->getBalloonCursor()->show();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyle::handleMousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
// Base::Console().Message("QGVNS::handleMousePressEvent()\n");
|
||||
if (!panningActive && (event->button() == Qt::MiddleButton)) {
|
||||
startPan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyle::handleMouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
// Base::Console().Message("QGVNS::handleMouseMoveEvent()\n");
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
getViewer()->setBalloonCursorPos(event->pos());
|
||||
}
|
||||
|
||||
if (panningActive) {
|
||||
pan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyle::handleMouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
placeBalloon(event->pos());
|
||||
}
|
||||
|
||||
if (panningActive && (event->button() == Qt::MiddleButton)) {
|
||||
stopPan();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyle::handleWheelEvent(QWheelEvent *event)
|
||||
{
|
||||
//Delta is the distance that the wheel is rotated, in eighths of a degree.
|
||||
//positive indicates rotation forwards away from the user; negative backwards toward the user.
|
||||
//Most mouse types work in steps of 15 degrees, in which case the delta value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees.
|
||||
//1 click = 15 degrees. 15 degrees = 120 deltas. delta/240 -> 1 click = 0.5 ==> factor = 1.2^0.5 = 1.095
|
||||
// 1 click = -0.5 ==> factor = 1.2^-0.5 = 0.91
|
||||
//so to change wheel direction, multiply (event->delta() / 240.0) by +/-1
|
||||
double mouseBase = 1.2; //magic numbers. change for different mice?
|
||||
double mouseAdjust = -240.0;
|
||||
if (invertZoom) {
|
||||
mouseAdjust = -mouseAdjust;
|
||||
}
|
||||
|
||||
int delta = event->angleDelta().y();
|
||||
qreal factor = std::pow(mouseBase, delta / mouseAdjust);
|
||||
zoom(factor);
|
||||
}
|
||||
|
||||
void QGVNavStyle::zoom(double factor)
|
||||
{
|
||||
QPoint center = getViewer()->viewport()->rect().center();
|
||||
getViewer()->scale(factor,
|
||||
factor);
|
||||
|
||||
QPoint newCenter = getViewer()->viewport()->rect().center();
|
||||
QPoint change = newCenter - center;
|
||||
getViewer()->translate(change.x(), change.y());
|
||||
}
|
||||
|
||||
void QGVNavStyle::startZoom(QPoint p)
|
||||
{
|
||||
// Base::Console().Message("QGVNS::startZoom(%s)\n", TechDraw::DrawUtil::formatVector(p).c_str());
|
||||
zoomOrigin = p;
|
||||
zoomingActive = true;
|
||||
}
|
||||
|
||||
double QGVNavStyle::mouseZoomFactor(QPoint p)
|
||||
{
|
||||
|
||||
// Base::Console().Message("QGVNS::mouseZoomFactor(%s)\n", TechDraw::DrawUtil::formatVector(p).c_str());
|
||||
QPoint movement = p - zoomOrigin;
|
||||
double sensitivity = 0.1;
|
||||
double direction = 1.0;
|
||||
double invert = 1.0;
|
||||
if (movement.y() < 0.0) {
|
||||
direction = -direction;
|
||||
}
|
||||
if (invertZoom) {
|
||||
invert = -invert;
|
||||
}
|
||||
double factor = 1.0 + (direction * invert * zoomStep * sensitivity);
|
||||
zoomOrigin = p;
|
||||
return factor;
|
||||
}
|
||||
|
||||
void QGVNavStyle::startPan(QPoint p)
|
||||
{
|
||||
panOrigin = p;
|
||||
panningActive = true;
|
||||
QApplication::setOverrideCursor(Qt::SizeAllCursor);
|
||||
|
||||
}
|
||||
|
||||
void QGVNavStyle::pan(QPoint p)
|
||||
{
|
||||
QScrollBar *horizontalScrollbar = getViewer()->horizontalScrollBar();
|
||||
QScrollBar *verticalScrollbar = getViewer()->verticalScrollBar();
|
||||
QPoint direction = p - panOrigin;
|
||||
|
||||
horizontalScrollbar->setValue(horizontalScrollbar->value() - m_reversePan*direction.x());
|
||||
verticalScrollbar->setValue(verticalScrollbar->value() - m_reverseScroll*direction.y());
|
||||
|
||||
panOrigin = p;
|
||||
}
|
||||
|
||||
void QGVNavStyle::stopPan()
|
||||
{
|
||||
QApplication::restoreOverrideCursor();
|
||||
panningActive = false;
|
||||
}
|
||||
|
||||
void QGVNavStyle::startClick(Qt::MouseButton b)
|
||||
{
|
||||
m_clickPending = true;
|
||||
m_clickButton = b;
|
||||
}
|
||||
|
||||
void QGVNavStyle::stopClick(void)
|
||||
{
|
||||
m_clickPending = false;
|
||||
m_clickButton = Qt::MouseButton::NoButton;
|
||||
}
|
||||
|
||||
void QGVNavStyle::placeBalloon(QPoint p)
|
||||
{
|
||||
getViewer()->getBalloonCursor()->hide();
|
||||
getViewer()->getScene()->createBalloon(getViewer()->mapToScene(p),
|
||||
getViewer()->getDrawPage()->balloonParent);
|
||||
getViewer()->setBalloonPlacing(false);
|
||||
}
|
||||
|
||||
//****************************************
|
||||
KeyCombination::KeyCombination()
|
||||
{
|
||||
}
|
||||
|
||||
KeyCombination::~KeyCombination()
|
||||
{
|
||||
}
|
||||
|
||||
void KeyCombination::addKey(int inKey)
|
||||
{
|
||||
bool found = false;
|
||||
//check for inKey already in keys
|
||||
if (!keys.empty()) {
|
||||
for (auto& k: keys) {
|
||||
if (k == inKey) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
keys.push_back(inKey);
|
||||
}
|
||||
}
|
||||
|
||||
void KeyCombination::removeKey(int inKey)
|
||||
{
|
||||
std::vector<int> newKeys;
|
||||
for (auto& k: keys) {
|
||||
if (k != inKey) {
|
||||
newKeys.push_back(k);
|
||||
}
|
||||
}
|
||||
keys = newKeys;
|
||||
}
|
||||
|
||||
void KeyCombination::clear()
|
||||
{
|
||||
keys.clear();
|
||||
}
|
||||
|
||||
bool KeyCombination::empty()
|
||||
{
|
||||
return keys.empty();
|
||||
}
|
||||
|
||||
//does inCombo match the keys we have in current combination
|
||||
bool KeyCombination::haveCombination(int inCombo)
|
||||
{
|
||||
bool matched = false;
|
||||
int combo = 0; //no key
|
||||
if (keys.size() < 2) {
|
||||
//not enough keys for a combination
|
||||
return false;
|
||||
}
|
||||
for (auto& k: keys) {
|
||||
combo = combo | k;
|
||||
}
|
||||
if (combo == inCombo) {
|
||||
matched = true;
|
||||
}
|
||||
return matched;
|
||||
}
|
||||
|
||||
} //namespace TechDrawGui
|
||||
123
src/Mod/TechDraw/Gui/QGVNavStyle.h
Normal file
123
src/Mod/TechDraw/Gui/QGVNavStyle.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 TECHDRAW_NAVIGATIONSTYLE_H
|
||||
#include <QPoint>
|
||||
#define TECHDRAW_NAVIGATIONSTYLE_H
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
class QEvent;
|
||||
class QFocusEvent;
|
||||
class QKeyEvent;
|
||||
class QMouseEvent;
|
||||
class QWheelEvent;
|
||||
|
||||
#include <Base/BaseClass.h>
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
class QGVPage;
|
||||
|
||||
//class to support multiple key combinations
|
||||
class KeyCombination
|
||||
{
|
||||
public:
|
||||
KeyCombination();
|
||||
~KeyCombination();
|
||||
|
||||
void addKey(int inKey);
|
||||
void removeKey(int inKey);
|
||||
void clear();
|
||||
bool empty();
|
||||
|
||||
bool haveCombination(int inCombo);
|
||||
|
||||
private:
|
||||
std::vector<int> keys;
|
||||
};
|
||||
|
||||
class TechDrawGuiExport QGVNavStyle : public Base::BaseClass
|
||||
{
|
||||
public:
|
||||
QGVNavStyle();
|
||||
virtual ~QGVNavStyle();
|
||||
|
||||
void setViewer(QGVPage* qgvp) { m_viewer = qgvp;} ;
|
||||
QGVPage* getViewer() { return m_viewer;};
|
||||
|
||||
virtual void handleEnterEvent(QEvent *event);
|
||||
virtual void handleFocusOutEvent(QFocusEvent *event);
|
||||
virtual void handleKeyPressEvent(QKeyEvent *event);
|
||||
virtual void handleKeyReleaseEvent(QKeyEvent *event);
|
||||
virtual void handleLeaveEvent(QEvent *event);
|
||||
virtual void handleMouseMoveEvent(QMouseEvent *event);
|
||||
virtual void handleMousePressEvent(QMouseEvent *event);
|
||||
virtual void handleMouseReleaseEvent(QMouseEvent *event);
|
||||
virtual void handleWheelEvent(QWheelEvent *event);
|
||||
|
||||
virtual bool allowContextMenu() {return true;};
|
||||
|
||||
virtual void zoom(double factor);
|
||||
virtual double mouseZoomFactor(QPoint p);
|
||||
virtual void startZoom(QPoint p);
|
||||
|
||||
virtual void startPan(QPoint p);
|
||||
virtual void pan(QPoint p);
|
||||
virtual void stopPan();
|
||||
|
||||
virtual void startClick(Qt::MouseButton b);
|
||||
virtual void stopClick(void);
|
||||
|
||||
virtual void placeBalloon(QPoint p);
|
||||
|
||||
protected:
|
||||
virtual void initialize();
|
||||
virtual void setAnchor();
|
||||
QGVPage* m_viewer;
|
||||
int m_currentmode;
|
||||
|
||||
bool ctrldown, shiftdown, altdown;
|
||||
bool button1down, button2down, button3down;
|
||||
bool invertZoom;
|
||||
bool zoomAtCursor;
|
||||
double zoomStep;
|
||||
int m_reversePan;
|
||||
int m_reverseScroll;
|
||||
QPoint panOrigin;
|
||||
bool panningActive;
|
||||
QPoint zoomOrigin;
|
||||
bool zoomingActive;
|
||||
bool m_clickPending;
|
||||
bool m_panPending;
|
||||
bool m_zoomPending;
|
||||
Qt::MouseButton m_clickButton;
|
||||
|
||||
KeyCombination m_keyCombo;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif // TECHDRAW_NAVIGATIONSTYLE_H
|
||||
101
src/Mod/TechDraw/Gui/QGVNavStyleBlender.cpp
Normal file
101
src/Mod/TechDraw/Gui/QGVNavStyleBlender.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 <QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QMouseEvent>
|
||||
#endif
|
||||
|
||||
#include "QGVPage.h"
|
||||
#include "QGVNavStyleBlender.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
QGVNavStyleBlender::QGVNavStyleBlender()
|
||||
{
|
||||
}
|
||||
|
||||
QGVNavStyleBlender::~QGVNavStyleBlender()
|
||||
{
|
||||
}
|
||||
|
||||
void QGVNavStyleBlender::handleKeyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
if ((event->key() == Qt::Key_Shift) && panningActive) {
|
||||
stopPan();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleBlender::handleMousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->buttons() == (Qt::LeftButton | Qt::RightButton)) {
|
||||
//pan mode 1 - LMB + RMB + mouse move
|
||||
startPan(event->pos());
|
||||
event->accept();
|
||||
} else if ((event->button() == Qt::MiddleButton) &&
|
||||
QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier)) {
|
||||
//pan mode 2 - Shift + MMB
|
||||
startPan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleBlender::handleMouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
getViewer()->setBalloonCursorPos(event->pos());
|
||||
}
|
||||
|
||||
if (panningActive) {
|
||||
pan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleBlender::handleMouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
placeBalloon(event->pos());
|
||||
}
|
||||
|
||||
if (panningActive) {
|
||||
//pan mode 1 - LMB + RMB + mouse move
|
||||
//stop panning if either button release
|
||||
if ( (event->button() == Qt::LeftButton) ||
|
||||
(event->button() == Qt::RightButton)) {
|
||||
stopPan();
|
||||
event->accept();
|
||||
}
|
||||
//pan mode 2 - Shift + MMB
|
||||
//stop panning if MMB released
|
||||
if (event->button() == Qt::MiddleButton) {
|
||||
stopPan();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace TechDrawGui
|
||||
55
src/Mod/TechDraw/Gui/QGVNavStyleBlender.h
Normal file
55
src/Mod/TechDraw/Gui/QGVNavStyleBlender.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 TECHDRAW_BLENDERNAVSTYLE_H
|
||||
#define TECHDRAW_BLENDERNAVSTYLE_H
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include "QGVNavStyle.h"
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
class QGVPage;
|
||||
|
||||
class TechDrawGuiExport QGVNavStyleBlender : public QGVNavStyle
|
||||
{
|
||||
public:
|
||||
QGVNavStyleBlender();
|
||||
virtual ~QGVNavStyleBlender();
|
||||
|
||||
virtual void handleKeyReleaseEvent(QKeyEvent *event) override;
|
||||
virtual void handleMousePressEvent(QMouseEvent *event) override;
|
||||
virtual void handleMouseMoveEvent(QMouseEvent *event) override;
|
||||
virtual void handleMouseReleaseEvent(QMouseEvent *event) override;
|
||||
|
||||
//context menu (RMB) prevents pan mode 2 (LMB + RMB)
|
||||
virtual bool allowContextMenu() override {return false;};
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif // TECHDRAW_BLENDERNAVSTYLE_H
|
||||
150
src/Mod/TechDraw/Gui/QGVNavStyleCAD.cpp
Normal file
150
src/Mod/TechDraw/Gui/QGVNavStyleCAD.cpp
Normal file
@@ -0,0 +1,150 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 <QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QMouseEvent>
|
||||
#endif
|
||||
|
||||
#include "QGVPage.h"
|
||||
#include "QGVNavStyleCAD.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
QGVNavStyleCAD::QGVNavStyleCAD()
|
||||
{
|
||||
}
|
||||
|
||||
QGVNavStyleCAD::~QGVNavStyleCAD()
|
||||
{
|
||||
}
|
||||
|
||||
void QGVNavStyleCAD::handleKeyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
//zoom mode 2
|
||||
if ( ((event->key() == Qt::Key_Control) ||
|
||||
(event->key() == Qt::Key_Shift)) && zoomingActive) {
|
||||
zoomingActive = false;
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//pan mode 2
|
||||
if ((event->key() == Qt::Key_Control) && panningActive) {
|
||||
stopPan();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleCAD::handleMousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
//pan mode 1 hold MMB + mouse movement
|
||||
if (event->button() == Qt::MiddleButton) {
|
||||
startClick(Qt::MiddleButton); //for MMB center view
|
||||
startPan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//zoom mode 2 Control + Shift + RMB click
|
||||
if ((event->button() == Qt::RightButton) &&
|
||||
QApplication::keyboardModifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) {
|
||||
startClick(Qt::RightButton);
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//pan mode 2 Control + RMB click
|
||||
if ((event->button() == Qt::RightButton) &&
|
||||
QApplication::keyboardModifiers() == Qt::ControlModifier) {
|
||||
startClick(Qt::RightButton);
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleCAD::handleMouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
getViewer()->setBalloonCursorPos(event->pos());
|
||||
}
|
||||
|
||||
//if the mouse moves between press and release, then it isn't a click
|
||||
if (m_clickPending) {
|
||||
stopClick();
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
|
||||
if (panningActive) {
|
||||
pan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
|
||||
if (zoomingActive) {
|
||||
zoom(mouseZoomFactor(event->pos()));
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleCAD::handleMouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
placeBalloon(event->pos());
|
||||
}
|
||||
|
||||
if (event->button() == Qt::MiddleButton) {
|
||||
if (m_clickPending && (m_clickButton == Qt::MiddleButton)) {
|
||||
stopClick();
|
||||
getViewer()->centerOn(getViewer()->mapToScene(event->pos()));
|
||||
event->accept();
|
||||
}
|
||||
//pan mode 1 hold MMB + mouse move
|
||||
if (panningActive) {
|
||||
stopPan();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
//zoom mode 2 Control + Shift + RMB click
|
||||
if ((event->button() == Qt::RightButton) &&
|
||||
QApplication::keyboardModifiers() == (Qt::ControlModifier | Qt::ShiftModifier) &&
|
||||
m_clickPending) {
|
||||
stopClick();
|
||||
startZoom(event->pos());
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
|
||||
//pan mode 2 starts with Control + RMB click
|
||||
if ((event->button() == Qt::RightButton) &&
|
||||
QApplication::keyboardModifiers() == (Qt::ControlModifier) &&
|
||||
m_clickPending) {
|
||||
stopClick();
|
||||
startPan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
} // namespace TechDrawGui
|
||||
55
src/Mod/TechDraw/Gui/QGVNavStyleCAD.h
Normal file
55
src/Mod/TechDraw/Gui/QGVNavStyleCAD.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 TECHDRAW_CADNAVSTYLE_H
|
||||
#define TECHDRAW_CADNAVSTYLE_H
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include "QGVNavStyle.h"
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
class QGVPage;
|
||||
|
||||
class TechDrawGuiExport QGVNavStyleCAD : public QGVNavStyle
|
||||
{
|
||||
public:
|
||||
QGVNavStyleCAD();
|
||||
virtual ~QGVNavStyleCAD();
|
||||
|
||||
virtual void handleKeyReleaseEvent(QKeyEvent *event) override;
|
||||
virtual void handleMousePressEvent(QMouseEvent *event) override;
|
||||
virtual void handleMouseMoveEvent(QMouseEvent *event) override;
|
||||
virtual void handleMouseReleaseEvent(QMouseEvent *event) override;
|
||||
|
||||
//context menu (RMB) prevents pan mode 2 (LMB + RMB)
|
||||
virtual bool allowContextMenu() override {return false;};
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif // TECHDRAW_CADNAVSTYLE_H
|
||||
78
src/Mod/TechDraw/Gui/QGVNavStyleGesture.cpp
Normal file
78
src/Mod/TechDraw/Gui/QGVNavStyleGesture.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 <QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QMouseEvent>
|
||||
#endif
|
||||
|
||||
#include "QGVPage.h"
|
||||
#include "QGVNavStyleGesture.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
QGVNavStyleGesture::QGVNavStyleGesture()
|
||||
{
|
||||
}
|
||||
|
||||
QGVNavStyleGesture::~QGVNavStyleGesture()
|
||||
{
|
||||
}
|
||||
|
||||
void QGVNavStyleGesture::handleMousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::RightButton) {
|
||||
startPan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void QGVNavStyleGesture::handleMouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
getViewer()->setBalloonCursorPos(event->pos());
|
||||
}
|
||||
|
||||
if (panningActive) {
|
||||
pan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleGesture::handleMouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
placeBalloon(event->pos());
|
||||
}
|
||||
|
||||
if (event->button() == Qt::RightButton) {
|
||||
stopPan();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace TechDrawGui
|
||||
53
src/Mod/TechDraw/Gui/QGVNavStyleGesture.h
Normal file
53
src/Mod/TechDraw/Gui/QGVNavStyleGesture.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 TECHDRAW_GESTURENAVSTYLE_H
|
||||
#define TECHDRAW_GESTURENAVSTYLE_H
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include "QGVNavStyle.h"
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
class QGVPage;
|
||||
|
||||
class TechDrawGuiExport QGVNavStyleGesture : public QGVNavStyle
|
||||
{
|
||||
public:
|
||||
QGVNavStyleGesture();
|
||||
virtual ~QGVNavStyleGesture();
|
||||
|
||||
virtual void handleMousePressEvent(QMouseEvent *event) override;
|
||||
virtual void handleMouseMoveEvent(QMouseEvent *event) override;
|
||||
virtual void handleMouseReleaseEvent(QMouseEvent *event) override;
|
||||
|
||||
virtual bool allowContextMenu() override {return false;};
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif // TECHDRAW_GESTURENAVSTYLE_H
|
||||
106
src/Mod/TechDraw/Gui/QGVNavStyleInventor.cpp
Normal file
106
src/Mod/TechDraw/Gui/QGVNavStyleInventor.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 <QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QMouseEvent>
|
||||
#endif
|
||||
|
||||
#include "QGVPage.h"
|
||||
#include "QGVNavStyleInventor.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
//**********
|
||||
// Issue: select should be Shift + LMB
|
||||
// currently is just LMB like all the other styles
|
||||
// need to just accept LMB w/o Shift and pass Shift + LMB to
|
||||
// QGraphicsView?
|
||||
//**********
|
||||
|
||||
QGVNavStyleInventor::QGVNavStyleInventor()
|
||||
{
|
||||
}
|
||||
|
||||
QGVNavStyleInventor::~QGVNavStyleInventor()
|
||||
{
|
||||
}
|
||||
|
||||
void QGVNavStyleInventor::handleMousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->buttons() == (Qt::LeftButton | Qt::MiddleButton)) {
|
||||
//zoom mode 2 LMB + MMB
|
||||
startZoom(event->pos());
|
||||
event->accept();
|
||||
} else if (event->button() == Qt::MiddleButton) {
|
||||
//pan mode MMB + mouse movement
|
||||
startPan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleInventor::handleMouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
getViewer()->setBalloonCursorPos(event->pos());
|
||||
}
|
||||
|
||||
if (panningActive) {
|
||||
pan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
|
||||
if (zoomingActive) {
|
||||
zoom(mouseZoomFactor(event->pos()));
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleInventor::handleMouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
placeBalloon(event->pos());
|
||||
}
|
||||
|
||||
if (event->button() == Qt::MiddleButton) {
|
||||
//pan mode MMB
|
||||
if (panningActive) {
|
||||
stopPan();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
if ((event->button() == Qt::LeftButton) ||
|
||||
(event->button() == Qt::MiddleButton) ){
|
||||
//zoom mode 2 LMB + MMB
|
||||
if (zoomingActive) {
|
||||
zoomingActive = false;
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace TechDrawGui
|
||||
51
src/Mod/TechDraw/Gui/QGVNavStyleInventor.h
Normal file
51
src/Mod/TechDraw/Gui/QGVNavStyleInventor.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 TECHDRAW_INVENTORNAVSTYLE_H
|
||||
#define TECHDRAW_INVENTORNAVSTYLE_H
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include "QGVNavStyle.h"
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
class QGVPage;
|
||||
|
||||
class TechDrawGuiExport QGVNavStyleInventor : public QGVNavStyle
|
||||
{
|
||||
public:
|
||||
QGVNavStyleInventor();
|
||||
virtual ~QGVNavStyleInventor();
|
||||
|
||||
virtual void handleMousePressEvent(QMouseEvent *event) override;
|
||||
virtual void handleMouseMoveEvent(QMouseEvent *event) override;
|
||||
virtual void handleMouseReleaseEvent(QMouseEvent *event) override;
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif // TECHDRAW_INVENTORNAVSTYLE_H
|
||||
123
src/Mod/TechDraw/Gui/QGVNavStyleMaya.cpp
Normal file
123
src/Mod/TechDraw/Gui/QGVNavStyleMaya.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 <QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QMouseEvent>
|
||||
#endif
|
||||
|
||||
#include "QGVPage.h"
|
||||
#include "QGVNavStyleMaya.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
//******
|
||||
// Issue: on linux mint, ALT + mouse button doesn't get to the application.
|
||||
// system eats the event for menus, accessibility magnifier, etc.
|
||||
// only wheel zoom is known to work.
|
||||
// need to test in different environment.
|
||||
//******
|
||||
|
||||
QGVNavStyleMaya::QGVNavStyleMaya()
|
||||
{
|
||||
}
|
||||
|
||||
QGVNavStyleMaya::~QGVNavStyleMaya()
|
||||
{
|
||||
}
|
||||
|
||||
void QGVNavStyleMaya::handleKeyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
//zoom mode 2
|
||||
if ( (event->key() == Qt::Key_Alt) && zoomingActive) {
|
||||
zoomingActive = false;
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//pan mode
|
||||
if ((event->key() == Qt::Key_Alt) && panningActive) {
|
||||
stopPan();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
void QGVNavStyleMaya::handleMousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
//pan mode alt + MMB + mouse movement
|
||||
if ((event->button() == Qt::MiddleButton) &&
|
||||
(QApplication::keyboardModifiers() == Qt::AltModifier)) {
|
||||
startPan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//zoom mode 2 ALT + RMB
|
||||
if ((event->button() == Qt::RightButton) &&
|
||||
(QApplication::keyboardModifiers() == Qt::AltModifier)) {
|
||||
startZoom(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleMaya::handleMouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
getViewer()->setBalloonCursorPos(event->pos());
|
||||
}
|
||||
|
||||
if (panningActive) {
|
||||
pan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
|
||||
if (zoomingActive) {
|
||||
zoom(mouseZoomFactor(event->pos()));
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleMaya::handleMouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
placeBalloon(event->pos());
|
||||
}
|
||||
|
||||
if (event->button() == Qt::MiddleButton) {
|
||||
//pan mode ALT + MMB
|
||||
if (panningActive) {
|
||||
stopPan();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
if (event->button() == Qt::RightButton) {
|
||||
//zoom mode 2 ALT + RMB
|
||||
if (zoomingActive) {
|
||||
zoomingActive = false;
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace TechDrawGui
|
||||
55
src/Mod/TechDraw/Gui/QGVNavStyleMaya.h
Normal file
55
src/Mod/TechDraw/Gui/QGVNavStyleMaya.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 TECHDRAW_MAYANAVSTYLE_H
|
||||
#define TECHDRAW_MAYANAVSTYLE_H
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include "QGVNavStyle.h"
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
class QGVPage;
|
||||
|
||||
class TechDrawGuiExport QGVNavStyleMaya : public QGVNavStyle
|
||||
{
|
||||
public:
|
||||
QGVNavStyleMaya();
|
||||
virtual ~QGVNavStyleMaya();
|
||||
|
||||
virtual void handleKeyReleaseEvent(QKeyEvent *event) override;
|
||||
virtual void handleMousePressEvent(QMouseEvent *event) override;
|
||||
virtual void handleMouseMoveEvent(QMouseEvent *event) override;
|
||||
virtual void handleMouseReleaseEvent(QMouseEvent *event) override;
|
||||
|
||||
//context menu (RMB) prevents zoom mode 2 (ALT + RMB)
|
||||
virtual bool allowContextMenu() override {return false;};
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif // TECHDRAW_MAYANAVSTYLE_H
|
||||
109
src/Mod/TechDraw/Gui/QGVNavStyleOCC.cpp
Normal file
109
src/Mod/TechDraw/Gui/QGVNavStyleOCC.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 <QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QMouseEvent>
|
||||
#endif
|
||||
|
||||
#include "QGVPage.h"
|
||||
#include "QGVNavStyleOCC.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
QGVNavStyleOCC::QGVNavStyleOCC()
|
||||
{
|
||||
}
|
||||
|
||||
QGVNavStyleOCC::~QGVNavStyleOCC()
|
||||
{
|
||||
}
|
||||
|
||||
void QGVNavStyleOCC::handleKeyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
//zoom mode 2
|
||||
if ( (event->key() == Qt::Key_Control) && zoomingActive) {
|
||||
zoomingActive = false;
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
void QGVNavStyleOCC::handleMousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
//pan mode MMB + mouse movement
|
||||
//also Control + MMB + mouse movement, but this is redundant for our purposes
|
||||
if (event->button() == Qt::MiddleButton) {
|
||||
startPan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//zoom mode 2 Control + LMB
|
||||
if ((event->button() == Qt::LeftButton) &&
|
||||
(QApplication::keyboardModifiers() == Qt::ControlModifier)) {
|
||||
startZoom(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleOCC::handleMouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
getViewer()->setBalloonCursorPos(event->pos());
|
||||
}
|
||||
|
||||
if (panningActive) {
|
||||
pan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
|
||||
if (zoomingActive) {
|
||||
zoom(mouseZoomFactor(event->pos()));
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleOCC::handleMouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
placeBalloon(event->pos());
|
||||
}
|
||||
|
||||
if (event->button() == Qt::MiddleButton) {
|
||||
//pan mode [Control] + MMB
|
||||
if (panningActive) {
|
||||
stopPan();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
//zoom mode 2 Control + LMB
|
||||
if (zoomingActive) {
|
||||
zoomingActive = false;
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace TechDrawGui
|
||||
52
src/Mod/TechDraw/Gui/QGVNavStyleOCC.h
Normal file
52
src/Mod/TechDraw/Gui/QGVNavStyleOCC.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 TECHDRAW_OCCNAVSTYLE_H
|
||||
#define TECHDRAW_OCCNAVSTYLE_H
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include "QGVNavStyle.h"
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
class QGVPage;
|
||||
|
||||
class TechDrawGuiExport QGVNavStyleOCC : public QGVNavStyle
|
||||
{
|
||||
public:
|
||||
QGVNavStyleOCC();
|
||||
virtual ~QGVNavStyleOCC();
|
||||
|
||||
virtual void handleKeyReleaseEvent(QKeyEvent *event) override;
|
||||
virtual void handleMousePressEvent(QMouseEvent *event) override;
|
||||
virtual void handleMouseMoveEvent(QMouseEvent *event) override;
|
||||
virtual void handleMouseReleaseEvent(QMouseEvent *event) override;
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif // TECHDRAW_OCCNAVSTYLE_H
|
||||
114
src/Mod/TechDraw/Gui/QGVNavStyleOpenSCAD.cpp
Normal file
114
src/Mod/TechDraw/Gui/QGVNavStyleOpenSCAD.cpp
Normal file
@@ -0,0 +1,114 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 <QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QMouseEvent>
|
||||
#endif
|
||||
|
||||
#include "QGVPage.h"
|
||||
#include "QGVNavStyleOpenSCAD.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
QGVNavStyleOpenSCAD::QGVNavStyleOpenSCAD()
|
||||
{
|
||||
}
|
||||
|
||||
QGVNavStyleOpenSCAD::~QGVNavStyleOpenSCAD()
|
||||
{
|
||||
}
|
||||
|
||||
void QGVNavStyleOpenSCAD::handleKeyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
//zoom mode 2
|
||||
if ( (event->key() == Qt::Key_Shift) && zoomingActive) {
|
||||
zoomingActive = false;
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
//eat the RMB event so it doesn't trigger MDIViewPage context
|
||||
void QGVNavStyleOpenSCAD::handleMousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
//zoom mode 2 Shift + RMB
|
||||
if ((event->button() == Qt::RightButton) &&
|
||||
(QApplication::keyboardModifiers() == Qt::ShiftModifier)) {
|
||||
startZoom(event->pos());
|
||||
event->accept();
|
||||
} else if (event->button() == Qt::RightButton) {
|
||||
//pan mode
|
||||
startPan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//zoom mode 2 MMB
|
||||
if (event->button() == Qt::MiddleButton) {
|
||||
startZoom(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleOpenSCAD::handleMouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
getViewer()->setBalloonCursorPos(event->pos());
|
||||
}
|
||||
|
||||
if (panningActive) {
|
||||
pan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
|
||||
if (zoomingActive) {
|
||||
zoom(mouseZoomFactor(event->pos()));
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleOpenSCAD::handleMouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
placeBalloon(event->pos());
|
||||
}
|
||||
|
||||
if ((event->button() == Qt::RightButton) && panningActive) {
|
||||
stopPan();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
if ((event->button() == Qt::RightButton) && zoomingActive) {
|
||||
zoomingActive = false;
|
||||
event->accept();
|
||||
}
|
||||
|
||||
if ((event->button() == Qt::MiddleButton) && zoomingActive) {
|
||||
zoomingActive = false;
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace TechDrawGui
|
||||
55
src/Mod/TechDraw/Gui/QGVNavStyleOpenSCAD.h
Normal file
55
src/Mod/TechDraw/Gui/QGVNavStyleOpenSCAD.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 TECHDRAW_OPENSCADNAVSTYLE_H
|
||||
#define TECHDRAW_OPENSCADNAVSTYLE_H
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include "QGVNavStyle.h"
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
class QGVPage;
|
||||
|
||||
class TechDrawGuiExport QGVNavStyleOpenSCAD : public QGVNavStyle
|
||||
{
|
||||
public:
|
||||
QGVNavStyleOpenSCAD();
|
||||
virtual ~QGVNavStyleOpenSCAD();
|
||||
|
||||
virtual void handleKeyReleaseEvent(QKeyEvent *event) override;
|
||||
virtual void handleMouseMoveEvent(QMouseEvent *event) override;
|
||||
virtual void handleMousePressEvent(QMouseEvent *event) override;
|
||||
virtual void handleMouseReleaseEvent(QMouseEvent *event) override;
|
||||
|
||||
//context menu (RMB) prevents pan and zoom
|
||||
virtual bool allowContextMenu() override {return false;};
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif // TECHDRAW_OPENSCADNAVSTYLE_H
|
||||
89
src/Mod/TechDraw/Gui/QGVNavStyleRevit.cpp
Normal file
89
src/Mod/TechDraw/Gui/QGVNavStyleRevit.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 <QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QMouseEvent>
|
||||
#endif
|
||||
|
||||
#include "QGVPage.h"
|
||||
#include "QGVNavStyleRevit.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
QGVNavStyleRevit::QGVNavStyleRevit()
|
||||
{
|
||||
}
|
||||
|
||||
QGVNavStyleRevit::~QGVNavStyleRevit()
|
||||
{
|
||||
}
|
||||
|
||||
void QGVNavStyleRevit::handleMousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
//pan mode 1 - LMB + RMB
|
||||
if (event->buttons() == (Qt::LeftButton & Qt::RightButton)) {
|
||||
startPan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//pan mode 2 - MMB
|
||||
if (event->button() == Qt::MiddleButton) {
|
||||
startPan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleRevit::handleMouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
getViewer()->setBalloonCursorPos(event->pos());
|
||||
}
|
||||
|
||||
if (panningActive) {
|
||||
pan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleRevit::handleMouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
placeBalloon(event->pos());
|
||||
}
|
||||
|
||||
if (panningActive) {
|
||||
//stop panning if any button release
|
||||
if ( (event->button() == Qt::LeftButton) ||
|
||||
(event->button() == Qt::RightButton) ||
|
||||
(event->button() == Qt::MiddleButton) ){
|
||||
stopPan();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace TechDrawGui
|
||||
54
src/Mod/TechDraw/Gui/QGVNavStyleRevit.h
Normal file
54
src/Mod/TechDraw/Gui/QGVNavStyleRevit.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 TECHDRAW_REVITNAVSTYLE_H
|
||||
#define TECHDRAW_REVITNAVSTYLE_H
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include "QGVNavStyle.h"
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
class QGVPage;
|
||||
|
||||
class TechDrawGuiExport QGVNavStyleRevit : public QGVNavStyle
|
||||
{
|
||||
public:
|
||||
QGVNavStyleRevit();
|
||||
virtual ~QGVNavStyleRevit();
|
||||
|
||||
virtual void handleMousePressEvent(QMouseEvent *event) override;
|
||||
virtual void handleMouseMoveEvent(QMouseEvent *event) override;
|
||||
virtual void handleMouseReleaseEvent(QMouseEvent *event) override;
|
||||
|
||||
//context menu (RMB) prevents pan mode 2 (LMB + RMB)
|
||||
virtual bool allowContextMenu() override {return false;};
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif // TECHDRAW_REVITNAVSTYLE_H
|
||||
83
src/Mod/TechDraw/Gui/QGVNavStyleTinkerCAD.cpp
Normal file
83
src/Mod/TechDraw/Gui/QGVNavStyleTinkerCAD.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 <QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QMouseEvent>
|
||||
#include <QScrollBar>
|
||||
#endif
|
||||
|
||||
#include <Mod/TechDraw/App/DrawPage.h>
|
||||
|
||||
#include "QGVPage.h"
|
||||
#include "QGSPage.h"
|
||||
#include "QGVNavStyleTinkerCAD.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
QGVNavStyleTinkerCAD::QGVNavStyleTinkerCAD()
|
||||
{
|
||||
}
|
||||
|
||||
QGVNavStyleTinkerCAD::~QGVNavStyleTinkerCAD()
|
||||
{
|
||||
}
|
||||
|
||||
void QGVNavStyleTinkerCAD::handleMousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::MiddleButton) {
|
||||
startPan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleTinkerCAD::handleMouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
getViewer()->setBalloonCursorPos(event->pos());
|
||||
}
|
||||
|
||||
if (panningActive) {
|
||||
pan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleTinkerCAD::handleMouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
placeBalloon(event->pos());
|
||||
}
|
||||
|
||||
if (panningActive) {
|
||||
if (event->button() == Qt::MiddleButton) {
|
||||
stopPan();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace TechDrawGui
|
||||
53
src/Mod/TechDraw/Gui/QGVNavStyleTinkerCAD.h
Normal file
53
src/Mod/TechDraw/Gui/QGVNavStyleTinkerCAD.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 TECHDRAW_TINKERNAVSTYLE_H
|
||||
#define TECHDRAW_TINKERNAVSTYLE_H
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include "QGVNavStyle.h"
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
class QGVPage;
|
||||
|
||||
class TechDrawGuiExport QGVNavStyleTinkerCAD : public QGVNavStyle
|
||||
{
|
||||
// TYPESYSTEM_HEADER();
|
||||
|
||||
public:
|
||||
QGVNavStyleTinkerCAD();
|
||||
virtual ~QGVNavStyleTinkerCAD();
|
||||
|
||||
virtual void handleMouseMoveEvent(QMouseEvent *event) override;
|
||||
virtual void handleMousePressEvent(QMouseEvent *event) override;
|
||||
virtual void handleMouseReleaseEvent(QMouseEvent *event) override;
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif // TECHDRAW_TINKERNAVSTYLE_H
|
||||
130
src/Mod/TechDraw/Gui/QGVNavStyleTouchpad.cpp
Normal file
130
src/Mod/TechDraw/Gui/QGVNavStyleTouchpad.cpp
Normal file
@@ -0,0 +1,130 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 <QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QMouseEvent>
|
||||
#endif
|
||||
|
||||
#include "QGVPage.h"
|
||||
#include "QGVNavStyleTouchpad.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
QGVNavStyleTouchpad::QGVNavStyleTouchpad()
|
||||
{
|
||||
}
|
||||
|
||||
QGVNavStyleTouchpad::~QGVNavStyleTouchpad()
|
||||
{
|
||||
}
|
||||
|
||||
void QGVNavStyleTouchpad::handleKeyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
// Q_UNUSED(event)
|
||||
if (event->key() == Qt::Key_PageUp) {
|
||||
setAnchor();
|
||||
zoom(1.0 + zoomStep);
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->key() == Qt::Key_PageDown) {
|
||||
setAnchor();
|
||||
zoom(1.0 - zoomStep);
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleTouchpad::handleKeyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
// Q_UNUSED(event)
|
||||
if (event->key() == Qt::Key_Shift) {
|
||||
if (panningActive == true) {
|
||||
stopPan();
|
||||
}
|
||||
zoomingActive = false;
|
||||
}
|
||||
|
||||
if (event->key() == Qt::Key_Control) {
|
||||
zoomingActive = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void QGVNavStyleTouchpad::handleMouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getViewer()->isBalloonPlacing()) {
|
||||
getViewer()->setBalloonCursorPos(event->pos());
|
||||
}
|
||||
|
||||
if (QApplication::keyboardModifiers() == Qt::ShiftModifier) {
|
||||
//if shift is down then we are panning
|
||||
if (!panningActive) {
|
||||
startPan(event->pos());
|
||||
}
|
||||
zoomingActive = false;
|
||||
} else if (QApplication::keyboardModifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) {
|
||||
// if control and shift are down then we are zooming
|
||||
if (panningActive == true) {
|
||||
stopPan();
|
||||
}
|
||||
if (!zoomingActive) {
|
||||
startZoom(event->pos());
|
||||
event->accept();
|
||||
return; //don't zoom on first movement
|
||||
}
|
||||
} else {
|
||||
if (panningActive == true) {
|
||||
stopPan();
|
||||
}
|
||||
zoomingActive = false;
|
||||
}
|
||||
|
||||
if (panningActive) {
|
||||
pan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
|
||||
if (zoomingActive) {
|
||||
// setAnchor();
|
||||
zoom(mouseZoomFactor(event->pos()));
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVNavStyleTouchpad::setAnchor()
|
||||
{
|
||||
//this navigation style can not anchor under mouse since mouse is moving as part of zoom action
|
||||
if (m_viewer != nullptr) {
|
||||
m_viewer->setResizeAnchor(QGraphicsView::AnchorViewCenter);
|
||||
m_viewer->setTransformationAnchor(QGraphicsView::AnchorViewCenter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} //namespace TechDrawGui
|
||||
53
src/Mod/TechDraw/Gui/QGVNavStyleTouchpad.h
Normal file
53
src/Mod/TechDraw/Gui/QGVNavStyleTouchpad.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <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 TECHDRAW_TOUCHPADNAVSTYLE_H
|
||||
#define TECHDRAW_TOUCHPADNAVSTYLE_H
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include "QGVNavStyle.h"
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
class QGVPage;
|
||||
|
||||
class TechDrawGuiExport QGVNavStyleTouchpad : public QGVNavStyle
|
||||
{
|
||||
public:
|
||||
QGVNavStyleTouchpad();
|
||||
virtual ~QGVNavStyleTouchpad();
|
||||
|
||||
virtual void handleKeyPressEvent(QKeyEvent *event) override;
|
||||
virtual void handleKeyReleaseEvent(QKeyEvent *event) override;
|
||||
virtual void handleMouseMoveEvent(QMouseEvent *event) override;
|
||||
|
||||
protected:
|
||||
virtual void setAnchor() override;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif // TECHDRAW_TOUCHPADNAVSTYLE_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -25,11 +25,13 @@
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsView>
|
||||
#include <QLabel>
|
||||
#include <QPainterPath>
|
||||
|
||||
#include <Base/Type.h>
|
||||
#include <Base/Parameter.h>
|
||||
|
||||
class QTemporaryFile;
|
||||
|
||||
namespace App {
|
||||
@@ -57,6 +59,7 @@ class DrawWeldSymbol;
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGSPage;
|
||||
class QGIView;
|
||||
class QGIViewDimension;
|
||||
class QGITemplate;
|
||||
@@ -65,74 +68,52 @@ class QGIViewBalloon;
|
||||
class QGILeaderLine;
|
||||
class QGIRichAnno;
|
||||
class QGITile;
|
||||
class QGVNavStyle;
|
||||
|
||||
class TechDrawGuiExport QGVPage : public QGraphicsView
|
||||
class TechDrawGuiExport QGVPage : public QGraphicsView, public ParameterGrp::ObserverType
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum RendererType { Native, OpenGL, Image };
|
||||
|
||||
QGVPage(ViewProviderPage *vp, QGraphicsScene* s, QWidget *parent = nullptr);
|
||||
QGVPage(ViewProviderPage *vp, QGSPage* s, QWidget *parent = nullptr);
|
||||
virtual ~QGVPage();
|
||||
|
||||
/// Observer message from the ParameterGrp
|
||||
virtual void OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::MessageType Reason) override;
|
||||
|
||||
|
||||
void setRenderer(RendererType type = Native);
|
||||
void drawBackground(QPainter *p, const QRectF &rect) override;
|
||||
|
||||
QGIView * addViewDimension(TechDraw::DrawViewDimension *dim);
|
||||
QGIView * addViewBalloon(TechDraw::DrawViewBalloon *balloon);
|
||||
QGIView * addProjectionGroup(TechDraw::DrawProjGroup *view);
|
||||
QGIView * addViewPart(TechDraw::DrawViewPart *part);
|
||||
QGIView * addViewSection(TechDraw::DrawViewPart *part);
|
||||
QGIView * addDrawView(TechDraw::DrawView *view);
|
||||
QGIView * addDrawViewCollection(TechDraw::DrawViewCollection *view);
|
||||
QGIView * addDrawViewAnnotation(TechDraw::DrawViewAnnotation *view);
|
||||
QGIView * addDrawViewSymbol(TechDraw::DrawViewSymbol *view);
|
||||
QGIView * addDrawViewClip(TechDraw::DrawViewClip *view);
|
||||
QGIView * addDrawViewSpreadsheet(TechDraw::DrawViewSpreadsheet *view);
|
||||
QGIView * addDrawViewImage(TechDraw::DrawViewImage *view);
|
||||
QGIView * addViewLeader(TechDraw::DrawLeaderLine* view);
|
||||
QGIView * addRichAnno(TechDraw::DrawRichAnno* anno);
|
||||
QGIView * addWeldSymbol(TechDraw::DrawWeldSymbol* weld);
|
||||
QGSPage* getScene() {return m_scene; };
|
||||
|
||||
QGIView* findQViewForDocObj(App::DocumentObject *obj) const;
|
||||
QGIView* getQGIVByName(std::string name);
|
||||
QGIView* findParent(QGIView *) const;
|
||||
|
||||
void addBalloonToParent(QGIViewBalloon* balloon, QGIView* parent);
|
||||
void createBalloon(QPointF origin, TechDraw::DrawViewPart *parent);
|
||||
void startBalloonPlacing(void);
|
||||
void cancelBalloonPlacing(void);
|
||||
|
||||
void addDimToParent(QGIViewDimension* dim, QGIView* parent);
|
||||
void addLeaderToParent(QGILeaderLine* lead, QGIView* parent);
|
||||
|
||||
std::vector<QGIView *> getViews() const;
|
||||
|
||||
int addQView(QGIView * view);
|
||||
int removeQView(QGIView *view);
|
||||
int removeQViewByName(const char* name);
|
||||
void removeQViewFromScene(QGIView *view);
|
||||
|
||||
void setPageTemplate(TechDraw::DrawTemplate *pageTemplate);
|
||||
|
||||
QGITemplate * getTemplate() const;
|
||||
void removeTemplate();
|
||||
|
||||
TechDraw::DrawPage * getDrawPage();
|
||||
|
||||
void setExporting(bool enable);
|
||||
virtual void refreshViews(void);
|
||||
|
||||
|
||||
/// Renders the page to SVG with filename.
|
||||
void saveSvg(QString filename);
|
||||
void postProcessXml(QTemporaryFile& tempFile, QString filename, QString pagename);
|
||||
// void saveSvg(QString filename);
|
||||
// void postProcessXml(QTemporaryFile& tempFile, QString filename, QString pagename);
|
||||
|
||||
void makeGrid(int width, int height, double step);
|
||||
void showGrid(bool state) {m_showGrid = state;}
|
||||
void updateViewport(void) {viewport()->repaint();}
|
||||
|
||||
bool isBalloonPlacing() {return balloonPlacing; };
|
||||
void setBalloonPlacing(bool s) {balloonPlacing = s;};
|
||||
|
||||
QLabel* getBalloonCursor() {return balloonCursor;};
|
||||
void setBalloonCursor(QLabel* l) {balloonCursor = l;};
|
||||
|
||||
void kbPanScroll(int xMove = 1, int yMove = 1);
|
||||
QPointF getBalloonCursorPos() {return balloonCursorPos;};
|
||||
void setBalloonCursorPos(QPoint p) { balloonCursorPos = p;};
|
||||
|
||||
public Q_SLOTS:
|
||||
void setHighQualityAntialiasing(bool highQualityAntialiasing);
|
||||
|
||||
@@ -146,14 +127,12 @@ protected:
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void focusOutEvent(QFocusEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void kbPanScroll(int xMove = 1, int yMove = 1);
|
||||
void keyReleaseEvent(QKeyEvent *event) override;
|
||||
virtual void contextMenuEvent(QContextMenuEvent *event) override;
|
||||
|
||||
static QColor SelectColor;
|
||||
static QColor PreselectColor;
|
||||
QColor getBackgroundColor();
|
||||
|
||||
|
||||
QGITemplate *pageTemplate;
|
||||
|
||||
double getDevicePixelRatio() const;
|
||||
QPixmap prepareCursorPixmap(const char *iconName, QPoint &hotspot);
|
||||
@@ -161,6 +140,12 @@ protected:
|
||||
void activateCursor(QCursor cursor);
|
||||
void resetCursor();
|
||||
virtual void drawForeground(QPainter *painter, const QRectF &rect) override;
|
||||
|
||||
std::string getNavStyleParameter();
|
||||
Base::Type getStyleType(std::string model);
|
||||
|
||||
void initNavigationStyle();
|
||||
void setNavigationStyle(std::string navParm);
|
||||
|
||||
private:
|
||||
RendererType m_renderer;
|
||||
@@ -176,6 +161,7 @@ private:
|
||||
int m_reversePan;
|
||||
int m_reverseScroll;
|
||||
|
||||
QGSPage* m_scene;
|
||||
bool balloonPlacing;
|
||||
QLabel *balloonCursor;
|
||||
QPoint balloonCursorPos;
|
||||
@@ -186,6 +172,12 @@ private:
|
||||
|
||||
bool m_showGrid;
|
||||
QPainterPath m_gridPath;
|
||||
|
||||
QGVNavStyle* m_navStyle;
|
||||
|
||||
/// handle to the viewer parameter group
|
||||
ParameterGrp::handle hGrp;
|
||||
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -39,6 +39,7 @@ class DrawViewSymbol;
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGSPage;
|
||||
class QGVPage;
|
||||
class QGIView;
|
||||
class MDIViewPage;
|
||||
|
||||
@@ -47,6 +47,7 @@ class LineFormat;
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGSPage;
|
||||
class QGVPage;
|
||||
class QGIView;
|
||||
class QGIPrimPath;
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
|
||||
#include <Mod/TechDraw/Gui/ui_TaskCosVertex.h>
|
||||
|
||||
#include "QGSPage.h"
|
||||
#include "QGVPage.h"
|
||||
#include "QGIView.h"
|
||||
#include "QGIPrimPath.h"
|
||||
@@ -95,7 +96,7 @@ TaskCosVertex::TaskCosVertex(TechDraw::DrawViewPart* baseFeat,
|
||||
Gui::ViewProvider* vp = activeGui->getViewProvider(m_basePage);
|
||||
ViewProviderPage* vpp = static_cast<ViewProviderPage*>(vp);
|
||||
m_mdi = vpp->getMDIViewPage();
|
||||
m_scene = m_mdi->m_scene;
|
||||
m_scene = m_mdi->getQGSPage();
|
||||
m_view = m_mdi->getQGVPage();
|
||||
|
||||
setUiPrimary();
|
||||
@@ -285,7 +286,7 @@ void TaskCosVertex::removeTracker(void)
|
||||
void TaskCosVertex::setEditCursor(QCursor c)
|
||||
{
|
||||
if (m_baseFeat != nullptr) {
|
||||
QGIView* qgivBase = m_view->findQViewForDocObj(m_baseFeat);
|
||||
QGIView* qgivBase = m_scene->findQViewForDocObj(m_baseFeat);
|
||||
qgivBase->setCursor(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,11 +39,13 @@ namespace TechDraw
|
||||
{
|
||||
class DrawPage;
|
||||
class DrawView;
|
||||
class DrawViewPart;
|
||||
class DrawCosVertex;
|
||||
}
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGSPage;
|
||||
class QGVPage;
|
||||
class QGIView;
|
||||
class QGIPrimPath;
|
||||
@@ -98,7 +100,7 @@ private:
|
||||
QGTracker* m_tracker;
|
||||
|
||||
MDIViewPage* m_mdi;
|
||||
QGraphicsScene* m_scene;
|
||||
QGSPage* m_scene;
|
||||
QGVPage* m_view;
|
||||
TechDraw::DrawViewPart* m_baseFeat;
|
||||
TechDraw::DrawPage* m_basePage;
|
||||
|
||||
@@ -40,6 +40,7 @@ class LineFormat;
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGSPage;
|
||||
class QGVPage;
|
||||
class QGIView;
|
||||
class QGIPrimPath;
|
||||
|
||||
@@ -47,6 +47,7 @@ class Face;
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGSPage;
|
||||
class QGVPage;
|
||||
class QGIView;
|
||||
class QGIPrimPath;
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
|
||||
#include <Mod/TechDraw/Gui/ui_TaskDetail.h>
|
||||
|
||||
#include "QGSPage.h"
|
||||
#include "QGVPage.h"
|
||||
#include "QGIView.h"
|
||||
#include "QGIPrimPath.h"
|
||||
@@ -116,7 +117,7 @@ TaskDetail::TaskDetail(TechDraw::DrawViewPart* baseFeat):
|
||||
Gui::ViewProvider* vp = activeGui->getViewProvider(m_basePage);
|
||||
ViewProviderPage* vpp = static_cast<ViewProviderPage*>(vp);
|
||||
m_mdi = vpp->getMDIViewPage();
|
||||
m_scene = m_mdi->m_scene;
|
||||
m_scene = m_mdi->getQGSPage();
|
||||
m_view = m_mdi->getQGVPage();
|
||||
|
||||
createDetail();
|
||||
@@ -202,7 +203,7 @@ TaskDetail::TaskDetail(TechDraw::DrawViewDetail* detailFeat):
|
||||
Gui::ViewProvider* vp = activeGui->getViewProvider(m_basePage);
|
||||
ViewProviderPage* vpp = static_cast<ViewProviderPage*>(vp);
|
||||
m_mdi = vpp->getMDIViewPage();
|
||||
m_scene = m_mdi->m_scene;
|
||||
m_scene = m_mdi->getQGSPage();
|
||||
m_view = m_mdi->getQGVPage();
|
||||
|
||||
saveDetailState();
|
||||
|
||||
@@ -44,6 +44,7 @@ class DrawViewPart;
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGSPage;
|
||||
class QGVPage;
|
||||
class QGIView;
|
||||
class QGIPrimPath;
|
||||
@@ -109,7 +110,7 @@ private:
|
||||
QGIGhostHighlight* m_ghost;
|
||||
|
||||
MDIViewPage* m_mdi;
|
||||
QGraphicsScene* m_scene;
|
||||
QGSPage* m_scene;
|
||||
QGVPage* m_view;
|
||||
TechDraw::DrawViewDetail* m_detailFeat;
|
||||
TechDraw::DrawViewPart* m_baseFeat;
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
|
||||
#include "DrawGuiUtil.h"
|
||||
#include "PreferencesGui.h"
|
||||
#include "QGSPage.h"
|
||||
#include "QGVPage.h"
|
||||
#include "QGIView.h"
|
||||
#include "QGIPrimPath.h"
|
||||
@@ -121,10 +122,10 @@ TaskLeaderLine::TaskLeaderLine(TechDrawGui::ViewProviderLeader* leadVP) :
|
||||
m_haveMdi = true;
|
||||
m_mdi = vpp->getMDIViewPage();
|
||||
if (m_mdi != nullptr) {
|
||||
m_scene = m_mdi->m_scene;
|
||||
m_scene = m_mdi->getQGSPage();
|
||||
m_view = m_mdi->getQGVPage();
|
||||
if (m_baseFeat != nullptr) {
|
||||
m_qgParent = m_view->findQViewForDocObj(m_baseFeat);
|
||||
m_qgParent = m_scene->findQViewForDocObj(m_baseFeat);
|
||||
}
|
||||
} else {
|
||||
m_haveMdi = false;
|
||||
@@ -197,10 +198,10 @@ TaskLeaderLine::TaskLeaderLine(TechDraw::DrawView* baseFeat,
|
||||
m_haveMdi = true;
|
||||
m_mdi = vpp->getMDIViewPage();
|
||||
if (m_mdi != nullptr) {
|
||||
m_scene = m_mdi->m_scene;
|
||||
m_scene = m_mdi->getQGSPage();
|
||||
m_view = m_mdi->getQGVPage();
|
||||
if (baseFeat != nullptr) {
|
||||
m_qgParent = m_view->findQViewForDocObj(baseFeat);
|
||||
m_qgParent = m_scene->findQViewForDocObj(baseFeat);
|
||||
}
|
||||
} else {
|
||||
m_haveMdi = false;
|
||||
@@ -558,8 +559,8 @@ void TaskLeaderLine::onTrackerClicked(bool b)
|
||||
m_inProgressLock = true;
|
||||
m_saveContextPolicy = m_mdi->contextMenuPolicy();
|
||||
m_mdi->setContextMenuPolicy(Qt::PreventContextMenu);
|
||||
QGVPage* qgvp = m_mdi->getQGVPage();
|
||||
QGIView* qgiv = qgvp->findQViewForDocObj(m_lineFeat);
|
||||
QGSPage* qgsp = m_mdi->getQGSPage();
|
||||
QGIView* qgiv = qgsp->findQViewForDocObj(m_lineFeat);
|
||||
QGILeaderLine* qgLead = dynamic_cast<QGILeaderLine*>(qgiv);
|
||||
|
||||
if (qgLead == nullptr) {
|
||||
@@ -712,7 +713,7 @@ void TaskLeaderLine::setEditCursor(QCursor c)
|
||||
return;
|
||||
}
|
||||
if (m_baseFeat != nullptr) {
|
||||
QGIView* qgivBase = m_view->findQViewForDocObj(m_baseFeat);
|
||||
QGIView* qgivBase = m_scene->findQViewForDocObj(m_baseFeat);
|
||||
qgivBase->setCursor(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
|
||||
#include "QGTracker.h"
|
||||
|
||||
|
||||
//TODO: make this a proper enum
|
||||
#define TRACKERPICK 0
|
||||
#define TRACKEREDIT 1
|
||||
@@ -47,6 +46,7 @@ class DrawLeaderLine;
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGSPage;
|
||||
class QGVPage;
|
||||
class QGIView;
|
||||
class QGIPrimPath;
|
||||
@@ -129,7 +129,7 @@ private:
|
||||
QGTracker* m_tracker;
|
||||
|
||||
MDIViewPage* m_mdi;
|
||||
QGraphicsScene* m_scene;
|
||||
QGSPage* m_scene;
|
||||
QGVPage* m_view;
|
||||
ViewProviderLeader* m_lineVP;
|
||||
TechDraw::DrawView* m_baseFeat;
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include <Mod/TechDraw/Gui/ui_TaskRichAnno.h>
|
||||
|
||||
#include "PreferencesGui.h"
|
||||
#include "QGSPage.h"
|
||||
#include "QGVPage.h"
|
||||
#include "QGIView.h"
|
||||
#include "QGIPrimPath.h"
|
||||
@@ -120,9 +121,9 @@ TaskRichAnno::TaskRichAnno(TechDrawGui::ViewProviderRichAnno* annoVP) :
|
||||
m_qgParent = nullptr;
|
||||
m_haveMdi = true;
|
||||
if (m_mdi != nullptr) {
|
||||
m_view = m_mdi->getQGVPage();
|
||||
m_scene = m_mdi->getQGSPage();
|
||||
if (m_baseFeat != nullptr) {
|
||||
m_qgParent = m_view->findQViewForDocObj(m_baseFeat);
|
||||
m_qgParent = m_scene->findQViewForDocObj(m_baseFeat);
|
||||
}
|
||||
} else {
|
||||
m_haveMdi = false;
|
||||
@@ -175,8 +176,8 @@ TaskRichAnno::TaskRichAnno(TechDraw::DrawView* baseFeat,
|
||||
m_haveMdi = true;
|
||||
m_mdi = dvp->getMDIViewPage();
|
||||
if (m_mdi != nullptr) {
|
||||
m_view = m_mdi->getQGVPage();
|
||||
m_qgParent = m_view->findQViewForDocObj(baseFeat);
|
||||
m_scene= m_mdi->getQGSPage();
|
||||
m_qgParent = m_scene->findQViewForDocObj(baseFeat);
|
||||
} else {
|
||||
m_haveMdi = false;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ class DrawRichAnno;
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGSPage;
|
||||
class QGVPage;
|
||||
class QGIView;
|
||||
class QGIPrimPath;
|
||||
@@ -101,6 +102,7 @@ private:
|
||||
bool blockUpdate;
|
||||
|
||||
MDIViewPage* m_mdi;
|
||||
QGSPage* m_scene;
|
||||
QGVPage* m_view;
|
||||
ViewProviderRichAnno* m_annoVP;
|
||||
TechDraw::DrawView* m_baseFeat;
|
||||
|
||||
@@ -59,6 +59,7 @@ class Face;
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGSPage;
|
||||
class QGVPage;
|
||||
class QGIView;
|
||||
class QGIPrimPath;
|
||||
|
||||
@@ -50,6 +50,7 @@ class Face;
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
class QGSPage;
|
||||
class QGVPage;
|
||||
class QGIView;
|
||||
class QGILeaderLine;
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "ViewProviderDrawingView.h"
|
||||
#include "MDIViewPage.h"
|
||||
#include "QGIView.h"
|
||||
#include "QGSPage.h"
|
||||
#include "QGVPage.h"
|
||||
#include "ViewProviderPage.h"
|
||||
|
||||
@@ -171,9 +172,9 @@ QGIView* ViewProviderDrawingView::getQView(void)
|
||||
ViewProviderPage* dvp = dynamic_cast<ViewProviderPage*>(vp);
|
||||
if (dvp) {
|
||||
if (dvp->getMDIViewPage()) {
|
||||
if (dvp->getMDIViewPage()->getQGVPage()) {
|
||||
if (dvp->getMDIViewPage()->getQGSPage()) {
|
||||
qView = dynamic_cast<QGIView *>(dvp->getMDIViewPage()->
|
||||
getQGVPage()->findQViewForDocObj(getViewObject()));
|
||||
getQGSPage()->findQViewForDocObj(getViewObject()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -266,9 +267,9 @@ void ViewProviderDrawingView::onGuiRepaint(const TechDraw::DrawView* dv)
|
||||
ViewProviderPage* vpPage = dynamic_cast<ViewProviderPage*>(vp);
|
||||
if (vpPage != nullptr) {
|
||||
if (vpPage->getMDIViewPage() != nullptr) {
|
||||
if (vpPage->getMDIViewPage()->getQGVPage()) {
|
||||
if (vpPage->getMDIViewPage()->getQGSPage()) {
|
||||
QGIView* qView = dynamic_cast<QGIView *>(vpPage->getMDIViewPage()->
|
||||
getQGVPage()->findQViewForDocObj(v));
|
||||
getQGSPage()->findQViewForDocObj(v));
|
||||
if (qView != nullptr) {
|
||||
qView->updateView(true);
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#include "MDIViewPage.h"
|
||||
#include "PreferencesGui.h"
|
||||
#include "QGITemplate.h"
|
||||
#include "QGSPage.h"
|
||||
#include "QGVPage.h"
|
||||
#include "ViewProviderTemplate.h"
|
||||
#include "ViewProviderPage.h"
|
||||
@@ -79,7 +80,8 @@ ViewProviderPage::ViewProviderPage()
|
||||
: m_mdiView(nullptr),
|
||||
m_docReady(true),
|
||||
m_pageName(""),
|
||||
m_graphicsView(nullptr)
|
||||
m_graphicsView(nullptr),
|
||||
m_graphicsScene(nullptr)
|
||||
{
|
||||
sPixmap = "TechDraw_TreePage";
|
||||
static const char *group = "Grid";
|
||||
@@ -432,9 +434,9 @@ void ViewProviderPage::setFrameState(bool state)
|
||||
void ViewProviderPage::toggleFrameState(void)
|
||||
{
|
||||
// Base::Console().Message("VPP::toggleFrameState()\n");
|
||||
if (m_graphicsView != nullptr) {
|
||||
if (m_graphicsScene != nullptr) {
|
||||
setFrameState(!getFrameState());
|
||||
m_graphicsView->refreshViews();
|
||||
m_graphicsScene->refreshViews();
|
||||
setTemplateMarkers(getFrameState());
|
||||
}
|
||||
}
|
||||
@@ -461,6 +463,11 @@ void ViewProviderPage::setGraphicsView(QGVPage* gv)
|
||||
m_graphicsView = gv;
|
||||
}
|
||||
|
||||
void ViewProviderPage::setGraphicsScene(QGSPage* gs)
|
||||
{
|
||||
m_graphicsScene = gs;
|
||||
}
|
||||
|
||||
bool ViewProviderPage::canDelete(App::DocumentObject *obj) const
|
||||
{
|
||||
// deletions from a page don't necessarily destroy anything
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace TechDrawGui {
|
||||
|
||||
class MDIViewPage;
|
||||
class QGVPage;
|
||||
class QGSPage;
|
||||
|
||||
class TechDrawGuiExport ViewProviderPage : public Gui::ViewProviderDocumentObject
|
||||
{
|
||||
@@ -97,7 +98,9 @@ public:
|
||||
void toggleFrameState(void);
|
||||
void setTemplateMarkers(bool state);
|
||||
QGVPage *getGraphicsView() { return m_graphicsView; }
|
||||
QGSPage* getGraphicsScene() { return m_graphicsScene; }
|
||||
void setGraphicsView(QGVPage* gv);
|
||||
void setGraphicsScene(QGSPage* gs);
|
||||
virtual bool canDelete(App::DocumentObject* obj) const override;
|
||||
void setGrid(void);
|
||||
|
||||
@@ -109,6 +112,7 @@ private:
|
||||
bool m_docReady;
|
||||
std::string m_pageName;
|
||||
QGVPage* m_graphicsView;
|
||||
QGSPage* m_graphicsScene;
|
||||
};
|
||||
|
||||
} // namespace TechDrawGui
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "QGITemplate.h"
|
||||
#include "QGISVGTemplate.h"
|
||||
#include "QGVPage.h"
|
||||
#include "QGSPage.h"
|
||||
#include "MDIViewPage.h"
|
||||
#include "TemplateTextField.h"
|
||||
#include "ViewProviderPage.h"
|
||||
@@ -94,6 +95,7 @@ void ViewProviderTemplate::updateData(const App::Property* prop)
|
||||
if (mdi != nullptr) {
|
||||
mdi->attachTemplate(t);
|
||||
mdi->viewAll();
|
||||
mdi->getViewProviderPage()->setGrid();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,7 +153,7 @@ QGITemplate* ViewProviderTemplate::getQTemplate(void)
|
||||
if (dt) {
|
||||
MDIViewPage* mdi = getMDIViewPage();
|
||||
if (mdi != nullptr) {
|
||||
result = mdi->getQGVPage()->getTemplate();
|
||||
result = mdi->getQGSPage()->getTemplate();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user