Skip to content

Commit

Permalink
Merge branch 'main' into annotation_dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan authored Dec 6, 2023
2 parents a792b9a + 008fc32 commit f128ad2
Show file tree
Hide file tree
Showing 94 changed files with 2,304 additions and 1,778 deletions.
2 changes: 1 addition & 1 deletion cMake/FreeCAD_Helpers/ConfigureCMakeVariables.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ macro(ConfigureCMakeVariables)
# ================================================================================
# Output directories for install target

if(WIN32)
if(MSVC)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "Installation root directory")
set(CMAKE_INSTALL_BINDIR bin CACHE PATH "Output directory for executables")
set(CMAKE_INSTALL_DATADIR data CACHE PATH "Output directory for data and resource files")
Expand Down
2 changes: 1 addition & 1 deletion cMake/FreeCAD_Helpers/SetupSalomeSMESH.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ macro(SetupSalomeSMESH)
if(NOT FREECAD_USE_EXTERNAL_SMESH)
find_package(MEDFile REQUIRED)
# See https://www.hdfgroup.org/HDF5/release/cmakebuild.html
if (WIN32)
if (MSVC)
find_package(HDF5 COMPONENTS NO_MODULE REQUIRED static)
else()
find_package(PkgConfig)
Expand Down
3 changes: 1 addition & 2 deletions conda/environment.devenv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,13 @@ dependencies:
- coin3d==4.0.0
- compilers
- conda
- conda-build
- conda-devenv
- conda-smithy
- debugpy
- doxygen
- eigen
- fmt
- freetype
- git
- gmsh
- graphviz
- hdf5
Expand Down
4 changes: 2 additions & 2 deletions contrib/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"tasks": [
{
"type": "shell",
"type": "process",
"label": "FreeCAD: setup conda environment",
"linux": {
"command": "conda/setup-environment.sh",
Expand Down Expand Up @@ -68,4 +68,4 @@
}
],
"version": "2.0.0"
}
}
13 changes: 13 additions & 0 deletions src/App/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ recompute path. Also, it enables more complicated dependencies beyond trees.
#include <Base/Uuid.h>
#include <Base/Sequencer.h>
#include <Base/Stream.h>
#include <Base/UnitsApi.h>

#include "Document.h"
#include "private/DocumentP.h"
Expand Down Expand Up @@ -821,6 +822,18 @@ Document::Document(const char* documentName)
0,
Prop_None,
"Additional tag to save the name of the company");
ADD_PROPERTY_TYPE(UnitSystem, (""), 0, Prop_None, "Unit system to use in this project");
// Set up the possible enum values for the unit system
int num = static_cast<int>(Base::UnitSystem::NumUnitSystemTypes);
std::vector<std::string> enumValsAsVector;
for (int i = 0; i < num; i++) {
QString item = Base::UnitsApi::getDescription(static_cast<Base::UnitSystem>(i));
enumValsAsVector.emplace_back(item.toStdString());
}
UnitSystem.setEnums(enumValsAsVector);
// Get the preferences/General unit system as the default for a new document
ParameterGrp::handle hGrpu = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Units");
UnitSystem.setValue(hGrpu->GetInt("UserSchema", 0));
ADD_PROPERTY_TYPE(Comment, (""), 0, Prop_None, "Additional tag to save a comment");
ADD_PROPERTY_TYPE(Meta, (), 0, Prop_None, "Map with additional meta information");
ADD_PROPERTY_TYPE(Material, (), 0, Prop_None, "Map with material properties");
Expand Down
2 changes: 2 additions & 0 deletions src/App/Document.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ class AppExport Document : public App::PropertyContainer
PropertyString LastModifiedDate;
/// company name UTF8(optional)
PropertyString Company;
/// Unit System
PropertyEnumeration UnitSystem;
/// long comment or description (UTF8 with line breaks)
PropertyString Comment;
/// Id e.g. Part number
Expand Down
2 changes: 1 addition & 1 deletion src/App/PropertyExpressionEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class AppExport PropertyExpressionEngine : public App::PropertyExpressionContain
using DiGraph = boost::adjacency_list< boost::listS, boost::vecS, boost::directedS >;
using Edge = std::pair<int, int>;
// Note: use std::map instead of unordered_map to keep the binding order stable
#if defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
#if defined(FC_OS_MACOSX) || defined(FC_OS_BSD) || defined(_LIBCPP_VERSION)
using ExpressionMap = std::map<App::ObjectIdentifier, ExpressionInfo>;
#else
using ExpressionMap = std::map<const App::ObjectIdentifier, ExpressionInfo>;
Expand Down
5 changes: 1 addition & 4 deletions src/Base/Builder3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,9 @@

