Compare commits

...

9 Commits

Author SHA1 Message Date
wmayer a88db11e0a Fem: [skip ci] set backend of matplotlib to Qt5Agg 2021-03-11 20:48:53 +01:00
donovaly f4574cf02d [Gui] fix HiDPI rounding bug
As reported in https://forum.freecadweb.org/viewtopic.php?f=10&t=56425&start=20#p485809
this PR fixes the problem reported here: https://forum.freecadweb.org/viewtopic.php?f=10&t=56425&start=20#p485759
2021-03-10 15:23:33 +01:00
Chris Hennes 159a71bba7 [0.19][Web] Remove HiDPI fix when using QTWEBVIEW
The screen scale adjustment code here should not be necessary when using
the Chromium-based QtWebView widget, which correctly handles logical vs.
device px units. The scaling causes poor font size choice when used on
ultrawide monitors, as reported in
https://forum.freecadweb.org/viewtopic.php?p=485431
2021-03-08 18:51:06 +01:00
donovaly dfc3e2b9a6 [Main] set Coin environment variable
as discussed in https://forum.freecadweb.org/viewtopic.php?f=10&t=56386&start=10 we need to set this environment variable for Coin on Windows
2021-03-08 15:21:17 +01:00
donovaly 27b568e4e4 update for FC 0.19.0 2021-03-05 12:24:05 +01:00
wmayer a266852510 PD: AddressSanitizer: heap-use-after-free
Fix crash inside TaskDlgSketchBasedParameters::reject()
2021-03-03 15:53:44 +01:00
donovaly 408128838c [PD] fix multi-transform View
- fixes bug 4581
  See the first issue reported here:
  https://forum.freecadweb.org/viewtopic.php?f=3&t=56093#p482553

- also fix issue that one could set 1 occurrence for polar patterns despite 2 are required at least

