Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'master' into feature/tool-bit-poc
Browse files Browse the repository at this point in the history
  • Loading branch information
mlampert committed Dec 7, 2019
2 parents 7922f6f + 004d606 commit dc74189
Show file tree
Hide file tree
Showing 20 changed files with 589 additions and 561 deletions.
30 changes: 21 additions & 9 deletions src/Gui/DlgUnitsCalculator.ui
Expand Up @@ -24,6 +24,9 @@
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Input the source value and unit</string>
</property>
</widget>
</item>
<item>
Expand All @@ -34,13 +37,19 @@
</widget>
</item>
<item>
<widget class="Gui::InputField" name="UnitInput">
<widget class="QLineEdit" name="UnitInput">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Input here the unit for the result</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
Expand All @@ -58,6 +67,9 @@
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Result</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
Expand All @@ -67,6 +79,10 @@
</item>
<item row="1" column="0">
<widget class="QTextEdit" name="textEdit">
<property name="toolTip">
<string>List of last used calculations
To add a calculation press Return in the value input field</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
Expand All @@ -82,7 +98,7 @@
</widget>
</item>
<item>
<widget class="Gui::QuantitySpinBox" name="quantitySpinBox">
<widget class="Gui::QuantitySpinBox" name="quantitySpinBox" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -112,13 +128,6 @@
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton_Help">
<property name="text">
<string>Help</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
Expand All @@ -134,6 +143,9 @@
</item>
<item>
<widget class="QPushButton" name="pushButton_Copy">
<property name="toolTip">
<string>Copy the result into the clipboard</string>
</property>
<property name="text">
<string>Copy</string>
</property>
Expand Down
53 changes: 30 additions & 23 deletions src/Gui/DlgUnitsCalculatorImp.cpp
Expand Up @@ -51,19 +51,20 @@ DlgUnitsCalculator::DlgUnitsCalculator( QWidget* parent, Qt::WindowFlags fl )
this->setAttribute(Qt::WA_DeleteOnClose);

