Merge branch 'master' into feature/job-tool-group

This commit is contained in:
mlampert
2021-01-02 10:58:47 -08:00
committed by GitHub
11 changed files with 174 additions and 64 deletions

View File

@@ -445,7 +445,11 @@ bool GraphvizView::onHasMsg(const char* pMsg) const
void GraphvizView::print(QPrinter* printer)
{
QPainter p(printer);
#if QT_VERSION >= 0x050300
QRect rect = printer->pageLayout().paintRectPixels(printer->resolution());
#else
QRect rect = printer->pageRect();
#endif
view->scene()->render(&p, rect);
//QByteArray buffer = exportGraph(QString::fromLatin1("svg"));
//QSvgRenderer svg(buffer);

View File

@@ -536,7 +536,11 @@ void View3DInventor::print(QPrinter* printer)
return;
}
#if QT_VERSION >= 0x050300
QRect rect = printer->pageLayout().paintRectPixels(printer->resolution());
#else
QRect rect = printer->pageRect();
#endif
QImage img;
_viewer->imageFromFramebuffer(rect.width(), rect.height(), 8, QColor(255,255,255), img);
p.drawImage(0,0,img);

View File

@@ -612,12 +612,20 @@ void DrawingView::print(QPrinter* printer)
qApp->restoreOverrideCursor();
return;
}
#if QT_VERSION >= 0x050300
QRect rect = printer->pageLayout().fullRectPixels(printer->resolution());
#else
QRect rect = printer->paperRect();
#endif
#ifdef Q_OS_WIN32
// On Windows the preview looks broken when using paperRect as render area.
// Although the picture is scaled when using pageRect, it looks just fine.
if (paintType == QPaintEngine::Picture)
rect = printer->pageRect();
#if QT_VERSION >= 0x050300
QRect rect = printer->pageLayout().paintRectPixels(printer->resolution());
#else
QRect rect = printer->pageRect();
#endif
#endif
this->m_view->scene()->render(&p, rect);
p.end();

View File

@@ -35,7 +35,7 @@
# include "boost_fix/intrusive/detail/memory_util.hpp"
# include "boost_fix/container/detail/memory_util.hpp"
# endif
# include <boost/geometry.hpp>
# include <boost_geometry.hpp>
# include <boost/geometry/index/rtree.hpp>
# include <boost/geometry/geometries/geometries.hpp>
# include <boost/geometry/geometries/register/point.hpp>

View File