// Std. configurations

#ifdef __GNUC__
#include <cstdint>
#endif

#include <sstream>
#include <vector>
#include <cstdint>
#include <Base/Tools3D.h>
#ifndef FC_GLOBAL_H
#include <FCGlobal.h>
Expand Down
18 changes: 9 additions & 9 deletions src/Gui/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,19 +933,19 @@ void Application::slotActiveDocument(const App::Document& Doc)
Py::Module("FreeCADGui").setAttr(std::string("ActiveDocument"),Py::None());
}
}

//Set Unit System.
int projectUnitSystemIndex = doc->second->getProjectUnitSystem();
int ignore = doc->second->getProjectUnitSystemIgnore();
if( projectUnitSystemIndex >= 0 && !ignore ){//is valid
Base::UnitsApi::setSchema(static_cast<Base::UnitSystem>(projectUnitSystemIndex));

// Update the application to show the unit change
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Units");
if( Doc.FileName.getValue()[0] != '\0' && ! hGrp->GetBool("IgnoreProjectSchema")) {
int userSchema = Doc.UnitSystem.getValue();
Base::UnitsApi::setSchema(static_cast<Base::UnitSystem>(userSchema));
getMainWindow()->setUserSchema(userSchema);
Application::Instance->onUpdate();
}else{// set up Unit system default
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Units");
Base::UnitsApi::setSchema((Base::UnitSystem)hGrp->GetInt("UserSchema",0));
Base::UnitsApi::setDecimals(hGrp->GetInt("Decimals", Base::UnitsApi::getDecimals()));
}

signalActiveDocument(*doc->second);
updateActions();
}
Expand Down
11 changes: 4 additions & 7 deletions src/Gui/DemoMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void DemoMode::onAngleSliderValueChanged(int v)
SbRotation rot(SbVec3f(-1, 0, 0), angle);
reorientCamera(cam ,rot);
this->oldvalue = v;
if (view->getViewer()->isAnimating()) {
if (view->getViewer()->isSpinning()) {
startAnimation(view);
}
}
Expand All @@ -206,7 +206,7 @@ void DemoMode::onSpeedSliderValueChanged(int v)
{
Q_UNUSED(v);
Gui::View3DInventor* view = activeView();
if (view && view->getViewer()->isAnimating()) {
if (view && view->getViewer()->isSpinning()) {
startAnimation(view);
}
}
Expand All @@ -216,7 +216,7 @@ void DemoMode::onPlayButtonToggled(bool pressed)
Gui::View3DInventor* view = activeView();
if (view) {
if (pressed) {
if (!view->getViewer()->isAnimating()) {
if (!view->getViewer()->isSpinning()) {
SoCamera* cam = view->getViewer()->getSoRenderManager()->getCamera();
if (cam) {
SbRotation rot = cam->orientation.getValue();
Expand Down Expand Up @@ -263,17 +263,14 @@ void DemoMode::onTimeoutValueChanged(int v)
void DemoMode::onAutoPlay()
{
Gui::View3DInventor* view = activeView();
if (view && !view->getViewer()->isAnimating()) {
if (view && !view->getViewer()->isSpinning()) {
ui->playButton->setChecked(true);
startAnimation(view);
}
}

void DemoMode::startAnimation(Gui::View3DInventor* view)
{
if (!view->getViewer()->isAnimationEnabled())
view->getViewer()->setAnimationEnabled(true);

view->getViewer()->startSpinningAnimation(getDirection(view),
getSpeed(ui->speedSlider->value()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/DlgPreferences.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<property name="minimumSize">
<size>
<width>1000</width>
<height>600</height>
<height>500</height>
</size>
</property>
<property name="windowTitle">
Expand Down
17 changes: 17 additions & 0 deletions src/Gui/DlgPreferencesImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
# include <QToolTip>
# include <QProcess>
# include <QPushButton>
# include <QWindow>
#endif

#include <App/Application.h>
Expand Down Expand Up @@ -690,6 +691,22 @@ void DlgPreferencesImp::restartIfRequired()
void DlgPreferencesImp::showEvent(QShowEvent* ev)
{
QDialog::showEvent(ev);

auto screen = windowHandle()->screen();
auto availableSize = screen->availableSize();

// leave at least 100 px of height so preferences window does not take
// entire screen height. User will still be able to resize the window,
// but it should never start too tall.
auto maxStartHeight = availableSize.height() - 100;

if (height() > maxStartHeight) {
auto heightDifference = availableSize.height() - maxStartHeight;

// resize and reposition window so it is fully visible
resize(width(), maxStartHeight);
move(x(), heightDifference / 2);
}
}

QModelIndex findRootIndex(const QModelIndex& index)
Expand Down
49 changes: 33 additions & 16 deletions src/Gui/DlgProjectInformation.ui
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,23 @@
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="textLabelUnitSystem">
<property name="text">
<string>Unit System:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="comboBox_unitSystem">
<property name="toolTip">
<string>Unit system for this file</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="textLabelCreator">
<property name="text">
<string>Created &amp;by:</string>
Expand All @@ -149,7 +166,7 @@
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QLineEdit" name="lineEditCreator">
<property name="minimumSize">
<size>
Expand All @@ -159,7 +176,7 @@
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="textLabelCreateDate">
<property name="text">
<string>Creation &amp;date:</string>
Expand All @@ -172,7 +189,7 @@
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QLineEdit" name="lineEditDate">
<property name="minimumSize">
<size>
Expand All @@ -185,7 +202,7 @@
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="textLabelLastMod">
<property name="text">
<string>&amp;Last modified by:</string>
Expand All @@ -198,7 +215,7 @@
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<widget class="QLineEdit" name="lineEditLastMod">
<property name="minimumSize">
<size>
Expand All @@ -208,7 +225,7 @@
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="textLabelLastModDate">
<property name="text">
<string>Last &amp;modification date:</string>
Expand All @@ -221,7 +238,7 @@
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QLineEdit" name="lineEditLastModDate">
<property name="minimumSize">
<size>
Expand All @@ -234,7 +251,7 @@
</property>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QLabel" name="textLabelCompany">
<property name="text">
<string>Com&amp;pany:</string>
Expand All @@ -247,7 +264,7 @@
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QLineEdit" name="lineEditCompany">
<property name="minimumSize">
<size>
Expand All @@ -257,7 +274,7 @@
</property>
</widget>
</item>
<item row="9" column="0">
<item row="10" column="0">
<widget class="QLabel" name="textLabelLicense">
<property name="text">
<string>License information:</string>
Expand All @@ -267,10 +284,10 @@
</property>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<widget class="QComboBox" name="comboLicense"/>
</item>
<item row="10" column="0">
<item row="11" column="0">
<widget class="QLabel" name="textLabelLicenseURL">
<property name="text">
<string>License URL</string>
Expand All @@ -280,7 +297,7 @@
</property>
</widget>
</item>
<item row="10" column="1">
<item row="11" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="lineEditLicenseURL"/>
Expand All @@ -294,7 +311,7 @@
</item>
</layout>
</item>
<item row="11" column="0">
<item row="12" column="0">
<widget class="QLabel" name="textLabelComment">
<property name="text">
<string>&amp;Comment:</string>
Expand All @@ -307,10 +324,10 @@
</property>
</widget>
</item>
<item row="11" column="1" rowspan="2">
<item row="12" column="1" rowspan="2">
<widget class="QTextEdit" name="textEditComment"/>
</item>
<item row="12" column="0">
<item row="13" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand Down
Loading

0 comments on commit f128ad2

Please sign in to comment.