- also fix potential dereferencing null pointer (reported by MSVC)
2021-03-02 10:40:13 +01:00
Yorik van Havre fc0c1069d2 Arch: Fixed SectionPlane outside objects bug in ArchSectionPlane - Fixes #4549 2021-03-01 16:50:10 +01:00
wmayer 5ea583466d Gui: [skip ci] allow to unbind() an ExpressionBinding and automatically unbind it if the observed object has been deleted
For more details see: https://forum.freecadweb.org/viewtopic.php?f=8&t=56097
2021-03-01 16:00:08 +01:00
11 changed files with 105 additions and 39 deletions
+3
View File
@@ -1937,6 +1937,9 @@ void Application::runApplication(void)
else {
// Enable automatic scaling based on pixel density of display (added in Qt 5.6)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif
}
#endif // QT_VERSION >= 0x050600
+20 -1
View File
@@ -59,6 +59,13 @@ bool ExpressionBinding::isBound() const
return path.getDocumentObject() != 0;
}
void ExpressionBinding::unbind()
{
expressionchanged.disconnect();
objectdeleted.disconnect();
path = App::ObjectIdentifier();
}
void Gui::ExpressionBinding::setExpression(boost::shared_ptr<Expression> expr)
{
DocumentObject * docObj = path.getDocumentObject();
@@ -100,7 +107,11 @@ void ExpressionBinding::bind(const App::ObjectIdentifier &_path)
//connect to be informed about changes
DocumentObject * docObj = path.getDocumentObject();
connection = docObj->ExpressionEngine.expressionChanged.connect(boost::bind(&ExpressionBinding::expressionChange, this, bp::_1));
if (docObj) {
expressionchanged = docObj->ExpressionEngine.expressionChanged.connect(boost::bind(&ExpressionBinding::expressionChange, this, bp::_1));
App::Document* doc = docObj->getDocument();
objectdeleted = doc->signalDeletedObject.connect(boost::bind(&ExpressionBinding::objectDeleted, this, bp::_1));
}
}
void ExpressionBinding::bind(const Property &prop)
@@ -247,3 +258,11 @@ void ExpressionBinding::expressionChange(const ObjectIdentifier& id) {
if(id==path)
onChange();
}
void ExpressionBinding::objectDeleted(const App::DocumentObject& obj)
{
DocumentObject * docObj = path.getDocumentObject();
if (docObj == &obj) {
unbind();
}
}
+7 -4
View File
@@ -44,6 +44,7 @@ public:
virtual void bind(const App::ObjectIdentifier & _path);
virtual void bind(const App::Property & prop);
bool isBound() const;
void unbind();
virtual bool apply(const std::string &propName);
virtual bool apply();
bool hasExpression() const;
@@ -52,8 +53,8 @@ public:
//auto apply means that the python code is issued not only on apply() but
//also on setExpression
bool autoApply() const {return m_autoApply;};
void setAutoApply(bool value) {m_autoApply = value;};
bool autoApply() const {return m_autoApply;}
void setAutoApply(bool value) {m_autoApply = value;}
protected:
const App::ObjectIdentifier & getPath() const { return path; }
@@ -63,7 +64,7 @@ protected:
virtual void setExpression(boost::shared_ptr<App::Expression> expr);
//gets called when the bound expression is changed, either by this binding or any external action
virtual void onChange() {};
virtual void onChange() {}
private:
App::ObjectIdentifier path;
@@ -75,7 +76,9 @@ protected:
int iconHeight;
void expressionChange(const App::ObjectIdentifier& id);
boost::signals2::scoped_connection connection;
void objectDeleted(const App::DocumentObject&);
boost::signals2::scoped_connection expressionchanged;
boost::signals2::scoped_connection objectdeleted;
bool m_autoApply;
};
+4
View File
@@ -146,6 +146,10 @@ int main( int argc, char ** argv )
#endif
#if defined (FC_OS_WIN32)
// we need to force Coin not to use Freetype in order to find installed fonts on Windows
// see https://forum.freecadweb.org/viewtopic.php?p=485142#p485016
_putenv("COIN_FORCE_FREETYPE_OFF=1");
int argc_ = argc;
QVector<QByteArray> data;
QVector<char *> argv_;
+7 -5
View File
@@ -211,11 +211,11 @@ def getCutShapes(objs,cutplane,onlySolids,clip,joinArch,showHidden,groupSshapesB
cutface,cutvolume,invcutvolume = ArchCommands.getCutVolume(cutplane,shapes,clip)
shapes = []
if cutvolume:
for o, shapeList in objectShapes:
tmpSshapes = []
for sh in shapeList:
for sol in sh.Solids:
for o, shapeList in objectShapes:
tmpSshapes = []
for sh in shapeList:
for sol in sh.Solids:
if cutvolume:
if sol.Volume < 0:
sol.reverse()
c = sol.cut(cutvolume)
@@ -235,6 +235,8 @@ def getCutShapes(objs,cutplane,onlySolids,clip,joinArch,showHidden,groupSshapesB
if showHidden:
c = sol.cut(invcutvolume)
hshapes.append(c)
else:
shapes.extend(sol.Solids)
if len(tmpSshapes) > 0:
sshapes.extend(tmpSshapes)
@@ -30,6 +30,12 @@ __url__ = "https://www.freecadweb.org"
# \ingroup FEM
# \brief task panel for mechanical ResultObjectPython
try:
import matplotlib
matplotlib.use("Qt5Agg")
except Exception:
print("Failed to set matplotlib backend to Qt5Agg")
import matplotlib.pyplot as plt
import numpy as np
@@ -229,7 +229,8 @@ void TaskMultiTransformParameters::closeSubTask()
void TaskMultiTransformParameters::onTransformDelete()
{
if (editHint) return; // Can't delete the hint...
if (editHint)
return; // Can't delete the hint...
int row = ui->listTransformFeatures->currentIndex().row();
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(TransformedView->getObject());
std::vector<App::DocumentObject*> transformFeatures = pcMultiTransform->Transformations.getValues();
@@ -254,7 +255,8 @@ void TaskMultiTransformParameters::onTransformDelete()
void TaskMultiTransformParameters::onTransformEdit()
{
if (editHint) return; // Can't edit the hint...
if (editHint)
return; // Can't edit the hint...
closeSubTask(); // For example if user is editing one subTask and then double-clicks on another without OK'ing first
ui->listTransformFeatures->currentItem()->setSelected(true);
int row = ui->listTransformFeatures->currentIndex().row();
@@ -288,17 +290,23 @@ void TaskMultiTransformParameters::onTransformAddMirrored()
closeSubTask();
std::string newFeatName = TransformedView->getObject()->getDocument()->getUniqueObjectName("Mirrored");
auto pcActiveBody = PartDesignGui::getBody(false);
if(!pcActiveBody) return;
if (!pcActiveBody)
return;
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Mirrored"));
FCMD_OBJ_CMD(pcActiveBody,"newObject('PartDesign::Mirrored','"<<newFeatName<<"')");
FCMD_OBJ_CMD(pcActiveBody, "newObject('PartDesign::Mirrored','"<<newFeatName<<"')");
auto Feat = pcActiveBody->getDocument()->getObject(newFeatName.c_str());
if (!Feat)
return;
//Gui::Command::updateActive();
App::DocumentObject* sketch = getSketchObject();
if (sketch)
FCMD_OBJ_CMD(Feat,"MirrorPlane = ("<<Gui::Command::getObjectCmd(sketch)<<",['V_Axis'])");
FCMD_OBJ_CMD(Feat, "MirrorPlane = ("<<Gui::Command::getObjectCmd(sketch)<<",['V_Axis'])");
finishAdd(newFeatName);
// show the new view when no error
if (!Feat->isError())
TransformedView->getObject()->Visibility.setValue(true);
}
void TaskMultiTransformParameters::onTransformAddLinearPattern()
@@ -308,29 +316,35 @@ void TaskMultiTransformParameters::onTransformAddLinearPattern()
closeSubTask();
std::string newFeatName = TransformedView->getObject()->getDocument()->getUniqueObjectName("LinearPattern");
auto pcActiveBody = PartDesignGui::getBody(false);
if(!pcActiveBody) return;
if (!pcActiveBody)
return;
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Make LinearPattern"));
FCMD_OBJ_CMD(pcActiveBody,"newObject('PartDesign::LinearPattern','"<<newFeatName<<"')");
FCMD_OBJ_CMD(pcActiveBody, "newObject('PartDesign::LinearPattern','"<<newFeatName<<"')");
auto Feat = pcActiveBody->getDocument()->getObject(newFeatName.c_str());
if (!Feat)
return;
//Gui::Command::updateActive();
App::DocumentObject* sketch = getSketchObject();
if (sketch) {
FCMD_OBJ_CMD(Feat,"Direction = ("<<Gui::Command::getObjectCmd(sketch)<<",['H_Axis'])");
FCMD_OBJ_CMD(Feat, "Direction = ("<<Gui::Command::getObjectCmd(sketch)<<",['H_Axis'])");
}
else {
// set Direction value before filling up the combo box to avoid creating an empty item
// inside updateUI()
PartDesign::Body* body = static_cast<PartDesign::Body*>(Part::BodyBase::findBodyOf(getObject()));
if (body) {
FCMD_OBJ_CMD(Feat,"Direction = ("<<Gui::Command::getObjectCmd(body->getOrigin()->getX())<<",[''])");
FCMD_OBJ_CMD(Feat, "Direction = ("<<Gui::Command::getObjectCmd(body->getOrigin()->getX())<<",[''])");
}
}
FCMD_OBJ_CMD(Feat,"Length = 100");
FCMD_OBJ_CMD(Feat,"Occurrences = 2");
FCMD_OBJ_CMD(Feat, "Length = 100");
FCMD_OBJ_CMD(Feat, "Occurrences = 2");
finishAdd(newFeatName);
// show the new view when no error
if (!Feat->isError())
TransformedView->getObject()->Visibility.setValue(true);
}
void TaskMultiTransformParameters::onTransformAddPolarPattern()
@@ -338,19 +352,25 @@ void TaskMultiTransformParameters::onTransformAddPolarPattern()
closeSubTask();
std::string newFeatName = TransformedView->getObject()->getDocument()->getUniqueObjectName("PolarPattern");
auto pcActiveBody = PartDesignGui::getBody(false);
if(!pcActiveBody) return;
if (!pcActiveBody)
return;
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "PolarPattern"));
FCMD_OBJ_CMD(pcActiveBody,"newObject('PartDesign::PolarPattern','"<<newFeatName<<"')");
FCMD_OBJ_CMD(pcActiveBody, "newObject('PartDesign::PolarPattern','"<<newFeatName<<"')");
auto Feat = pcActiveBody->getDocument()->getObject(newFeatName.c_str());
if (!Feat)
return;
//Gui::Command::updateActive();
App::DocumentObject* sketch = getSketchObject();
if (sketch)
FCMD_OBJ_CMD(Feat, "Axis = ("<<Gui::Command::getObjectCmd(sketch)<<",['N_Axis'])");
FCMD_OBJ_CMD(Feat,"Angle = 360");
FCMD_OBJ_CMD(Feat,"Occurrences = 2");
FCMD_OBJ_CMD(Feat, "Angle = 360");
FCMD_OBJ_CMD(Feat, "Occurrences = 2");
finishAdd(newFeatName);
// show the new view when no error
if (!Feat->isError())
TransformedView->getObject()->Visibility.setValue(true);
}
void TaskMultiTransformParameters::onTransformAddScaled()
@@ -358,16 +378,22 @@ void TaskMultiTransformParameters::onTransformAddScaled()
closeSubTask();
std::string newFeatName = TransformedView->getObject()->getDocument()->getUniqueObjectName("Scaled");
auto pcActiveBody = PartDesignGui::getBody(false);
if(!pcActiveBody) return;
if (!pcActiveBody)
return;
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Scaled"));
FCMD_OBJ_CMD(pcActiveBody,"newObject('PartDesign::Scaled','"<<newFeatName<<"')");
FCMD_OBJ_CMD(pcActiveBody, "newObject('PartDesign::Scaled','"<<newFeatName<<"')");
auto Feat = pcActiveBody->getDocument()->getObject(newFeatName.c_str());
if (!Feat)
return;
//Gui::Command::updateActive();
FCMD_OBJ_CMD(Feat,"Factor = 2");
FCMD_OBJ_CMD(Feat,"Occurrences = 2");
FCMD_OBJ_CMD(Feat, "Factor = 2");
FCMD_OBJ_CMD(Feat, "Occurrences = 2");
finishAdd(newFeatName);
// show the new view when no error
if (!Feat->isError())
TransformedView->getObject()->Visibility.setValue(true);
}
void TaskMultiTransformParameters::finishAdd(std::string &newFeatName)
@@ -264,6 +264,7 @@ bool TaskDlgSketchBasedParameters::accept() {
bool TaskDlgSketchBasedParameters::reject()
{
PartDesign::ProfileBased* pcSketchBased = static_cast<PartDesign::ProfileBased*>(vp->getObject());
App::DocumentObjectWeakPtrT weakptr(pcSketchBased);
// get the Sketch
Sketcher::SketchObject *pcSketch = static_cast<Sketcher::SketchObject*>(pcSketchBased->Profile.getValue());
bool rv;
@@ -273,7 +274,7 @@ bool TaskDlgSketchBasedParameters::reject()
// if abort command deleted the object the sketch is visible again.
// The previous one feature already should be made visible
if (!Gui::Application::Instance->getViewProvider(pcSketchBased)) {
if (weakptr.expired()) {
// Make the sketch visible
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
Gui::Application::Instance->getViewProvider(pcSketch)->show();
+2
View File
@@ -239,6 +239,7 @@ Py::Object BrowserViewPy::setHtml(const Py::Tuple& args)
WebView::WebView(QWidget *parent)
: QWEBVIEW(parent)
{
#ifdef QTWEBKIT
// Increase html font size for high DPI displays
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QRect mainScreenSize = QApplication::primaryScreen()->geometry();
@@ -248,6 +249,7 @@ WebView::WebView(QWidget *parent)
if (mainScreenSize.width() > 1920){
setTextSizeMultiplier (mainScreenSize.width()/1920.0);
}
#endif
}
#ifdef QTWEBENGINE
+4 -4
View File
@@ -20,14 +20,14 @@ To build the installer you can do the following:
(You can alternatively get nsProcess from https://nsis.sourceforge.io/NsProcess_plugin)
7. Copy all FreeCAD files to the folder "~\FreeCAD"
e.g. "C:\FreeCAD\Installer\FreeCAD"
8. If you use a version of FreeCAD that was compiled using another MSVC version than MSVC 2017,
8. If you use a version of FreeCAD that was compiled using another MSVC version than MSVC 2019,
copy its distributable DLLs to the folder FILES_DEPS (see step 3).
9. Right-click on the file FreeCAD-installer.nsi and choose "Compile NSIS script"
to compile the installer.
10. The folder ~\MSVCRedist contains already all MSVC 2017 x64 redistributable DLLs necessary
for FreeCAD 0.19dev. If another MSVC version was used to compile FreeCAD, replace the DLLs by
10. The folder ~\MSVCRedist contains already all MSVC 2019 x64 redistributable DLLs necessary
for FreeCAD 0.19. If another MSVC version was used to compile FreeCAD, replace the DLLs by
the ones of the used MSVC. (They are usually available in the folder
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Redist\MSVC)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC)
For test builds of the installer you can turn off the compression. This speeds up
the build time for the installer a lot but increases its file size. The compression
+5 -5
View File
@@ -18,14 +18,14 @@ SetCompressor /SOLID lzma
!define APP_VERSION_MAJOR 0
!define APP_VERSION_MINOR 19
!define APP_VERSION_REVISION 0
!define APP_VERSION_EMERGENCY "rev18731" # use "1" for an emergency release of FreeCAD otherwise ""
!define APP_VERSION_EMERGENCY "" # use "1" for an emergency release of FreeCAD otherwise ""
# alternatively you can use APP_VERSION_EMERGENCY for a custom suffix of the version number
!define APP_EMERGENCY_DOT "" # use "." for an emergency release of FreeCAD otherwise ""
!define APP_VERSION_BUILD 1 # Start with 1 for the installer releases of each version
!define APP_VERSION "${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}.${APP_VERSION_REVISION}${APP_EMERGENCY_DOT}${APP_VERSION_EMERGENCY}" # Version to display
!define COPYRIGHT_YEAR 2020
!define COPYRIGHT_YEAR 2021
#--------------------------------
# Installer file name
@@ -43,6 +43,6 @@ SetCompressor /SOLID lzma
# File locations
# !!! you need to adjust them to the folders in your Windows system !!!
!define FILES_FREECAD "D:\usti\FreeCAD\Installer\FreeCAD"
!define FILES_DEPS "D:\usti\FreeCAD\Installer\MSVCRedist"
!define FILES_THUMBS "D:\usti\FreeCAD\Installer\thumbnail"
!define FILES_FREECAD "G:\FreeCADInst\Installer\FreeCAD"
!define FILES_DEPS "G:\FreeCADInst\Installer\MSVCRedist"
!define FILES_THUMBS "G:\FreeCADInst\Installer\thumbnail"