@@ -91,26 +91,26 @@ const char* DrawViewBalloon::balloonTypeEnums[]= {"Circular",
DrawViewBalloon::DrawViewBalloon(void)
{
ADD_PROPERTY_TYPE(Text , (""),"",App::Prop_None,"The text to be displayed");
ADD_PROPERTY_TYPE(SourceView,(0),"",(App::PropertyType)(App::Prop_None),"Source view for balloon");
ADD_PROPERTY_TYPE(OriginX,(0),"",(App::PropertyType)(App::Prop_None),"Balloon origin x");
ADD_PROPERTY_TYPE(OriginY,(0),"",(App::PropertyType)(App::Prop_None),"Balloon origin y");
ADD_PROPERTY_TYPE(Text, (""), "", App::Prop_None, "The text to be displayed");
ADD_PROPERTY_TYPE(SourceView, (0), "", (App::PropertyType)(App::Prop_None), "Source view for balloon");
ADD_PROPERTY_TYPE(OriginX, (0), "", (App::PropertyType)(App::Prop_None), "Balloon origin x");
ADD_PROPERTY_TYPE(OriginY, (0), "", (App::PropertyType)(App::Prop_None), "Balloon origin y");
EndType.setEnums(ArrowPropEnum::ArrowTypeEnums);
ADD_PROPERTY(EndType,(prefEnd()));
ADD_PROPERTY_TYPE(EndType, (prefEnd()), "", (App::PropertyType)(App::Prop_None), "End symbol for the balloon line");
ADD_PROPERTY_TYPE(EndTypeScale,(1.0),"",(App::PropertyType)(App::Prop_None),"EndType shape scale");
ADD_PROPERTY_TYPE(EndTypeScale, (1.0), "", (App::PropertyType)(App::Prop_None),"End symbol scale factor");
EndTypeScale.setConstraints(&SymbolScaleRange);
BubbleShape.setEnums(balloonTypeEnums);
ADD_PROPERTY(BubbleShape,(prefShape()));
ADD_PROPERTY_TYPE(BubbleShape, (prefShape()), "", (App::PropertyType)(App::Prop_None), "Shape of the balloon bubble");
ADD_PROPERTY_TYPE(ShapeScale,(1.0),"",(App::PropertyType)(App::Prop_None),"Balloon shape scale");
ADD_PROPERTY_TYPE(ShapeScale, (1.0), "", (App::PropertyType)(App::Prop_None), "Balloon shape scale");
ShapeScale.setConstraints(&SymbolScaleRange);
ADD_PROPERTY_TYPE(TextWrapLen,(-1),"",(App::PropertyType)(App::Prop_None),"Text wrap length; -1 means no wrap");
ADD_PROPERTY_TYPE(TextWrapLen, (-1), "", (App::PropertyType)(App::Prop_None), "Text wrap length; -1 means no wrap");
ADD_PROPERTY_TYPE(KinkLength,(prefKinkLength()),"",(App::PropertyType)(App::Prop_None),
ADD_PROPERTY_TYPE(KinkLength, (prefKinkLength()), "", (App::PropertyType)(App::Prop_None),
"Distance from symbol to leader kink");
SourceView.setScope(App::LinkScope::Global);

View File

@@ -757,12 +757,20 @@ void MDIViewPage::print(QPrinter* printer)
return;
}
#if QT_VERSION >= 0x050300
QRect targetRect = printer->pageLayout().fullRectPixels(printer->resolution());
#else
QRect targetRect = printer->paperRect();
#endif
#ifdef Q_OS_WIN32
// On Windows the preview looks broken when using paperRect as render area.
// Although the picture is scaled when using pageRect, it looks just fine.
if (paintType == QPaintEngine::Picture)
targetRect = printer->pageRect();
#if QT_VERSION >= 0x050300
QRect targetRect = printer->pageLayout().paintRectPixels(printer->resolution());
#else
QRect targetRect = printer->pageRect();
#endif
#endif
//bool block =

View File

@@ -68,44 +68,49 @@ TaskBalloon::TaskBalloon(QGIViewBalloon *parent, ViewProviderBalloon *balloonVP)
ui->setupUi(this);
ui->inputScale->setValue(parent->dvBalloon->ShapeScale.getValue());
connect(ui->inputScale, SIGNAL(valueChanged(double)), this, SLOT(onShapeScaleChanged()));
ui->qsbShapeScale->setValue(parent->dvBalloon->ShapeScale.getValue());
connect(ui->qsbShapeScale, SIGNAL(valueChanged(double)), this, SLOT(onShapeScaleChanged()));
ui->qsbSymbolScale->setValue(parent->dvBalloon->EndTypeScale.getValue());
connect(ui->qsbSymbolScale, SIGNAL(valueChanged(double)), this, SLOT(onEndSymbolScaleChanged()));
std::string value = parent->dvBalloon->Text.getValue();
QString qs = QString::fromUtf8(value.data(), value.size());
ui->inputValue->setText(qs);
ui->inputValue->selectAll();
connect(ui->inputValue, SIGNAL(textChanged(QString)), this, SLOT(onTextChanged()));
QTimer::singleShot(0, ui->inputValue, SLOT(setFocus()));
ui->leText->setText(qs);
ui->leText->selectAll();
connect(ui->leText, SIGNAL(textChanged(QString)), this, SLOT(onTextChanged()));
QTimer::singleShot(0, ui->leText, SLOT(setFocus()));
DrawGuiUtil::loadArrowBox(ui->comboEndType);
DrawGuiUtil::loadArrowBox(ui->comboEndSymbol);
i = parent->dvBalloon->EndType.getValue();
ui->comboEndType->setCurrentIndex(i);
connect(ui->comboEndType, SIGNAL(currentIndexChanged(int)), this, SLOT(onEndTypeChanged()));
ui->comboEndSymbol->setCurrentIndex(i);
connect(ui->comboEndSymbol, SIGNAL(currentIndexChanged(int)), this, SLOT(onEndSymbolChanged()));
i = parent->dvBalloon->BubbleShape.getValue();
ui->comboSymbol->setCurrentIndex(i);
connect(ui->comboSymbol, SIGNAL(currentIndexChanged(int)), this, SLOT(onShapeChanged()));
ui->comboBubbleShape->setCurrentIndex(i);
connect(ui->comboBubbleShape, SIGNAL(currentIndexChanged(int)), this, SLOT(onBubbleShapeChanged()));
ui->qsbFontSize->setUnit(Base::Unit::Length);
ui->qsbFontSize->setMinimum(0);
connect(ui->qsbFontSize, SIGNAL(valueChanged(double)), this, SLOT(onFontsizeChanged()));
connect(ui->comboLineVisible, SIGNAL(currentIndexChanged(int)), this, SLOT(onLineVisibleChanged()));
ui->qsbLineWidth->setUnit(Base::Unit::Length);
ui->qsbLineWidth->setSingleStep(0.100);
ui->qsbLineWidth->setMinimum(0);
connect(ui->qsbLineWidth, SIGNAL(valueChanged(double)), this, SLOT(onLineWidthChanged()));
ui->qsbBalloonKink->setUnit(Base::Unit::Length);
ui->qsbKinkLength->setUnit(Base::Unit::Length);
// negative kink length is allowed, thus no minimum
connect(ui->qsbBalloonKink, SIGNAL(valueChanged(double)), this, SLOT(onBalloonKinkChanged()));
connect(ui->qsbKinkLength, SIGNAL(valueChanged(double)), this, SLOT(onKinkLengthChanged()));
if (balloonVP != nullptr) {
ui->textColor->setColor(balloonVP->Color.getValue().asValue<QColor>());
connect(ui->textColor, SIGNAL(changed()), this, SLOT(onColorChanged()));
ui->qsbFontSize->setValue(balloonVP->Fontsize.getValue());
ui->comboLineVisible->setCurrentIndex(balloonVP->LineVisible.getValue());
ui->qsbLineWidth->setValue(balloonVP->LineWidth.getValue());
}
// new balloons have already the preferences BalloonKink length
ui->qsbBalloonKink->setValue(parent->dvBalloon->KinkLength.getValue());
ui->qsbKinkLength->setValue(parent->dvBalloon->KinkLength.getValue());
}
TaskBalloon::~TaskBalloon()
@@ -115,16 +120,18 @@ TaskBalloon::~TaskBalloon()
bool TaskBalloon::accept()
{
m_parent->dvBalloon->Text.setValue(ui->inputValue->text().toUtf8().constData());
m_parent->dvBalloon->Text.setValue(ui->leText->text().toUtf8().constData());
App::Color ac;
ac.setValue<QColor>(ui->textColor->color());
m_balloonVP->Color.setValue(ac);
m_balloonVP->Fontsize.setValue(ui->qsbFontSize->value().getValue());
m_parent->dvBalloon->ShapeScale.setValue(ui->inputScale->value().getValue());
m_parent->dvBalloon->EndType.setValue(ui->comboEndType->currentIndex());
m_parent->dvBalloon->BubbleShape.setValue(ui->comboSymbol->currentIndex());
m_parent->dvBalloon->ShapeScale.setValue(ui->qsbShapeScale->value().getValue());
m_parent->dvBalloon->EndType.setValue(ui->comboEndSymbol->currentIndex());
m_parent->dvBalloon->EndTypeScale.setValue(ui->qsbSymbolScale->value().getValue());
m_parent->dvBalloon->BubbleShape.setValue(ui->comboBubbleShape->currentIndex());
m_balloonVP->LineVisible.setValue(ui->comboLineVisible->currentIndex());
m_balloonVP->LineWidth.setValue(ui->qsbLineWidth->value().getValue());
m_parent->dvBalloon->KinkLength.setValue(ui->qsbBalloonKink->value().getValue());
m_parent->dvBalloon->KinkLength.setValue(ui->qsbKinkLength->value().getValue());
m_parent->updateView(true);
return true;
@@ -144,7 +151,7 @@ void TaskBalloon::recomputeFeature()
void TaskBalloon::onTextChanged()
{
m_parent->dvBalloon->Text.setValue(ui->inputValue->text().toUtf8().constData());
m_parent->dvBalloon->Text.setValue(ui->leText->text().toUtf8().constData());
recomputeFeature();
}
@@ -162,21 +169,33 @@ void TaskBalloon::onFontsizeChanged()
recomputeFeature();
}
void TaskBalloon::onShapeChanged()
void TaskBalloon::onBubbleShapeChanged()
{
m_parent->dvBalloon->BubbleShape.setValue(ui->comboSymbol->currentIndex());
m_parent->dvBalloon->BubbleShape.setValue(ui->comboBubbleShape->currentIndex());
recomputeFeature();
}
void TaskBalloon::onShapeScaleChanged()
{
m_parent->dvBalloon->ShapeScale.setValue(ui->inputScale->value().getValue());
m_parent->dvBalloon->ShapeScale.setValue(ui->qsbShapeScale->value().getValue());
recomputeFeature();
}
void TaskBalloon::onEndTypeChanged()
void TaskBalloon::onEndSymbolChanged()
{
m_parent->dvBalloon->EndType.setValue(ui->comboEndType->currentIndex());
m_parent->dvBalloon->EndType.setValue(ui->comboEndSymbol->currentIndex());
recomputeFeature();
}
void TaskBalloon::onEndSymbolScaleChanged()
{
m_parent->dvBalloon->EndTypeScale.setValue(ui->qsbSymbolScale->value().getValue());
recomputeFeature();
}
void TaskBalloon::onLineVisibleChanged()
{
m_balloonVP->LineVisible.setValue(ui->comboLineVisible->currentIndex());
recomputeFeature();
}
@@ -186,9 +205,9 @@ void TaskBalloon::onLineWidthChanged()
recomputeFeature();
}
void TaskBalloon::onBalloonKinkChanged()
void TaskBalloon::onKinkLengthChanged()
{
m_parent->dvBalloon->KinkLength.setValue(ui->qsbBalloonKink->value().getValue());
m_parent->dvBalloon->KinkLength.setValue(ui->qsbKinkLength->value().getValue());
recomputeFeature();
}

