Correct pageSize determination
remove obsolete code
This commit is contained in:
parent
78924d3a22
commit
fe871cd245
|
@ -40,6 +40,8 @@
|
||||||
#include <QPrintPreviewDialog>
|
#include <QPrintPreviewDialog>
|
||||||
#endif // #ifndef _PreComp_
|
#endif // #ifndef _PreComp_
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include "MDIViewPage.h"
|
#include "MDIViewPage.h"
|
||||||
|
|
||||||
#include <Base/Stream.h>
|
#include <Base/Stream.h>
|
||||||
|
@ -92,28 +94,16 @@ using namespace TechDrawGui;
|
||||||
|
|
||||||
MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget* parent)
|
MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget* parent)
|
||||||
: Gui::MDIView(doc, parent),
|
: Gui::MDIView(doc, parent),
|
||||||
//m_view(new QGVPage(pageVp)),
|
m_orientation(QPrinter::Landscape),
|
||||||
|
m_paperSize(QPrinter::A4),
|
||||||
pageGui(pageVp),
|
pageGui(pageVp),
|
||||||
m_frameState(true)
|
m_frameState(true)
|
||||||
{
|
{
|
||||||
m_view = new QGVPage(pageVp,m_scene,this);
|
m_view = new QGVPage(pageVp,m_scene,this);
|
||||||
|
|
||||||
m_backgroundAction = new QAction(tr("&Background"), this);
|
|
||||||
m_backgroundAction->setEnabled(false);
|
|
||||||
m_backgroundAction->setCheckable(true);
|
|
||||||
m_backgroundAction->setChecked(true);
|
|
||||||
connect(m_backgroundAction, SIGNAL(toggled(bool)), m_view, SLOT(setViewBackground(bool)));
|
|
||||||
|
|
||||||
m_exportSVGAction = new QAction(tr("&Export SVG"), this);
|
m_exportSVGAction = new QAction(tr("&Export SVG"), this);
|
||||||
connect(m_exportSVGAction, SIGNAL(triggered()), this, SLOT(saveSVG()));
|
connect(m_exportSVGAction, SIGNAL(triggered()), this, SLOT(saveSVG()));
|
||||||
|
|
||||||
//m_outlineAction is obs? never set to Enabled?
|
|
||||||
m_outlineAction = new QAction(tr("&Outline"), this);
|
|
||||||
m_outlineAction->setEnabled(false);
|
|
||||||
m_outlineAction->setCheckable(true);
|
|
||||||
m_outlineAction->setChecked(false);
|
|
||||||
connect(m_outlineAction, SIGNAL(toggled(bool)), m_view, SLOT(setViewOutline(bool))); //in QGVPage
|
|
||||||
|
|
||||||
m_nativeAction = new QAction(tr("&Native"), this);
|
m_nativeAction = new QAction(tr("&Native"), this);
|
||||||
m_nativeAction->setCheckable(true);
|
m_nativeAction->setCheckable(true);
|
||||||
m_nativeAction->setChecked(false);
|
m_nativeAction->setChecked(false);
|
||||||
|
@ -147,9 +137,6 @@ MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget*
|
||||||
setWindowTitle(tr("dummy[*]")); //Yuck. prevents "QWidget::setWindowModified: The window title does not contain a '[*]' placeholder"
|
setWindowTitle(tr("dummy[*]")); //Yuck. prevents "QWidget::setWindowModified: The window title does not contain a '[*]' placeholder"
|
||||||
setCentralWidget(m_view); //this makes m_view a Qt child of MDIViewPage
|
setCentralWidget(m_view); //this makes m_view a Qt child of MDIViewPage
|
||||||
|
|
||||||
m_orientation = QPrinter::Landscape;
|
|
||||||
m_pageSize = QPrinter::A4;
|
|
||||||
|
|
||||||
// Connect Signals and Slots
|
// Connect Signals and Slots
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
m_view->scene(), SIGNAL(selectionChanged()),
|
m_view->scene(), SIGNAL(selectionChanged()),
|
||||||
|
@ -157,7 +144,7 @@ MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget*
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// A fresh page is added and we iterate through its collected children and add these to Canvas View
|
// A fresh page is added and we iterate through its collected children and add these to Canvas View -MLP
|
||||||
// if docobj is a featureviewcollection (ex orthogroup), add its child views. if there are ever children that have children,
|
// if docobj is a featureviewcollection (ex orthogroup), add its child views. if there are ever children that have children,
|
||||||
// we'll have to make this recursive. -WF
|
// we'll have to make this recursive. -WF
|
||||||
const std::vector<App::DocumentObject*> &grp = pageGui->getPageObject()->Views.getValues();
|
const std::vector<App::DocumentObject*> &grp = pageGui->getPageObject()->Views.getValues();
|
||||||
|
@ -220,48 +207,6 @@ void MDIViewPage::setDimensionGroups(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MDIViewPage::findPrinterSettings(const QString& fileName)
|
|
||||||
{
|
|
||||||
if (fileName.indexOf(QLatin1String("Portrait"), Qt::CaseInsensitive) >= 0) {
|
|
||||||
m_orientation = QPrinter::Portrait;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
m_orientation = QPrinter::Landscape;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMap<QPrinter::PageSize, QString> pageSizes;
|
|
||||||
pageSizes[QPrinter::A0] = QString::fromLatin1("A0");
|
|
||||||
pageSizes[QPrinter::A1] = QString::fromLatin1("A1");
|
|
||||||
pageSizes[QPrinter::A2] = QString::fromLatin1("A2");
|
|
||||||
pageSizes[QPrinter::A3] = QString::fromLatin1("A3");
|
|
||||||
pageSizes[QPrinter::A4] = QString::fromLatin1("A4");
|
|
||||||
pageSizes[QPrinter::A5] = QString::fromLatin1("A5");
|
|
||||||
pageSizes[QPrinter::A6] = QString::fromLatin1("A6");
|
|
||||||
pageSizes[QPrinter::A7] = QString::fromLatin1("A7");
|
|
||||||
pageSizes[QPrinter::A8] = QString::fromLatin1("A8");
|
|
||||||
pageSizes[QPrinter::A9] = QString::fromLatin1("A9");
|
|
||||||
pageSizes[QPrinter::B0] = QString::fromLatin1("B0");
|
|
||||||
pageSizes[QPrinter::B1] = QString::fromLatin1("B1");
|
|
||||||
pageSizes[QPrinter::B2] = QString::fromLatin1("B2");
|
|
||||||
pageSizes[QPrinter::B3] = QString::fromLatin1("B3");
|
|
||||||
pageSizes[QPrinter::B4] = QString::fromLatin1("B4");
|
|
||||||
pageSizes[QPrinter::B5] = QString::fromLatin1("B5");
|
|
||||||
pageSizes[QPrinter::B6] = QString::fromLatin1("B6");
|
|
||||||
pageSizes[QPrinter::B7] = QString::fromLatin1("B7");
|
|
||||||
pageSizes[QPrinter::B8] = QString::fromLatin1("B8");
|
|
||||||
pageSizes[QPrinter::B9] = QString::fromLatin1("B9");
|
|
||||||
pageSizes[QPrinter::Letter] = QString::fromLatin1("Letter");
|
|
||||||
pageSizes[QPrinter::Legal] = QString::fromLatin1("Legal");
|
|
||||||
for (QMap<QPrinter::PageSize, QString>::iterator it = pageSizes.begin(); it != pageSizes.end(); ++it) {
|
|
||||||
if (fileName.startsWith(it.value(), Qt::CaseInsensitive)) {
|
|
||||||
m_pageSize = it.key();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MDIViewPage::setDocumentObject(const std::string& name)
|
void MDIViewPage::setDocumentObject(const std::string& name)
|
||||||
{
|
{
|
||||||
m_objectName = name;
|
m_objectName = name;
|
||||||
|
@ -290,8 +235,6 @@ void MDIViewPage::closeEvent(QCloseEvent* ev)
|
||||||
void MDIViewPage::contextMenuEvent(QContextMenuEvent *event)
|
void MDIViewPage::contextMenuEvent(QContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
menu.addAction(m_backgroundAction);
|
|
||||||
menu.addAction(m_outlineAction);
|
|
||||||
menu.addAction(m_exportSVGAction);
|
menu.addAction(m_exportSVGAction);
|
||||||
QMenu* submenu = menu.addMenu(tr("&Renderer"));
|
QMenu* submenu = menu.addMenu(tr("&Renderer"));
|
||||||
submenu->addAction(m_nativeAction);
|
submenu->addAction(m_nativeAction);
|
||||||
|
@ -305,10 +248,17 @@ void MDIViewPage::contextMenuEvent(QContextMenuEvent *event)
|
||||||
|
|
||||||
void MDIViewPage::attachTemplate(TechDraw::DrawTemplate *obj)
|
void MDIViewPage::attachTemplate(TechDraw::DrawTemplate *obj)
|
||||||
{
|
{
|
||||||
|
//why doesn't setting the template set the papersize???
|
||||||
m_view->setPageTemplate(obj);
|
m_view->setPageTemplate(obj);
|
||||||
double width = obj->Width.getValue();
|
double width = obj->Width.getValue();
|
||||||
double height = obj->Height.getValue();
|
double height = obj->Height.getValue();
|
||||||
m_view->scene()->setSceneRect(QRectF(-1.,-height,width+1.,height)); //the +/- 1 is because of the way the template is define???
|
m_view->scene()->setSceneRect(QRectF(-1.,-height,width+1.,height)); //the +/- 1 is because of the way the template is define???
|
||||||
|
m_paperSize = getPaperSize(int(round(width)),int(round(height)));
|
||||||
|
if (width > height) {
|
||||||
|
m_orientation = QPrinter::Landscape;
|
||||||
|
} else {
|
||||||
|
m_orientation = QPrinter::Portrait;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -576,7 +526,6 @@ void MDIViewPage::onRelabel(Gui::Document *pDoc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MDIViewPage::printPdf()
|
void MDIViewPage::printPdf()
|
||||||
{
|
{
|
||||||
Gui::FileOptionsDialog dlg(this, 0);
|
Gui::FileOptionsDialog dlg(this, 0);
|
||||||
|
@ -599,6 +548,8 @@ void MDIViewPage::printPdf()
|
||||||
gridLayout->addWidget(listWidget, 0, 0, 1, 1);
|
gridLayout->addWidget(listWidget, 0, 0, 1, 1);
|
||||||
formLayout->addWidget(groupBox, 0, 0, 1, 1);
|
formLayout->addWidget(groupBox, 0, 0, 1, 1);
|
||||||
|
|
||||||
|
//the "Extended" part of the dialog
|
||||||
|
//doesn't have any impact on result?
|
||||||
groupBox->setTitle(tr("Page sizes"));
|
groupBox->setTitle(tr("Page sizes"));
|
||||||
item = new QListWidgetItem(tr("A0"), listWidget);
|
item = new QListWidgetItem(tr("A0"), listWidget);
|
||||||
item->setData(Qt::UserRole, QVariant(QPrinter::A0));
|
item->setData(Qt::UserRole, QVariant(QPrinter::A0));
|
||||||
|
@ -619,7 +570,7 @@ void MDIViewPage::printPdf()
|
||||||
//listWidget->item(4)->setSelected(true); // by default A4
|
//listWidget->item(4)->setSelected(true); // by default A4
|
||||||
int index = 4; // by default A4
|
int index = 4; // by default A4
|
||||||
for (int i=0; i<listWidget->count(); i++) {
|
for (int i=0; i<listWidget->count(); i++) {
|
||||||
if (listWidget->item(i)->data(Qt::UserRole).toInt() == m_pageSize) {
|
if (listWidget->item(i)->data(Qt::UserRole).toInt() == m_paperSize) {
|
||||||
index = i;
|
index = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -635,11 +586,13 @@ void MDIViewPage::printPdf()
|
||||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||||
printer.setOutputFileName(filename);
|
printer.setOutputFileName(filename);
|
||||||
printer.setOrientation(m_orientation);
|
printer.setOrientation(m_orientation);
|
||||||
|
printer.setPaperSize(m_paperSize);
|
||||||
QList<QListWidgetItem*> items = listWidget->selectedItems();
|
QList<QListWidgetItem*> items = listWidget->selectedItems();
|
||||||
if (items.size() == 1) {
|
|
||||||
int AX = items.front()->data(Qt::UserRole).toInt();
|
// if (items.size() == 1) {
|
||||||
printer.setPaperSize(QPrinter::PageSize(AX));
|
// int AX = items.front()->data(Qt::UserRole).toInt();
|
||||||
}
|
// printer.setPaperSize(QPrinter::PaperSize(AX));
|
||||||
|
// }
|
||||||
|
|
||||||
print(&printer);
|
print(&printer);
|
||||||
}
|
}
|
||||||
|
@ -650,7 +603,7 @@ void MDIViewPage::print()
|
||||||
{
|
{
|
||||||
QPrinter printer(QPrinter::HighResolution);
|
QPrinter printer(QPrinter::HighResolution);
|
||||||
printer.setFullPage(true);
|
printer.setFullPage(true);
|
||||||
printer.setPageSize(m_pageSize);
|
printer.setPaperSize(m_paperSize);
|
||||||
printer.setOrientation(m_orientation);
|
printer.setOrientation(m_orientation);
|
||||||
QPrintDialog dlg(&printer, this);
|
QPrintDialog dlg(&printer, this);
|
||||||
if (dlg.exec() == QDialog::Accepted) {
|
if (dlg.exec() == QDialog::Accepted) {
|
||||||
|
@ -658,12 +611,11 @@ void MDIViewPage::print()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MDIViewPage::printPreview()
|
void MDIViewPage::printPreview()
|
||||||
{
|
{
|
||||||
QPrinter printer(QPrinter::HighResolution);
|
QPrinter printer(QPrinter::HighResolution);
|
||||||
printer.setFullPage(true);
|
printer.setFullPage(true);
|
||||||
printer.setPageSize(m_pageSize);
|
printer.setPaperSize(m_paperSize);
|
||||||
printer.setOrientation(m_orientation);
|
printer.setOrientation(m_orientation);
|
||||||
|
|
||||||
QPrintPreviewDialog dlg(&printer, this);
|
QPrintPreviewDialog dlg(&printer, this);
|
||||||
|
@ -690,8 +642,8 @@ void MDIViewPage::print(QPrinter* printer)
|
||||||
if (printer->outputFormat() == QPrinter::NativeFormat) {
|
if (printer->outputFormat() == QPrinter::NativeFormat) {
|
||||||
int w = printer->widthMM();
|
int w = printer->widthMM();
|
||||||
int h = printer->heightMM();
|
int h = printer->heightMM();
|
||||||
QPrinter::PaperSize realPaperSize = getPageSize(w, h);
|
QPrinter::PaperSize psPrtCalcd = getPaperSize(w, h);
|
||||||
QPrinter::PaperSize curPaperSize = printer->paperSize();
|
QPrinter::PaperSize psPrtSetting = printer->paperSize();
|
||||||
|
|
||||||
// for the preview a 'Picture' paint engine is used which we don't
|
// for the preview a 'Picture' paint engine is used which we don't
|
||||||
// care if it uses wrong printer settings
|
// care if it uses wrong printer settings
|
||||||
|
@ -705,7 +657,7 @@ void MDIViewPage::print(QPrinter* printer)
|
||||||
if (ret != QMessageBox::Yes)
|
if (ret != QMessageBox::Yes)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (doPrint && realPaperSize != m_pageSize) {
|
else if (doPrint && psPrtCalcd != m_paperSize) {
|
||||||
int ret = QMessageBox::warning(this, tr("Different paper size"),
|
int ret = QMessageBox::warning(this, tr("Different paper size"),
|
||||||
tr("The printer uses a different paper size than the drawing.\n"
|
tr("The printer uses a different paper size than the drawing.\n"
|
||||||
"Do you want to continue?"),
|
"Do you want to continue?"),
|
||||||
|
@ -713,7 +665,7 @@ void MDIViewPage::print(QPrinter* printer)
|
||||||
if (ret != QMessageBox::Yes)
|
if (ret != QMessageBox::Yes)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (doPrint && curPaperSize != m_pageSize) {
|
else if (doPrint && psPrtSetting != m_paperSize) {
|
||||||
int ret = QMessageBox::warning(this, tr("Different paper size"),
|
int ret = QMessageBox::warning(this, tr("Different paper size"),
|
||||||
tr("The printer uses a different paper size than the drawing.\n"
|
tr("The printer uses a different paper size than the drawing.\n"
|
||||||
"Do you want to continue?"),
|
"Do you want to continue?"),
|
||||||
|
@ -756,8 +708,7 @@ void MDIViewPage::print(QPrinter* printer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//QPrinter::PageSize is obsolete. Use QPrinter::PaperSize instead.
|
QPrinter::PaperSize MDIViewPage::getPaperSize(int w, int h) const
|
||||||
QPrinter::PageSize MDIViewPage::getPageSize(int w, int h) const
|
|
||||||
{
|
{
|
||||||
static const float paperSizes[][2] = {
|
static const float paperSizes[][2] = {
|
||||||
{210, 297}, // A4
|
{210, 297}, // A4
|
||||||
|
@ -792,23 +743,24 @@ QPrinter::PageSize MDIViewPage::getPageSize(int w, int h) const
|
||||||
{279.4f, 431.8f} // Tabloid
|
{279.4f, 431.8f} // Tabloid
|
||||||
};
|
};
|
||||||
|
|
||||||
QPrinter::PageSize ps = QPrinter::Custom;
|
QPrinter::PaperSize ps = QPrinter::Custom;
|
||||||
for (int i=0; i<30; i++) {
|
for (int i=0; i<30; i++) {
|
||||||
if (std::abs(paperSizes[i][0]-w) <= 1 &&
|
if (std::abs(paperSizes[i][0]-w) <= 1 &&
|
||||||
std::abs(paperSizes[i][1]-h) <= 1) {
|
std::abs(paperSizes[i][1]-h) <= 1) {
|
||||||
ps = static_cast<QPrinter::PageSize>(i);
|
ps = static_cast<QPrinter::PaperSize>(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (std::abs(paperSizes[i][0]-h) <= 1 &&
|
if (std::abs(paperSizes[i][0]-h) <= 1 &&
|
||||||
std::abs(paperSizes[i][1]-w) <= 1) {
|
std::abs(paperSizes[i][1]-w) <= 1) {
|
||||||
ps = static_cast<QPrinter::PageSize>(i);
|
ps = static_cast<QPrinter::PaperSize>(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ps;
|
return ps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MDIViewPage::setFrameState(bool state)
|
void MDIViewPage::setFrameState(bool state)
|
||||||
{
|
{
|
||||||
m_frameState = state;
|
m_frameState = state;
|
||||||
|
|
|
@ -95,8 +95,7 @@ protected:
|
||||||
int attachView(App::DocumentObject *obj);
|
int attachView(App::DocumentObject *obj);
|
||||||
void contextMenuEvent(QContextMenuEvent *event);
|
void contextMenuEvent(QContextMenuEvent *event);
|
||||||
void closeEvent(QCloseEvent*);
|
void closeEvent(QCloseEvent*);
|
||||||
void findPrinterSettings(const QString&);
|
QPrinter::PaperSize getPaperSize(int w, int h) const;
|
||||||
QPrinter::PageSize getPageSize(int w, int h) const;
|
|
||||||
void setDimensionGroups(void);
|
void setDimensionGroups(void);
|
||||||
void showStatusMsg(const char* s1, const char* s2, const char* s3) const;
|
void showStatusMsg(const char* s1, const char* s2, const char* s3) const;
|
||||||
|
|
||||||
|
@ -106,8 +105,6 @@ private:
|
||||||
QAction *m_exportSVGAction;
|
QAction *m_exportSVGAction;
|
||||||
QAction *m_imageAction;
|
QAction *m_imageAction;
|
||||||
QAction *m_highQualityAntialiasingAction;
|
QAction *m_highQualityAntialiasingAction;
|
||||||
QAction *m_backgroundAction;
|
|
||||||
QAction *m_outlineAction;
|
|
||||||
|
|
||||||
std::string m_objectName;
|
std::string m_objectName;
|
||||||
bool isSelectionBlocked;
|
bool isSelectionBlocked;
|
||||||
|
@ -115,7 +112,7 @@ private:
|
||||||
|
|
||||||
QString m_currentPath;
|
QString m_currentPath;
|
||||||
QPrinter::Orientation m_orientation;
|
QPrinter::Orientation m_orientation;
|
||||||
QPrinter::PageSize m_pageSize;
|
QPrinter::PaperSize m_paperSize;
|
||||||
ViewProviderPage *pageGui;
|
ViewProviderPage *pageGui;
|
||||||
|
|
||||||
bool m_frameState;
|
bool m_frameState;
|
||||||
|
|
|
@ -85,8 +85,6 @@ QGVPage::QGVPage(ViewProviderPage *vp, QGraphicsScene& s, QWidget *parent)
|
||||||
, pageTemplate(0)
|
, pageTemplate(0)
|
||||||
, m_renderer(Native)
|
, m_renderer(Native)
|
||||||
, drawBkg(true)
|
, drawBkg(true)
|
||||||
, m_backgroundItem(0)
|
|
||||||
, m_outlineItem(0)
|
|
||||||
, pageGui(0)
|
, pageGui(0)
|
||||||
{
|
{
|
||||||
assert(vp);
|
assert(vp);
|
||||||
|
@ -103,11 +101,6 @@ QGVPage::QGVPage(ViewProviderPage *vp, QGraphicsScene& s, QWidget *parent)
|
||||||
setCursor(QCursor(Qt::ArrowCursor));
|
setCursor(QCursor(Qt::ArrowCursor));
|
||||||
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
|
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
|
||||||
|
|
||||||
//m_backgroundItem = new QGraphicsRectItem();
|
|
||||||
//m_backgroundItem->setCacheMode(QGraphicsItem::NoCache);
|
|
||||||
//m_backgroundItem->setZValue(ZVALUE::BACKGROUND);
|
|
||||||
// scene()->addItem(m_backgroundItem); // TODO IF SEGFAULTS WITH DRAW ENABLE THIS (REDRAWS ARE SLOWER :s)
|
|
||||||
|
|
||||||
bkgBrush = new QBrush(QColor::fromRgb(70,70,70));
|
bkgBrush = new QBrush(QColor::fromRgb(70,70,70));
|
||||||
|
|
||||||
resetCachedContent();
|
resetCachedContent();
|
||||||
|
@ -115,7 +108,7 @@ QGVPage::QGVPage(ViewProviderPage *vp, QGraphicsScene& s, QWidget *parent)
|
||||||
QGVPage::~QGVPage()
|
QGVPage::~QGVPage()
|
||||||
{
|
{
|
||||||
delete bkgBrush;
|
delete bkgBrush;
|
||||||
//delete m_backgroundItem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QGVPage::drawBackground(QPainter *p, const QRectF &)
|
void QGVPage::drawBackground(QPainter *p, const QRectF &)
|
||||||
|
@ -382,35 +375,6 @@ QGIView * QGVPage::findParent(QGIView *view) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QGVPage::setPageFeature(TechDraw::DrawPage *page)
|
|
||||||
{
|
|
||||||
//redundant
|
|
||||||
#if 0
|
|
||||||
// TODO verify if the pointer should even be used. Not really safe
|
|
||||||
pageFeat = page;
|
|
||||||
|
|
||||||
float pageWidth = pageGui->getPageObject()->getPageWidth();
|
|
||||||
float pageHeight = pageGui->getPageObject()->getPageHeight();
|
|
||||||
|
|
||||||
QRectF paperRect(0, -pageHeight, pageWidth, pageHeight);
|
|
||||||
|
|
||||||
QBrush brush(Qt::white);
|
|
||||||
|
|
||||||
m_backgroundItem->setBrush(brush);
|
|
||||||
m_backgroundItem->setRect(paperRect);
|
|
||||||
|
|
||||||
QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect();
|
|
||||||
shadow->setBlurRadius(10.0);
|
|
||||||
shadow->setColor(Qt::white);
|
|
||||||
shadow->setOffset(0,0);
|
|
||||||
m_backgroundItem->setGraphicsEffect(shadow);
|
|
||||||
|
|
||||||
QRectF myRect = paperRect;
|
|
||||||
myRect.adjust(-20,-20,20,20);
|
|
||||||
setSceneRect(myRect);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void QGVPage::setPageTemplate(TechDraw::DrawTemplate *obj)
|
void QGVPage::setPageTemplate(TechDraw::DrawTemplate *obj)
|
||||||
{
|
{
|
||||||
// Remove currently set background template
|
// Remove currently set background template
|
||||||
|
@ -418,11 +382,9 @@ void QGVPage::setPageTemplate(TechDraw::DrawTemplate *obj)
|
||||||
removeTemplate();
|
removeTemplate();
|
||||||
|
|
||||||
if(obj->isDerivedFrom(TechDraw::DrawParametricTemplate::getClassTypeId())) {
|
if(obj->isDerivedFrom(TechDraw::DrawParametricTemplate::getClassTypeId())) {
|
||||||
//TechDraw::DrawParametricTemplate *dwgTemplate = static_cast<TechDraw::DrawParametricTemplate *>(obj);
|
|
||||||
QGIDrawingTemplate *qTempItem = new QGIDrawingTemplate(scene());
|
QGIDrawingTemplate *qTempItem = new QGIDrawingTemplate(scene());
|
||||||
pageTemplate = qTempItem;
|
pageTemplate = qTempItem;
|
||||||
} else if(obj->isDerivedFrom(TechDraw::DrawSVGTemplate::getClassTypeId())) {
|
} else if(obj->isDerivedFrom(TechDraw::DrawSVGTemplate::getClassTypeId())) {
|
||||||
//TechDraw::DrawSVGTemplate *dwgTemplate = static_cast<TechDraw::DrawSVGTemplate *>(obj);
|
|
||||||
QGISVGTemplate *qTempItem = new QGISVGTemplate(scene(),this);
|
QGISVGTemplate *qTempItem = new QGISVGTemplate(scene(),this);
|
||||||
pageTemplate = qTempItem;
|
pageTemplate = qTempItem;
|
||||||
}
|
}
|
||||||
|
@ -465,22 +427,6 @@ void QGVPage::setHighQualityAntialiasing(bool highQualityAntialiasing)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void QGVPage::setViewBackground(bool enable)
|
|
||||||
{
|
|
||||||
// if (!m_backgroundItem)
|
|
||||||
// return;
|
|
||||||
|
|
||||||
// m_backgroundItem->setVisible(enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QGVPage::setViewOutline(bool enable)
|
|
||||||
{
|
|
||||||
if (!m_outlineItem)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_outlineItem->setVisible(enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QGVPage::toggleMarkers(bool enable)
|
void QGVPage::toggleMarkers(bool enable)
|
||||||
{
|
{
|
||||||
QList<QGraphicsItem*> list = scene()->items();
|
QList<QGraphicsItem*> list = scene()->items();
|
||||||
|
|
|
@ -77,7 +77,6 @@ public:
|
||||||
const std::vector<QGIView *> & getViews() const { return views; }
|
const std::vector<QGIView *> & getViews() const { return views; }
|
||||||
int addView(QGIView * view);
|
int addView(QGIView * view);
|
||||||
void setViews(const std::vector<QGIView *> &view) {views = view; }
|
void setViews(const std::vector<QGIView *> &view) {views = view; }
|
||||||
void setPageFeature(TechDraw::DrawPage *page);
|
|
||||||
void setPageTemplate(TechDraw::DrawTemplate *pageTemplate);
|
void setPageTemplate(TechDraw::DrawTemplate *pageTemplate);
|
||||||
|
|
||||||
QGITemplate * getTemplate() const;
|
QGITemplate * getTemplate() const;
|
||||||
|
@ -93,8 +92,6 @@ public:
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void setHighQualityAntialiasing(bool highQualityAntialiasing);
|
void setHighQualityAntialiasing(bool highQualityAntialiasing);
|
||||||
void setViewBackground(bool enable);
|
|
||||||
void setViewOutline(bool enable);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void wheelEvent(QWheelEvent *event);
|
void wheelEvent(QWheelEvent *event);
|
||||||
|
@ -113,8 +110,6 @@ private:
|
||||||
RendererType m_renderer;
|
RendererType m_renderer;
|
||||||
|
|
||||||
bool drawBkg;
|
bool drawBkg;
|
||||||
QGraphicsRectItem *m_backgroundItem;
|
|
||||||
QGraphicsRectItem *m_outlineItem;
|
|
||||||
QBrush* bkgBrush;
|
QBrush* bkgBrush;
|
||||||
QImage m_image;
|
QImage m_image;
|
||||||
ViewProviderPage *pageGui;
|
ViewProviderPage *pageGui;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user