Merge branch 'master' into PathArray_Z

This commit is contained in:
jimzim111
2021-09-22 19:33:16 -07:00
committed by GitHub
33 changed files with 2015 additions and 1067 deletions

View File

@@ -266,8 +266,10 @@ def get_zip_url(baseurl):
def get_readme_url(url):
"Returns the location of a readme file"
if "github" in url or "framagit" in url or "gitlab" in url:
if "github" in url or "framagit" in url:
return url+"/raw/master/README.md"
elif "gitlab" in url:
return url+"/-/raw/master/README.md"
else:
print("Debug: addonmanager_utilities.get_readme_url: Unknown git host:", url)
return None

View File

@@ -372,6 +372,15 @@ SET(Mesh_SRCS
Segment.h
)
# Suppress -Wundefined-var-template
if (MINGW AND CMAKE_COMPILER_IS_CLANGXX)
unset(_flag_found CACHE)
check_cxx_compiler_flag("-Wno-undefined-var-template" _flag_found)
if (_flag_found)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undefined-var-template")
endif()
endif()
if(FREECAD_USE_PCH)
add_definitions(-D_PreComp_)
GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${Core_SRCS} ${Mesh_SRCS})

View File

@@ -49,6 +49,8 @@
#include <boost/regex.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/convert.hpp>
#include <boost/convert/spirit.hpp>
using namespace MeshCore;
@@ -1656,31 +1658,88 @@ bool MeshInput::LoadNastran (std::istream &rstrIn)
while (std::getline(rstrIn, line)) {
upper(ltrim(line));
if (line.find("GRID*") == 0) {
if (line.empty()) {
// Skip all the following tests
}
else if (line.find('*') == 0) {
else if (line.rfind("GRID*", 0) == 0) {
// This element is the 16-digit-precision GRID element, which occupies two lines of the card. Note that
// FreeCAD discards the extra precision, downcasting to an four-byte float.
//
// The two lines are:
// 1 8 24 40 56
// GRID* Index(16) Blank(16) x(16) y(at least one)
// * z(at least one)
//
// The first character is typically the sign, and may be omitted for positive numbers,
// so it is possible for a field to begin with a blank. Trailing zeros may be omitted, so
// a field may also end with blanks. No space or other delimiter is required between
// the numbers. The following is a valid NASTRAN GRID* element:
//
// GRID* 1 0.1234567890120.
// * 1.
//
if (line.length() < 8 + 16 + 16 + 16 + 1) // Element type(8), index(16), empty(16), x(16), y(>=1)
continue;
auto indexView = std::string_view(&line[8], 16);
auto blankView = std::string_view(&line[8+16], 16);
auto xView = std::string_view(&line[8+16+16], 16);
auto yView = std::string_view(&line[8+16+16+16]);
std::string line2;
std::getline(rstrIn, line2);
if ((!line2.empty() && line2[0] != '*') ||
line2.length() < 9)
continue; // File format error: second line is not a continuation line
auto zView = std::string_view(&line2[8]);
// We have to strip off any whitespace (technically really just any *trailing* whitespace):
auto indexString = boost::trim_copy(std::string(indexView));
auto xString = boost::trim_copy(std::string(xView));
auto yString = boost::trim_copy(std::string(yView));
auto zString = boost::trim_copy(std::string(zView));
auto converter = boost::cnv::spirit();
auto indexCheck = boost::convert<int>(indexString, converter);
if (!indexCheck.is_initialized())
// File format error: index couldn't be converted to an integer
continue;
index = indexCheck.get();
// Get the high-precision versions first
auto x = boost::convert<double>(xString, converter);
auto y = boost::convert<double>(yString, converter);
auto z = boost::convert<double>(zString, converter);
if (!x.is_initialized() || !y.is_initialized() || !z.is_initialized())
// File format error: x, y or z could not be converted
continue;
// Now drop precision:
mNode[index].x = (float)x.get();
mNode[index].y = (float)y.get();
mNode[index].z = (float)z.get();
}
// insert the read-in vertex into a map to preserve the order
else if (line.find("GRID") == 0) {
else if (line.rfind("GRID", 0) == 0) {
if (boost::regex_match(line.c_str(), what, rx_p)) {
// insert the read-in vertex into a map to preserve the order
index = std::atol(what[1].first)-1;
mNode[index].x = (float)std::atof(what[2].first);
mNode[index].y = (float)std::atof(what[5].first);
mNode[index].z = (float)std::atof(what[8].first);
}
}
// insert the read-in triangle into a map to preserve the order
else if (line.find("CTRIA3 ") == 0) {
else if (line.rfind("CTRIA3 ", 0) == 0) {
if (boost::regex_match(line.c_str(), what, rx_t)) {
// insert the read-in triangle into a map to preserve the order
index = std::atol(what[1].first)-1;
mTria[index].iV[0] = std::atol(what[3].first)-1;
mTria[index].iV[1] = std::atol(what[4].first)-1;
mTria[index].iV[2] = std::atol(what[5].first)-1;
}
}
// insert the read-in quadrangle into a map to preserve the order
else if (line.find("CQUAD4") == 0) {
else if (line.rfind("CQUAD4", 0) == 0) {
if (boost::regex_match(line.c_str(), what, rx_q)) {
// insert the read-in quadrangle into a map to preserve the order
index = std::atol(what[1].first)-1;
mQuad[index].iV[0] = std::atol(what[3].first)-1;
mQuad[index].iV[1] = std::atol(what[4].first)-1;

View File

@@ -52,7 +52,7 @@ class TestPathDeburr(PathTestUtils.PathTestBase):
self.assertFalse(info)
def test01(self):
'''Verify chamfer depth and offset for a 90° v-bit.'''
'''Verify chamfer depth and offset for a 90 deg v-bit.'''
tool = Path.Tool()
tool.FlatRadius = 0
tool.CuttingEdgeAngle = 90
@@ -68,7 +68,7 @@ class TestPathDeburr(PathTestUtils.PathTestBase):
self.assertFalse(info)
def test02(self):
'''Verify chamfer depth and offset for a 90° v-bit with non 0 flat radius.'''
'''Verify chamfer depth and offset for a 90 deg v-bit with non 0 flat radius.'''
tool = Path.Tool()
tool.FlatRadius = 0.3
tool.CuttingEdgeAngle = 90
@@ -84,7 +84,7 @@ class TestPathDeburr(PathTestUtils.PathTestBase):
self.assertFalse(info)
def test03(self):
'''Verify chamfer depth and offset for a 60° v-bit with non 0 flat radius.'''
'''Verify chamfer depth and offset for a 60 deg v-bit with non 0 flat radius.'''
tool = Path.Tool()
tool.FlatRadius = 10
tool.CuttingEdgeAngle = 60

View File

@@ -541,20 +541,12 @@ void ConstraintView::updateActiveStatus()
void ConstraintView::showConstraints()
{
QList<QListWidgetItem *> items = selectedItems();
for (auto it : items) {
if (it->checkState() != Qt::Checked)
it->setCheckState(Qt::Checked);
}
Q_EMIT emitShowSelection3DVisibility();
}
void ConstraintView::hideConstraints()
{
QList<QListWidgetItem *> items = selectedItems();
for (auto it : items) {
if (it->checkState() != Qt::Unchecked)
it->setCheckState(Qt::Unchecked);
}
Q_EMIT emitHideSelection3DVisibility();
}
void ConstraintView::modifyCurrentItem()
@@ -679,6 +671,22 @@ TaskSketcherConstrains::TaskSketcherConstrains(ViewProviderSketch *sketchView) :
ui->extendedInformation, SIGNAL(stateChanged(int)),
this , SLOT (on_extendedInformation_stateChanged(int))
);
QObject::connect(
ui->showAllButton, SIGNAL(clicked(bool)),
this , SLOT (on_showAllButton_clicked(bool))
);
QObject::connect(
ui->hideAllButton, SIGNAL(clicked(bool)),
this , SLOT (on_hideAllButton_clicked(bool))
);
QObject::connect(
ui->listWidgetConstraints, SIGNAL(emitHideSelection3DVisibility()),
this , SLOT (on_listWidgetConstraints_emitHideSelection3DVisibility())
);
QObject::connect(
ui->listWidgetConstraints, SIGNAL(emitShowSelection3DVisibility()),
this , SLOT (on_listWidgetConstraints_emitShowSelection3DVisibility())
);
connectionConstraintsChanged = sketchView->signalConstraintsChanged.connect(
boost::bind(&SketcherGui::TaskSketcherConstrains::slotConstraintsChanged, this));
@@ -698,6 +706,85 @@ TaskSketcherConstrains::~TaskSketcherConstrains()
connectionConstraintsChanged.disconnect();
}
void TaskSketcherConstrains::changeFilteredVisibility(bool show, ActionTarget target)
{
assert(sketchView);
const Sketcher::SketchObject * sketch = sketchView->getSketchObject();
bool doCommit = false;
auto selecteditems = ui->listWidgetConstraints->selectedItems();
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Update constraint's virtual space"));
for(int i = 0; i < ui->listWidgetConstraints->count(); ++i)
{
QListWidgetItem* item = ui->listWidgetConstraints->item(i);
bool processItem = false;
if(target == ActionTarget::All) {
processItem = !item->isHidden();
}
else if(target == ActionTarget::Selected) {
if(std::find(selecteditems.begin(), selecteditems.end(), item) != selecteditems.end())
processItem = true;
}
if(processItem) { // The item is shown in the filtered list
const ConstraintItem *it = dynamic_cast<const ConstraintItem*>(item);
if (!it)
continue;
// must change state is shown and is to be hidden or hidden and must change state is shown
if((it->isInVirtualSpace() == sketchView->getIsShownVirtualSpace() && !show) ||
(it->isInVirtualSpace() != sketchView->getIsShownVirtualSpace() && show)) {
try {
Gui::cmdAppObjectArgs(sketch, "setVirtualSpace(%d, %s)",
it->ConstraintNbr,
show?"False":"True");
doCommit = true;
}
catch (const Base::Exception & e) {
Gui::Command::abortCommand();
QMessageBox::critical(Gui::MainWindow::getInstance(), tr("Error"),
QString::fromLatin1("Impossible to update visibility tracking"), QMessageBox::Ok, QMessageBox::Ok);
return;
}
}
}
}
if(doCommit)
Gui::Command::commitCommand();
}
void TaskSketcherConstrains::on_showAllButton_clicked(bool)
{
changeFilteredVisibility(true);
}
void TaskSketcherConstrains::on_hideAllButton_clicked(bool)
{
changeFilteredVisibility(false);
}
void TaskSketcherConstrains::on_listWidgetConstraints_emitHideSelection3DVisibility()
{
changeFilteredVisibility(false, ActionTarget::Selected);
}
void TaskSketcherConstrains::on_listWidgetConstraints_emitShowSelection3DVisibility()
{
changeFilteredVisibility(true, ActionTarget::Selected);
}
void TaskSketcherConstrains::onSelectionChanged(const Gui::SelectionChanges& msg)
{
std::string temp;
@@ -743,7 +830,13 @@ void TaskSketcherConstrains::onSelectionChanged(const Gui::SelectionChanges& msg
void TaskSketcherConstrains::on_comboBoxFilter_currentIndexChanged(int)
{
slotConstraintsChanged();
// enforce constraint visibility
bool visibilityTracksFilter = ui->visualisationTrackingFilter->isChecked();
if(visibilityTracksFilter)
change3DViewVisibilityToTrackFilter(); // it will call slotConstraintChanged via update mechanism
else
slotConstraintsChanged();
}
void TaskSketcherConstrains::on_filterInternalAlignment_stateChanged(int state)
@@ -872,6 +965,149 @@ void TaskSketcherConstrains::on_listWidgetConstraints_itemChanged(QListWidgetIte
inEditMode = false;
}
void TaskSketcherConstrains::change3DViewVisibilityToTrackFilter()
{
assert(sketchView);
// Build up ListView with the constraints
const Sketcher::SketchObject * sketch = sketchView->getSketchObject();
const std::vector< Sketcher::Constraint * > &vals = sketch->Constraints.getValues();
bool doCommit = false;
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Update constraint's virtual space"));
for(std::size_t i = 0; i < vals.size(); ++i) {
ConstraintItem * it = static_cast<ConstraintItem*>(ui->listWidgetConstraints->item(i));
bool visible = !isConstraintFiltered(it);
// If the constraint is filteredout and it was previously shown in 3D view
if( !visible && it->isInVirtualSpace() == sketchView->getIsShownVirtualSpace()) {
try {
Gui::cmdAppObjectArgs(sketch, "setVirtualSpace(%d, %s)",
it->ConstraintNbr,
"True");
doCommit = true;
}
catch (const Base::Exception & e) {
Gui::Command::abortCommand();
QMessageBox::critical(Gui::MainWindow::getInstance(), tr("Error"),
QString::fromLatin1("Impossible to update visibility tracking"), QMessageBox::Ok, QMessageBox::Ok);
return;
}
}
else if( visible && it->isInVirtualSpace() != sketchView->getIsShownVirtualSpace() ) {
try {
Gui::cmdAppObjectArgs(sketch, "setVirtualSpace(%d, %s)",
it->ConstraintNbr,
"False");
doCommit = true;
}
catch (const Base::Exception & e) {
Gui::Command::abortCommand();
QMessageBox::critical(Gui::MainWindow::getInstance(), tr("Error"),
QString::fromLatin1("Impossible to update visibility tracking"), QMessageBox::Ok, QMessageBox::Ok);
return;
}
}
}
if(doCommit)
Gui::Command::commitCommand();
}
bool TaskSketcherConstrains::isConstraintFiltered(QListWidgetItem * item)
{
assert(sketchView);
const Sketcher::SketchObject * sketch = sketchView->getSketchObject();
const std::vector< Sketcher::Constraint * > &vals = sketch->Constraints.getValues();
ConstraintItem * it = static_cast<ConstraintItem*>(item);
const Sketcher::Constraint * constraint = vals[it->ConstraintNbr];
int Filter = ui->comboBoxFilter->currentIndex();
bool hideInternalAlignment = this->ui->filterInternalAlignment->isChecked();
bool visible = true;
bool showAll = (Filter == FilterValue::All);
bool showGeometric = (Filter == FilterValue::Geometric);
bool showDatums = (Filter == FilterValue::Datums);
bool showNamed = (Filter == FilterValue::Named && !(constraint->Name.empty()));
bool showNonDriving = (Filter == FilterValue::NonDriving && !constraint->isDriving);
switch(constraint->Type) {
case Sketcher::Horizontal:
visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Horizontal);
break;
case Sketcher::Vertical:
visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Vertical);
break;
case Sketcher::Coincident:
visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Coincident);
break;
case Sketcher::PointOnObject:
visible = showAll || showGeometric || showNamed || (Filter == FilterValue::PointOnObject);
break;
case Sketcher::Parallel:
visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Parallel);
break;
case Sketcher::Perpendicular:
visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Perpendicular);
break;
case Sketcher::Tangent:
visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Tangent);
break;
case Sketcher::Equal:
visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Equality);
break;
case Sketcher::Symmetric:
visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Symmetric);
break;
case Sketcher::Block:
visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Block);
break;
case Sketcher::Distance:
visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::Distance);
break;
case Sketcher::DistanceX:
visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::HorizontalDistance);
break;
case Sketcher::DistanceY:
visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::VerticalDistance);
break;
case Sketcher::Radius:
visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::Radius);
break;
case Sketcher::Weight:
visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::Weight);
break;
case Sketcher::Diameter:
visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::Diameter);
break;
case Sketcher::Angle:
visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::Angle);
break;
case Sketcher::SnellsLaw:
visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::SnellsLaw);
break;
case Sketcher::InternalAlignment:
visible = (( showAll || showGeometric || showNamed || Filter == FilterValue::InternalAlignment) &&
(!hideInternalAlignment || (Filter == FilterValue::InternalAlignment)));
default:
break;
}
return !visible;
}
void TaskSketcherConstrains::slotConstraintsChanged(void)
{
assert(sketchView);
@@ -906,54 +1142,11 @@ void TaskSketcherConstrains::slotConstraintsChanged(void)
ui->listWidgetConstraints->blockSignals(false);
/* Update filtering */
int Filter = ui->comboBoxFilter->currentIndex();
for(std::size_t i = 0; i < vals.size(); ++i) {
const Sketcher::Constraint * constraint = vals[i];
ConstraintItem * it = static_cast<ConstraintItem*>(ui->listWidgetConstraints->item(i));
bool visible = true;
/* Filter
0 <=> All
1 <=> Normal
2 <=> Datums
3 <=> Named
4 <=> Non-Driving
*/
bool showNormal = (Filter < 2);
bool showDatums = (Filter < 3);
bool showNamed = (Filter == 3 && !(constraint->Name.empty()));
bool showNonDriving = (Filter == 4 && !constraint->isDriving);
bool hideInternalAlignment = this->ui->filterInternalAlignment->isChecked();
switch(constraint->Type) {
case Sketcher::Horizontal:
case Sketcher::Vertical:
case Sketcher::Coincident:
case Sketcher::PointOnObject:
case Sketcher::Parallel:
case Sketcher::Perpendicular:
case Sketcher::Tangent:
case Sketcher::Equal:
case Sketcher::Symmetric:
case Sketcher::Block:
visible = showNormal || showNamed;
break;
case Sketcher::Distance:
case Sketcher::DistanceX:
case Sketcher::DistanceY:
case Sketcher::Radius:
case Sketcher::Weight:
case Sketcher::Diameter:
case Sketcher::Angle:
case Sketcher::SnellsLaw:
visible = (showDatums || showNamed || showNonDriving);
break;
case Sketcher::InternalAlignment:
visible = ((showNormal || showNamed) && !hideInternalAlignment);
default:
break;
}
bool visible = !isConstraintFiltered(it);
// block signals as there is no need to invoke the
// on_listWidgetConstraints_itemChanged() slot in
@@ -964,6 +1157,7 @@ void TaskSketcherConstrains::slotConstraintsChanged(void)
it->setHidden(!visible);
it->setData(Qt::EditRole, Base::Tools::fromStdString(constraint->Name));
model->blockSignals(block);
}
}