View File

@@ -56,11 +56,13 @@ private Q_SLOTS:
void onTextChanged();
void onColorChanged();
void onFontsizeChanged();
void onShapeChanged();
void onBubbleShapeChanged();
void onShapeScaleChanged();
void onEndTypeChanged();
void onEndSymbolChanged();
void onEndSymbolScaleChanged();
void onLineVisibleChanged();
void onLineWidthChanged();
void onBalloonKinkChanged();
void onKinkLengthChanged();
private:
Ui_TaskBalloon *ui;

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>307</width>
<height>229</height>
<height>279</height>
</rect>
</property>
<property name="windowTitle">
@@ -24,7 +24,7 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="inputValue">
<widget class="QLineEdit" name="leText">
<property name="toolTip">
<string>Text to be displayed</string>
</property>
@@ -54,7 +54,7 @@
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Fontsize:</string>
<string>Font Size:</string>
</property>
</widget>
</item>
@@ -92,12 +92,12 @@
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Shape:</string>
<string>Bubble Shape:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="comboSymbol">
<widget class="QComboBox" name="comboBubbleShape">
<property name="toolTip">
<string>Shape of the balloon bubble</string>
</property>
@@ -174,7 +174,7 @@
</widget>
</item>
<item row="4" column="1">
<widget class="Gui::QuantitySpinBox" name="inputScale">
<widget class="Gui::QuantitySpinBox" name="qsbShapeScale">
<property name="minimumSize">
<size>
<width>0</width>
@@ -182,7 +182,7 @@
</size>
</property>
<property name="toolTip">
<string>Scale factor for the 'Shape'</string>
<string>Bubble shape scale factor</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -206,20 +206,79 @@
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="comboEndType">
<widget class="QComboBox" name="comboEndSymbol">
<property name="toolTip">
<string>End symbol for the balloon line</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>End Symbol Scale:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="Gui::QuantitySpinBox" name="qsbSymbolScale">
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>End symbol scale factor</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Line Visible:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QComboBox" name="comboLineVisible">
<property name="toolTip">
<string>Whether the leader line is visible or not</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>False</string>
</property>
</item>
<item>
<property name="text">
<string>True</string>
</property>
</item>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Line Width:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="8" column="1">
<widget class="Gui::QuantitySpinBox" name="qsbLineWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@@ -250,15 +309,15 @@
</property>
</widget>
</item>
<item row="7" column="0">
<item row="9" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Leader Kink Length:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="Gui::QuantitySpinBox" name="qsbBalloonKink">
<item row="9" column="1">
<widget class="Gui::QuantitySpinBox" name="qsbKinkLength">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>