connect(ui->ValueInput, SIGNAL(valueChanged(Base::Quantity)), this, SLOT(valueChanged(Base::Quantity)));
connect(ui->ValueInput, SIGNAL(returnPressed () ), this, SLOT(returnPressed()));
connect(ui->UnitInput, SIGNAL(valueChanged(Base::Quantity)), this, SLOT(unitValueChanged(Base::Quantity)));
connect(ui->ValueInput, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
connect(ui->UnitInput, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
connect(ui->UnitInput, SIGNAL(returnPressed()), this, SLOT(returnPressed()));

connect(ui->pushButton_Help, SIGNAL(clicked()), this, SLOT(help()));
connect(ui->pushButton_Close, SIGNAL(clicked()), this, SLOT(accept()));
connect(ui->pushButton_Copy, SIGNAL(clicked()), this, SLOT(copy()));

connect(ui->ValueInput, SIGNAL(parseError(QString)), this, SLOT(parseError(QString)));
connect(ui->UnitInput, SIGNAL(parseError(QString)), this, SLOT(parseError(QString)));

ui->ValueInput->setParamGrpPath(QByteArray("User parameter:BaseApp/History/UnitsCalculator"));
actUnit.setInvalid();
// set a default that also illustrates how the dialog works
ui->ValueInput->setText(QString::fromLatin1("1 cm"));
ui->UnitInput->setText(QString::fromLatin1("in"));

units << Base::Unit::Length << Base::Unit::Mass << Base::Unit::Angle << Base::Unit::Density
<< Base::Unit::Area << Base::Unit::Volume << Base::Unit::TimeSpan << Base::Unit::Frequency
Expand All @@ -72,7 +73,7 @@ DlgUnitsCalculator::DlgUnitsCalculator( QWidget* parent, Qt::WindowFlags fl )
<< Base::Unit::AmountOfSubstance << Base::Unit::LuminousIntensity << Base::Unit::Stress
<< Base::Unit::Pressure << Base::Unit::Force << Base::Unit::Work << Base::Unit::Power
<< Base::Unit::ThermalConductivity << Base::Unit::ThermalExpansionCoefficient
<< Base::Unit::SpecificHeat << Base::Unit::ThermalTransferCoefficient <<Base::Unit::HeatFlux;
<< Base::Unit::SpecificHeat << Base::Unit::ThermalTransferCoefficient << Base::Unit::HeatFlux;
for (QList<Base::Unit>::iterator it = units.begin(); it != units.end(); ++it) {
ui->unitsBox->addItem(it->getTypeString());
}
Expand All @@ -95,31 +96,42 @@ void DlgUnitsCalculator::reject()
QDialog::reject();
}

void DlgUnitsCalculator::unitValueChanged(const Base::Quantity& unit)
void DlgUnitsCalculator::textChanged(QString unit)
{
actUnit = unit;
valueChanged(actValue);
}

void DlgUnitsCalculator::valueChanged(const Base::Quantity& quant)
{
if (actUnit.isValid()) {
if (actUnit.getUnit() != quant.getUnit()) {
ui->ValueOutput->setText(tr("Unit mismatch"));
// first check the unit, if it is invalid, getTypeString() outputs an empty string
if (Base::Unit(ui->UnitInput->text()).getTypeString().isEmpty()) {
ui->ValueOutput->setText(tr("unknown unit: ") + ui->UnitInput->text());
ui->pushButton_Copy->setEnabled(false);
} else { // the unit is valid
// we can only convert units of the same type, thus check
if (Base::Unit(ui->UnitInput->text()).getTypeString() != quant.getUnit().getTypeString()) {
ui->ValueOutput->setText(tr("unit mismatch"));
ui->pushButton_Copy->setEnabled(false);
} else {
double value = quant.getValue()/actUnit.getValue();
QString val = QLocale::system().toString(value, 'f', Base::UnitsApi::getDecimals());
} else { // the unit is valid and has the same type
double convertValue = Base::Quantity::parse(QString::fromLatin1("1") + ui->UnitInput->text()).getValue();
// we got now e.g. for "1 in" the value '25.4' because 1 in = 25.4 mm
// the result is now just quant / convertValue because the input is always in a base unit
// (an input of "1 cm" will immediately be converted to "10 mm" by Gui::InputField of the dialog)
double value = quant.getValue() / convertValue;
// determine how many decimals we will need to avoid an output like "0.00"
// at first use scientific notation, if there is no "e", we can round it to the user-defined decimals,
// but the user-defined decimals might be too low for cases like "10 um" in "in",
// thus only if value > 0.005 because FC's default are 2 decimals
QString val = QLocale::system().toString(value, 'g');
if (!val.contains(QChar::fromLatin1('e')) && (value > 0.005))
val = QLocale::system().toString(value, 'f', Base::UnitsApi::getDecimals());
// create the output string
QString out = QString::fromLatin1("%1 %2").arg(val, ui->UnitInput->text());
ui->ValueOutput->setText(out);
ui->pushButton_Copy->setEnabled(true);
}
} else {
//ui->ValueOutput->setValue(quant);
ui->ValueOutput->setText(quant.getUserString());
ui->pushButton_Copy->setEnabled(true);
}

// store the input value
actValue = quant;
}

Expand All @@ -135,11 +147,6 @@ void DlgUnitsCalculator::copy(void)
cb->setText(ui->ValueOutput->text());
}

void DlgUnitsCalculator::help(void)
{
//TODO: call help page Std_UnitsCalculator
}

void DlgUnitsCalculator::returnPressed(void)
{
if (ui->pushButton_Copy->isEnabled()) {
Expand Down
4 changes: 1 addition & 3 deletions src/Gui/DlgUnitsCalculatorImp.h
Expand Up @@ -50,19 +50,17 @@ class DlgUnitsCalculator : public QDialog
void reject();

protected Q_SLOTS:
void unitValueChanged(const Base::Quantity&);
void textChanged(const QString);
void valueChanged(const Base::Quantity&);
void on_unitsBox_activated(int);

void copy(void);
void help(void);
void returnPressed(void);

void parseError(const QString& errorText);

private:
Base::Quantity actValue;
Base::Quantity actUnit;
std::unique_ptr<Ui_DlgUnitCalculator> ui;
QList<Base::Unit> units;
};
Expand Down
Empty file modified src/Gui/Icons/edit-select-all.svg 100755 → 100644
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/Gui/Icons/edit-select-box.svg 100755 → 100644
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 11 additions & 7 deletions src/Gui/MainWindow.cpp
Expand Up @@ -1591,11 +1591,13 @@ QMimeData * MainWindow::createMimeDataFromSelection () const
// if less than ~10 MB
bool use_buffer=(memsize < 0xA00000);
QByteArray res;
try {
res.reserve(memsize);
}
catch (const Base::MemoryException&) {
use_buffer = false;
if(use_buffer) {
try {
res.reserve(memsize);
}
catch (const std::bad_alloc &) {
use_buffer = false;
}
}

WaitCursor wc;
Expand Down Expand Up @@ -1651,9 +1653,11 @@ void MainWindow::insertFromMimeData (const QMimeData * mimeData)
else if(mimeData->hasFormat(_MimeDocObjX)) {
format = _MimeDocObjX;
hasXLink = true;
}else if(mimeData->hasFormat(_MimeDocObjFile))
}else if(mimeData->hasFormat(_MimeDocObjFile)) {
format = _MimeDocObjFile;
fromDoc = true;
else if(mimeData->hasFormat(_MimeDocObjXFile)) {
}else if(mimeData->hasFormat(_MimeDocObjXFile)) {
format = _MimeDocObjXFile;
fromDoc = true;
hasXLink = true;
}else {
Expand Down
6 changes: 6 additions & 0 deletions src/Mod/Draft/Draft.py
Expand Up @@ -5717,6 +5717,12 @@ def linkSetup(self,obj):
obj.setPropertyStatus('PlacementList','Immutable')
else:
obj.setPropertyStatus('PlacementList','-Immutable')
if not hasattr(obj,'LinkTransform'):
obj.addProperty('App::PropertyBool','LinkTransform',' Link')
if not hasattr(obj,'ColoredElements'):
obj.addProperty('App::PropertyLinkSubHidden','ColoredElements',' Link')
obj.setPropertyStatus('ColoredElements','Hidden')
obj.configLinkProperty('LinkTransform','ColoredElements')

def getViewProviderName(self,_obj):
if self.useLink:
Expand Down
4 changes: 3 additions & 1 deletion src/Mod/Draft/Resources/ui/preferences-dxf.ui
Expand Up @@ -60,7 +60,9 @@ Note: C++ importer is faster, but is not as featureful yet</string>
<widget class="Gui::PrefCheckBox" name="checkBox_7">
<property name="toolTip">
<string>Python exporter is used, otherwise the newer C++ is used.
Note: C++ importer is faster, but is not as featureful yet</string>
Note: C++ importer is faster, but is not as featureful yet
</string>
</property>
<property name="text">
<string>Use legacy python exporter</string>
</property>
Expand Down
17 changes: 8 additions & 9 deletions src/Mod/Draft/importSVG.py
Expand Up @@ -714,18 +714,17 @@ def startElement(self, name, attrs):
if self.count == 1 and name == 'svg':
if 'inkscape:version' in data:
inks_doc_name = attrs.getValue('sodipodi:docname')
inks_full_ver = attrs.getValue('inkscape:version')[:4]
inks_full_ver_list = inks_full_ver.split('.')
_maj = int(inks_full_ver_list[0])
_min = int(inks_full_ver_list[1])

inks_full_ver = attrs.getValue('inkscape:version')
inks_ver_pars = re.search("\d+\.\d+", inks_full_ver)
if inks_ver_pars != None:
inks_ver_f = float(inks_ver_pars.group(0))
else:
inks_ver_f = 99.99
# Inkscape before 0.92 used 90 dpi as resolution
# Newer versions use 96 dpi
if _maj == 0 and _min > 91:
self.svgdpi = 96.0
elif _maj == 0 and _min < 92:
if inks_ver_f < 0.92:
self.svgdpi = 90.0
elif _maj > 0:
else:
self.svgdpi = 96.0
if 'inkscape:version' not in data:
_msg = ("This SVG file does not appear to have been produced "
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/PartDesign/Gui/CommandBody.cpp
Expand Up @@ -94,7 +94,7 @@ CmdPartDesignBody::CmdPartDesignBody()
sToolTipText = QT_TR_NOOP("Create a new body and make it active");
sWhatsThis = "PartDesign_Body";
sStatusTip = sToolTipText;
sPixmap = "PartDesign_Body_Create_New";
sPixmap = "PartDesign_Body";
}

void CmdPartDesignBody::activated(int iMsg)
Expand Down

0 comments on commit dc74189

Please sign in to comment.