[TD]prevent use of non-exist/hidden tab in exports
This commit is contained in:
@@ -37,7 +37,6 @@
|
||||
#include <Mod/TechDraw/App/DrawPagePy.h>
|
||||
#include <Mod/TechDraw/App/DrawViewPy.h> // generated from DrawViewPy.xml
|
||||
|
||||
#include "MDIViewPage.h"
|
||||
#include "QGIView.h"
|
||||
#include "QGSPage.h"
|
||||
#include "ViewProviderPage.h"
|
||||
@@ -131,25 +130,30 @@ private:
|
||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
PyObject* item = (*it).ptr();
|
||||
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {
|
||||
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr();
|
||||
App::DocumentObject* obj =
|
||||
static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr();
|
||||
if (obj->isDerivedFrom<TechDraw::DrawPage>()) {
|
||||
page = static_cast<TechDraw::DrawPage*>(obj);
|
||||
Gui::Document* activeGui = Gui::Application::Instance->getDocument(page->getDocument());
|
||||
Gui::Document* activeGui =
|
||||
Gui::Application::Instance->getDocument(page->getDocument());
|
||||
Gui::ViewProvider* vp = activeGui->getViewProvider(obj);
|
||||
ViewProviderPage* dvp = dynamic_cast<ViewProviderPage*>(vp);
|
||||
if ( !(dvp && dvp->getMDIViewPage()) ) {
|
||||
ViewProviderPage* vpPage = dynamic_cast<ViewProviderPage*>(vp);
|
||||
if (!vpPage) {
|
||||
throw Py::TypeError("TechDraw can not find Page");
|
||||
}
|
||||
|
||||
Base::FileInfo fi_out(EncodedName.c_str());
|
||||
|
||||
if (fi_out.hasExtension("svg")) {
|
||||
dvp->getMDIViewPage()->saveSVG(EncodedName);
|
||||
} else if (fi_out.hasExtension("dxf")) {
|
||||
dvp->getMDIViewPage()->saveDXF(EncodedName);
|
||||
} else if (fi_out.hasExtension("pdf")) {
|
||||
dvp->getMDIViewPage()->savePDF(EncodedName);
|
||||
} else {
|
||||
PagePrinter::saveSVG(vpPage, EncodedName);
|
||||
}
|
||||
else if (fi_out.hasExtension("dxf")) {
|
||||
PagePrinter::saveDXF(vpPage, EncodedName);
|
||||
}
|
||||
else if (fi_out.hasExtension("pdf")) {
|
||||
PagePrinter::savePDF(vpPage, EncodedName);
|
||||
}
|
||||
else {
|
||||
throw Py::TypeError("TechDraw can not export this file format");
|
||||
}
|
||||
}
|
||||
@@ -175,30 +179,22 @@ private:
|
||||
PyMem_Free(name);
|
||||
|
||||
try {
|
||||
App::DocumentObject* obj = nullptr;
|
||||
Gui::ViewProvider* vp = nullptr;
|
||||
MDIViewPage* mdi = nullptr;
|
||||
if (PyObject_TypeCheck(pageObj, &(App::DocumentObjectPy::Type))) {
|
||||
obj = static_cast<App::DocumentObjectPy*>(pageObj)->getDocumentObjectPtr();
|
||||
vp = Gui::Application::Instance->getViewProvider(obj);
|
||||
if (vp) {
|
||||
TechDrawGui::ViewProviderPage* vpp = dynamic_cast<TechDrawGui::ViewProviderPage*>(vp);
|
||||
if (vpp) {
|
||||
mdi = vpp->getMDIViewPage();
|
||||
if (mdi) {
|
||||
mdi->savePDF(filePath);
|
||||
} else {
|
||||
vpp->showMDIViewPage();
|
||||
mdi = vpp->getMDIViewPage();
|
||||
if (mdi) {
|
||||
mdi->savePDF(filePath);
|
||||
} else {
|
||||
throw Py::TypeError("Page not available! Is it Hidden?");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
App::DocumentObject* obj = nullptr;
|
||||
Gui::ViewProvider* vp = nullptr;
|
||||
if (PyObject_TypeCheck(pageObj, &(App::DocumentObjectPy::Type))) {
|
||||
obj = static_cast<App::DocumentObjectPy*>(pageObj)->getDocumentObjectPtr();
|
||||
vp = Gui::Application::Instance->getViewProvider(obj);
|
||||
if (vp) {
|
||||
TechDrawGui::ViewProviderPage* vpPage =
|
||||
dynamic_cast<TechDrawGui::ViewProviderPage*>(vp);
|
||||
if (vpPage) {
|
||||
PagePrinter::savePDF(vpPage, filePath);
|
||||
}
|
||||
else {
|
||||
throw Py::TypeError("Page not available! Is it Hidden?");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Base::Exception &e) {
|
||||
e.setPyException();
|
||||
@@ -221,30 +217,22 @@ private:
|
||||
PyMem_Free(name);
|
||||
|
||||
try {
|
||||
App::DocumentObject* obj = nullptr;
|
||||
Gui::ViewProvider* vp = nullptr;
|
||||
MDIViewPage* mdi = nullptr;
|
||||
if (PyObject_TypeCheck(pageObj, &(App::DocumentObjectPy::Type))) {
|
||||
obj = static_cast<App::DocumentObjectPy*>(pageObj)->getDocumentObjectPtr();
|
||||
vp = Gui::Application::Instance->getViewProvider(obj);
|
||||
if (vp) {
|
||||
TechDrawGui::ViewProviderPage* vpp = dynamic_cast<TechDrawGui::ViewProviderPage*>(vp);
|
||||
if (vpp) {
|
||||
mdi = vpp->getMDIViewPage();
|
||||
if (mdi) {
|
||||
mdi->saveSVG(filePath);
|
||||
} else {
|
||||
vpp->showMDIViewPage();
|
||||
mdi = vpp->getMDIViewPage();
|
||||
if (mdi) {
|
||||
mdi->saveSVG(filePath);
|
||||
} else {
|
||||
throw Py::TypeError("Page not available! Is it Hidden?");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
App::DocumentObject* obj = nullptr;
|
||||
Gui::ViewProvider* vp = nullptr;
|
||||
if (PyObject_TypeCheck(pageObj, &(App::DocumentObjectPy::Type))) {
|
||||
obj = static_cast<App::DocumentObjectPy*>(pageObj)->getDocumentObjectPtr();
|
||||
vp = Gui::Application::Instance->getViewProvider(obj);
|
||||
if (vp) {
|
||||
TechDrawGui::ViewProviderPage* vpPage =
|
||||
dynamic_cast<TechDrawGui::ViewProviderPage*>(vp);
|
||||
if (vpPage) {
|
||||
PagePrinter::saveSVG(vpPage, filePath);
|
||||
}
|
||||
else {
|
||||
throw Py::TypeError("Page not available! Is it Hidden?");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Base::Exception &e) {
|
||||
e.setPyException();
|
||||
|
||||
@@ -323,7 +323,7 @@ void CmdTechDrawView::activated(int iMsg)
|
||||
auto* vpp = dynamic_cast<ViewProviderPage*>
|
||||
(Gui::Application::Instance->getViewProvider(page));
|
||||
if (vpp) {
|
||||
vpp->switchToMdiViewPage();
|
||||
vpp->show();
|
||||
}
|
||||
|
||||
|
||||
@@ -1793,14 +1793,16 @@ void CmdTechDrawExportPageSVG::activated(int iMsg)
|
||||
|
||||
Gui::Document* activeGui = Gui::Application::Instance->getDocument(page->getDocument());
|
||||
Gui::ViewProvider* vp = activeGui->getViewProvider(page);
|
||||
ViewProviderPage* dvp = dynamic_cast<ViewProviderPage*>(vp);
|
||||
ViewProviderPage* vpPage = dynamic_cast<ViewProviderPage*>(vp);
|
||||
|
||||
if (dvp && dvp->getMDIViewPage()) {
|
||||
dvp->getMDIViewPage()->saveSVG();
|
||||
if (vpPage) {
|
||||
vpPage->show(); // make sure a mdi will be available
|
||||
vpPage->getMDIViewPage()->saveSVG();
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No Drawing View"),
|
||||
QObject::tr("Open Drawing View before attempting export to SVG."));
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
QObject::tr("No Drawing Page"),
|
||||
QObject::tr("FreeCAD could not find a page to export"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,11 +48,11 @@
|
||||
#include <Mod/TechDraw/App/Preferences.h>
|
||||
|
||||
#include "DrawGuiUtil.h"
|
||||
#include "MDIViewPage.h"
|
||||
#include "TaskGeomHatch.h"
|
||||
#include "TaskHatch.h"
|
||||
#include "ViewProviderGeomHatch.h"
|
||||
#include "ViewProviderPage.h"
|
||||
#include "MDIViewPage.h"
|
||||
|
||||
|
||||
using namespace TechDrawGui;
|
||||
@@ -312,35 +312,42 @@ Gui::Action *CmdTechDrawToggleFrame::createAction()
|
||||
void CmdTechDrawToggleFrame::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
TechDraw::DrawPage* page = DrawGuiUtil::findPage(this);
|
||||
if (!page) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto mvp = dynamic_cast<MDIViewPage *>(Gui::getMainWindow()->activeWindow());
|
||||
if (!mvp) {
|
||||
Gui::Document* activeGui = Gui::Application::Instance->getDocument(page->getDocument());
|
||||
Gui::ViewProvider* vp = activeGui->getViewProvider(page);
|
||||
ViewProviderPage* vpPage = dynamic_cast<ViewProviderPage*>(vp);
|
||||
|
||||
if (!vpPage) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No TechDraw Page"),
|
||||
QObject::tr("Need a TechDraw Page for this command"));
|
||||
return;
|
||||
}
|
||||
|
||||
ViewProviderPage* vpp = mvp->getViewProviderPage();
|
||||
if (!vpp) {
|
||||
return;
|
||||
}
|
||||
vpp->toggleFrameState();
|
||||
vpPage->toggleFrameState();
|
||||
|
||||
Gui::Action *action = this->getAction();
|
||||
if (action) {
|
||||
action->setChecked(!vpp->getFrameState(), true);
|
||||
action->setChecked(!vpPage->getFrameState(), true);
|
||||
}
|
||||
}
|
||||
|
||||
//! true if the active tab is a TechDraw Page.
|
||||
// There is an assumption here that you would only want to toggle the frames on a page when you are
|
||||
// currently looking at that page
|
||||
bool CmdTechDrawToggleFrame::isActive()
|
||||
{
|
||||
auto mvp = dynamic_cast<MDIViewPage *>(Gui::getMainWindow()->activeWindow());
|
||||
auto mvp = dynamic_cast<MDIViewPage*>(Gui::getMainWindow()->activeWindow());
|
||||
if (!mvp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ViewProviderPage* vpp = mvp->getViewProviderPage();
|
||||
Gui::Action *action = this->getAction();
|
||||
|
||||
Gui::Action* action = this->getAction();
|
||||
if (action) {
|
||||
action->setChecked(vpp && !vpp->getFrameState(), true);
|
||||
}
|
||||
|
||||
@@ -119,14 +119,11 @@ MDIViewPage::MDIViewPage(ViewProviderPage* pageVp, Gui::Document* doc, QWidget*
|
||||
connectDeletedObject = appDoc->signalDeletedObject.connect(bnd);
|
||||
//NOLINTEND
|
||||
|
||||
// m_pagePrinter = new PagePrinter(m_vpPage);
|
||||
// m_pagePrinter->setOwner(this);
|
||||
}
|
||||
|
||||
MDIViewPage::~MDIViewPage()
|
||||
{
|
||||
connectDeletedObject.disconnect();
|
||||
// delete m_pagePrinter;
|
||||
}
|
||||
|
||||
void MDIViewPage::setScene(QGSPage* scene, QGVPage* viewWidget)
|
||||
@@ -134,9 +131,6 @@ void MDIViewPage::setScene(QGSPage* scene, QGVPage* viewWidget)
|
||||
m_scene = scene;
|
||||
setCentralWidget(viewWidget);//this makes viewWidget a Qt child of MDIViewPage
|
||||
QObject::connect(scene, &QGSPage::selectionChanged, this, &MDIViewPage::sceneSelectionChanged);
|
||||
// if (m_pagePrinter) {
|
||||
// m_pagePrinter->setScene(m_scene);
|
||||
// }
|
||||
}
|
||||
|
||||
void MDIViewPage::setDocumentObject(const std::string& name)
|
||||
@@ -420,7 +414,7 @@ void MDIViewPage::print(QPrinter* printer)
|
||||
PagePrinter::print(getViewProviderPage(), printer);
|
||||
}
|
||||
|
||||
//static routine to print all pages in a document
|
||||
// static routine to print all pages in a document. Used by PrintAll command in Command.cpp
|
||||
void MDIViewPage::printAll(QPrinter* printer, App::Document* doc)
|
||||
{
|
||||
PagePrinter::printAll(printer, doc);
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/ViewProviderDocumentObject.h>
|
||||
#include <Mod/TechDraw/App/DrawHatch.h>
|
||||
#include <Mod/TechDraw/App/DrawGeomHatch.h>
|
||||
#include <Mod/TechDraw/App/DrawPage.h>
|
||||
#include <Mod/TechDraw/App/DrawProjGroupItem.h>
|
||||
#include <Mod/TechDraw/App/DrawTemplate.h>
|
||||
@@ -50,6 +51,7 @@
|
||||
#include <Mod/TechDraw/App/DrawViewBalloon.h>
|
||||
#include <Mod/TechDraw/App/DrawViewDimension.h>
|
||||
#include <Mod/TechDraw/App/DrawWeldSymbol.h>
|
||||
#include <Mod/TechDraw/App/Preferences.h>
|
||||
|
||||
#include "ViewProviderPage.h"
|
||||
#include "MDIViewPage.h"
|
||||
|
||||
Reference in New Issue
Block a user