View File

@@ -47,7 +47,6 @@
#include <Gui/ViewProviderDocumentObject.h>
#include <Mod/TechDraw/App/LineGroup.h>
//#include <Mod/TechDraw/App/Preferences.h>
#include "PreferencesGui.h"
#include "TaskBalloon.h"
@@ -67,18 +66,16 @@ ViewProviderBalloon::ViewProviderBalloon()
static const char *group = "Balloon Format";
ADD_PROPERTY_TYPE(Font,(Preferences::labelFont().c_str()),group,App::Prop_None, "The name of the font to use");
ADD_PROPERTY_TYPE(Fontsize,(Preferences::dimFontSizeMM()),
group,(App::PropertyType)(App::Prop_None),"Balloon text size in units");
ADD_PROPERTY_TYPE(Font, (Preferences::labelFont().c_str()), group, App::Prop_None, "The name of the font to use");
ADD_PROPERTY_TYPE(Fontsize, (Preferences::dimFontSizeMM()),
group, (App::PropertyType)(App::Prop_None), "Balloon text size in units");
int lgNumber = Preferences::lineGroup();
auto lg = TechDraw::LineGroup::lineGroupFactory(lgNumber);
double weight = lg->getWeight("Thin");
delete lg; //Coverity CID 174670
ADD_PROPERTY_TYPE(LineWidth,(weight),group,(App::PropertyType)(App::Prop_None),"Leader line width");
ADD_PROPERTY_TYPE(LineVisible,(true),group,(App::PropertyType)(App::Prop_None),"Balloon line visible or hidden");
ADD_PROPERTY_TYPE(Color,(PreferencesGui::dimColor()),
group,App::Prop_None,"Color of the balloon");
ADD_PROPERTY_TYPE(LineWidth, (weight), group, (App::PropertyType)(App::Prop_None), "Leader line width");
ADD_PROPERTY_TYPE(LineVisible, (true), group, (App::PropertyType)(App::Prop_None), "Balloon line visible or hidden");
ADD_PROPERTY_TYPE(Color, (PreferencesGui::dimColor()), group, App::Prop_None, "Color of the balloon");
}
ViewProviderBalloon::~ViewProviderBalloon()

9
src/boost_geometry.hpp Normal file
View File

@@ -0,0 +1,9 @@
#ifndef FREECAD_GEOMETRY_HPP_WORKAROUND
#define FREECAD_GEOMETRY_HPP_WORKAROUND
// Workaround for boost >= 1.74
#define BOOST_ALLOW_DEPRECATED_HEADERS
#include <boost/geometry.hpp>
#undef BOOST_ALLOW_DEPRECATED_HEADERS
#endif // #ifndef FREECAD_GEOMETRY_HPP_WORKAROUND