View File

@@ -53,6 +53,8 @@ Q_SIGNALS:
void onUpdateDrivingStatus(QListWidgetItem *item, bool status);
void onUpdateActiveStatus(QListWidgetItem *item, bool status);
void emitCenterSelectedItems();
void emitHideSelection3DVisibility();
void emitShowSelection3DVisibility();
protected Q_SLOTS:
void modifyCurrentItem();
@@ -71,6 +73,38 @@ class TaskSketcherConstrains : public Gui::TaskView::TaskBox, public Gui::Select
{
Q_OBJECT
enum FilterValue {
All = 0,
Geometric = 1,
Datums = 2,
Named = 3,
NonDriving = 4,
Horizontal = 5,
Vertical = 6,
Coincident = 7,
PointOnObject = 8,
Parallel = 9,
Perpendicular = 10,
Tangent = 11,
Equality = 12,
Symmetric = 13,
Block = 14,
Distance = 15,
HorizontalDistance = 16,
VerticalDistance = 17,
Radius = 18,
Weight = 19,
Diameter = 20,
Angle = 21,
SnellsLaw = 22,
InternalAlignment = 23
};
enum class ActionTarget {
All,
Selected
};
public:
TaskSketcherConstrains(ViewProviderSketch *sketchView);
~TaskSketcherConstrains();
@@ -80,6 +114,9 @@ public:
private:
void slotConstraintsChanged(void);
bool isConstraintFiltered(QListWidgetItem * item);
void change3DViewVisibilityToTrackFilter();
void changeFilteredVisibility(bool show, ActionTarget target = ActionTarget::All);
public Q_SLOTS:
void on_comboBoxFilter_currentIndexChanged(int);
@@ -91,6 +128,10 @@ public Q_SLOTS:
void on_listWidgetConstraints_emitCenterSelectedItems(void);
void on_filterInternalAlignment_stateChanged(int state);
void on_extendedInformation_stateChanged(int state);
void on_showAllButton_clicked(bool);
void on_hideAllButton_clicked(bool);
void on_listWidgetConstraints_emitShowSelection3DVisibility();
void on_listWidgetConstraints_emitHideSelection3DVisibility();
protected:
void changeEvent(QEvent *e);

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>212</width>
<height>288</height>
<width>299</width>
<height>388</height>
</rect>
</property>
<property name="sizePolicy">
@@ -19,7 +19,7 @@
<property name="maximumSize">
<size>
<width>16777215</width>
<height>288</height>
<height>388</height>
</size>
</property>
<property name="windowTitle">
@@ -47,7 +47,7 @@
</item>
<item>
<property name="text">
<string>Normal</string>
<string>Geometric</string>
</property>
</item>
<item>
@@ -65,46 +65,301 @@
<string>Reference</string>
</property>
</item>
<item>
<property name="text">
<string>Horizontal</string>
</property>
</item>
<item>
<property name="text">
<string>Vertical</string>
</property>
</item>
<item>
<property name="text">
<string>Coincident</string>
</property>
</item>
<item>
<property name="text">
<string>Point on Object</string>
</property>
</item>
<item>
<property name="text">
<string>Parallel</string>
</property>
</item>
<item>
<property name="text">
<string>Perpendicular</string>
</property>
</item>
<item>
<property name="text">
<string>Tangent</string>
</property>
</item>
<item>
<property name="text">
<string>Equality</string>
</property>
</item>
<item>
<property name="text">
<string>Symmetric</string>
</property>
</item>
<item>
<property name="text">
<string>Block</string>
</property>
</item>
<item>
<property name="text">
<string>Distance</string>
</property>
</item>
<item>
<property name="text">
<string>Horizontal Distance</string>
</property>
</item>
<item>
<property name="text">
<string>Vertical Distance</string>
</property>
</item>
<item>
<property name="text">
<string>Radius</string>
</property>
</item>
<item>
<property name="text">
<string>Weight</string>
</property>
</item>
<item>
<property name="text">
<string>Diameter</string>
</property>
</item>
<item>
<property name="text">
<string>Angle</string>
</property>
</item>
<item>
<property name="text">
<string>Snell's Law</string>
</property>
</item>
<item>
<property name="text">
<string>Internal Alignment</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="filterInternalAlignment">
<widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>95</height>
</size>
</property>
<property name="toolTip">
<string>Internal alignments will be hidden</string>
<string/>
</property>
<property name="text">
<string>Hide internal alignment</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>HideInternalAlignment</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="extendedInformation">
<property name="toolTip">
<string>Extended information will be added to the list</string>
</property>
<property name="text">
<string>Extended information</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>ExtendedConstraintInformation</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher</cstring>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="visualisationTab">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<attribute name="title">
<string>View</string>
</attribute>
<widget class="QPushButton" name="showAllButton">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>125</width>
<height>27</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Shows all the constraints in the list</string>
</property>
<property name="text">
<string>Show All</string>
</property>
</widget>
<widget class="QPushButton" name="hideAllButton">
<property name="geometry">
<rect>
<x>140</x>
<y>10</y>
<width>125</width>
<height>27</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Hides all the constraints in the list</string>
</property>
<property name="text">
<string>Hide All</string>
</property>
</widget>
</widget>
<widget class="QWidget" name="automationTab">
<property name="toolTip">
<string>Controls visualisation in the 3D view</string>
</property>
<attribute name="title">
<string>Automation</string>
</attribute>
<widget class="Gui::PrefCheckBox" name="visualisationTrackingFilter">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>189</width>
<height>36</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Constraint visualisation tracks filter selection so that filtered out constraints are hidden</string>
</property>
<property name="text">
<string>Track filter selection</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>VisualisationTrackingFilter</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher</cstring>
</property>
</widget>
</widget>
<widget class="QWidget" name="controlTab">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Controls widget list behaviour</string>
</property>
<attribute name="title">
<string>List</string>
</attribute>
<widget class="Gui::PrefCheckBox" name="extendedInformation">
<property name="geometry">
<rect>
<x>0</x>
<y>30</y>
<width>189</width>
<height>36</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Extended information will be added to the list</string>
</property>
<property name="text">
<string>Extended information</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>ExtendedConstraintInformation</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher</cstring>
</property>
</widget>
<widget class="Gui::PrefCheckBox" name="filterInternalAlignment">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>189</width>
<height>36</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Internal alignments will be hidden</string>
</property>
<property name="text">
<string>Hide internal alignment</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>HideInternalAlignment</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher</cstring>
</property>
</widget>
</widget>
</widget>
</item>
<item>

View File

@@ -3455,6 +3455,7 @@ void ViewProviderSketch::drawConstraintIcons()
thisIcon.position = absPos;
thisIcon.destination = coinIconPtr;
thisIcon.infoPtr = infoPtr;
thisIcon.visible = (*it)->isInVirtualSpace == getIsShownVirtualSpace();
if ((*it)->Type==Symmetric) {
Base::Vector3d startingpoint = getSketchObject()->getPoint((*it)->First,(*it)->FirstPos);
@@ -3539,36 +3540,44 @@ void ViewProviderSketch::combineConstraintIcons(IconQueue iconQueue)
iconQueue.pop_back();
// we group only icons not being Symmetry icons, because we want those on the line
if(init.type != QString::fromLatin1("Constraint_Symmetric")){
// and only icons that are visible
if(init.type != QString::fromLatin1("Constraint_Symmetric") && init.visible){
IconQueue::iterator i = iconQueue.begin();
while(i != iconQueue.end()) {
bool addedToGroup = false;
if((*i).visible) {
bool addedToGroup = false;
for(IconQueue::iterator j = thisGroup.begin();
j != thisGroup.end(); ++j) {
float distSquared = pow(i->position[0]-j->position[0],2) + pow(i->position[1]-j->position[1],2);
if(distSquared <= maxDistSquared && (*i).type != QString::fromLatin1("Constraint_Symmetric")) {
// Found an icon in iconQueue that's close enough to
// a member of thisGroup, so move it into thisGroup
thisGroup.push_back(*i);
i = iconQueue.erase(i);
addedToGroup = true;
break;
for(IconQueue::iterator j = thisGroup.begin();
j != thisGroup.end(); ++j) {
float distSquared = pow(i->position[0]-j->position[0],2) + pow(i->position[1]-j->position[1],2);
if(distSquared <= maxDistSquared && (*i).type != QString::fromLatin1("Constraint_Symmetric")) {
// Found an icon in iconQueue that's close enough to
// a member of thisGroup, so move it into thisGroup
thisGroup.push_back(*i);
i = iconQueue.erase(i);
addedToGroup = true;
break;
}
}
}
if(addedToGroup) {
if(i == iconQueue.end())
// We just got the last icon out of iconQueue
break;
else
// Start looking through the iconQueue again, in case
// we have an icon that's now close enough to thisGroup
i = iconQueue.begin();
} else
++i;
if(addedToGroup) {
if(i == iconQueue.end())
// We just got the last icon out of iconQueue
break;
else
// Start looking through the iconQueue again, in case
// we have an icon that's now close enough to thisGroup
i = iconQueue.begin();
} else
++i;
}
else // if !visible we skip it
i++;
}
}
if(thisGroup.size() == 1) {

View File

@@ -370,6 +370,8 @@ protected:
/// Angle to rotate an icon
double iconRotation;
bool visible;
};
/// Internal type used for drawing constraint icons

View File

@@ -45,7 +45,7 @@
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/ViewProvider.h>
#include <Gui/WidgetFactory.h> //for PythonWrappers
#include <Gui/PythonWrapper.h>
#include <Mod/Part/App/OCCError.h>
#include <Mod/TechDraw/App/DrawPage.h>

View File

@@ -125,9 +125,10 @@ class UnitBasicCases(unittest.TestCase):
try:
q2 = FreeCAD.Units.Quantity(t[0])
if math.fabs(q1.Value - q2.Value) > 0.01:
print (q1, " : ", q2, " : ", t, " : ", i, " : ", val)
print (" {} : {} : {} : {} : {}".format(q1, q2, t, i, val).encode("utf-8").strip())
except Exception as e:
print ("{}: {}".format(str(e), t[0]))
s = "{}: {}".format(e, t[0])
print (" ".join(e).encode("utf-8").strip())
def testVoltage(self):
q1 = FreeCAD.Units.Quantity("1e20 V")

View File

@@ -27,6 +27,7 @@
# include <QMdiArea>
# include <QMdiSubWindow>
# include <QUrl>
# include <QIcon>
#endif
#include <Base/Console.h>
@@ -63,7 +64,7 @@ public:
add_varargs_method("openBrowserWindow",&Module::openBrowserWindow
);
add_varargs_method("open",&Module::openBrowser,
"open(string)\n"
"open(htmlcode,baseurl,[title,iconpath])\n"
"Load a local (X)HTML file."
);
add_varargs_method("insert",&Module::openBrowser,
@@ -99,8 +100,9 @@ private:
{
const char* HtmlCode;
const char* BaseUrl;
const char* IconPath;
char* TabName = nullptr;
if (! PyArg_ParseTuple(args.ptr(), "ss|et", &HtmlCode, &BaseUrl, "utf-8", &TabName))
if (! PyArg_ParseTuple(args.ptr(), "ss|ets", &HtmlCode, &BaseUrl, "utf-8", &TabName, &IconPath))
throw Py::Exception();
std::string EncodedName = "Browser";
@@ -114,6 +116,8 @@ private:
pcBrowserView->resize(400, 300);
pcBrowserView->setHtml(QString::fromUtf8(HtmlCode),QUrl(QString::fromLatin1(BaseUrl)));
pcBrowserView->setWindowTitle(QString::fromUtf8(EncodedName.c_str()));
if (IconPath)
pcBrowserView->setWindowIcon(QIcon(QString::fromUtf8(IconPath)));
Gui::getMainWindow()->addWindow(pcBrowserView);
if (!Gui::getMainWindow()->activeWindow())
Gui::getMainWindow()->setActiveWindow(pcBrowserView);

View File

@@ -97,7 +97,11 @@ public:
bool onMsg(const char* pMsg,const char** ppReturn);
bool onHasMsg(const char* pMsg) const;
bool canClose(void);
bool canClose (void);
#ifdef QTWEBENGINE
void setWindowIcon(const QIcon &icon);
#endif
protected Q_SLOTS:
void onLoadStarted();
@@ -107,7 +111,6 @@ protected Q_SLOTS:
void urlFilter(const QUrl &url);
#ifdef QTWEBENGINE
void onDownloadRequested(QWebEngineDownloadItem *request);
void setWindowIcon(const QIcon &icon);
void onLinkHovered(const QString& url);
#else
void onDownloadRequested(const QNetworkRequest& request);