Skip to content

Commit 47947b6

Browse files
committed
App,Base: add option to automatically expand compound shapes on file import
Relates to GitHub #374
1 parent 593d5e2 commit 47947b6

14 files changed

Lines changed: 870 additions & 756 deletions

i18n/mayo_en.qm

87 Bytes
Binary file not shown.

i18n/mayo_en.ts

Lines changed: 270 additions & 254 deletions
Large diffs are not rendered by default.

i18n/mayo_fr.qm

-75 Bytes
Binary file not shown.

i18n/mayo_fr.ts

Lines changed: 275 additions & 247 deletions
Large diffs are not rendered by default.

i18n/mayo_zh.qm

-545 Bytes
Binary file not shown.

i18n/mayo_zh.ts

Lines changed: 273 additions & 245 deletions
Large diffs are not rendered by default.

src/app/app_module.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ AppModule::AppModule()
9696

9797
m_settings->setPropertyValueConversion(this);
9898
Application::defineMayoFormat(m_application);
99+
m_settings->signalPropertyChanged.connectSlot([=](const Property* prop){
100+
if (prop == &m_props.autoExpandCompoundToAssembly)
101+
m_application->setAutoExpandCompoundToAssembly(m_props.autoExpandCompoundToAssembly);
102+
});
99103
}
100104

101105
QStringUtils::TextOptions AppModule::defaultTextOptions() const

src/app/app_module_properties.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ AppModuleProperties::AppModuleProperties(Settings* settings)
3939
groupId_application(settings->addGroup(textId("application"))),
4040
groupId_meshing(settings->addGroup(textId("meshing"))),
4141
groupId_graphics(settings->addGroup(textId("graphics"))),
42+
groupId_import(settings->addGroup(textId("import"))),
43+
groupId_export(settings->addGroup(textId("export"))),
4244
language(this, textId("language"), &AppModule::languages()),
4345
viewCubeCorner(this, textId("viewCubeCorner"), &cornerEnumeration()),
4446
m_settings(settings)
@@ -95,6 +97,9 @@ AppModuleProperties::AppModuleProperties(Settings* settings)
9597
settings->addSetting(&this->meshDefaultsShowEdges, sectionId_graphicsMeshDefaults);
9698
settings->addSetting(&this->meshDefaultsShowNodes, sectionId_graphicsMeshDefaults);
9799

100+
// Import
101+
settings->addSetting(&this->autoExpandCompoundToAssembly, groupId_import);
102+
98103
// Register reset functions
99104
settings->addResetFunction(sectionId_systemUnits, [=]{
100105
this->unitSystemDecimals.setValue(2);
@@ -139,14 +144,16 @@ AppModuleProperties::AppModuleProperties(Settings* settings)
139144
this->meshDefaultsShowEdges.setValue(meshDefaults.showEdges);
140145
this->meshDefaultsShowNodes.setValue(meshDefaults.showNodes);
141146
});
147+
settings->addResetFunction(groupId_import, [=]{
148+
this->autoExpandCompoundToAssembly.setValue(true);
149+
});
142150
}
143151

144152
void AppModuleProperties::IO_bindParameters(const IO::System* ioSystem)
145153
{
146154
// Import
147-
const auto groupId_Import = m_settings->addGroup(textId("import"));
148155
for (IO::Format format : ioSystem->readerFormats()) {
149-
auto sectionId_format = m_settings->addSection(groupId_Import, IO::formatIdentifier(format));
156+
auto sectionId_format = m_settings->addSection(groupId_import, IO::formatIdentifier(format));
150157
const IO::FactoryReader* factory = ioSystem->findFactoryReader(format);
151158
std::unique_ptr<PropertyGroup> ptrGroup = factory->createProperties(format, m_settings);
152159
if (ptrGroup) {
@@ -161,9 +168,8 @@ void AppModuleProperties::IO_bindParameters(const IO::System* ioSystem)
161168
}
162169

163170
// Export
164-
const auto groupId_Export = m_settings->addGroup(textId("export"));
165171
for (IO::Format format : ioSystem->writerFormats()) {
166-
auto sectionId_format = m_settings->addSection(groupId_Export, IO::formatIdentifier(format));
172+
auto sectionId_format = m_settings->addSection(groupId_export, IO::formatIdentifier(format));
167173
const IO::FactoryWriter* factory = ioSystem->findFactoryWriter(format);
168174
std::unique_ptr<PropertyGroup> ptrGroup = factory->createProperties(format, m_settings);
169175
if (ptrGroup) {
@@ -253,6 +259,12 @@ void AppModuleProperties::retranslate()
253259
this->clipPlanesCappingHatchOn.setDescription(
254260
textIdTr("Enable capping hatch texture of currently clipped graphics")
255261
);
262+
263+
// Import
264+
this->autoExpandCompoundToAssembly.setDescription(
265+
textIdTr("Automatically expand compound shapes to assemblies. For some input models this "
266+
"allows 3D exploding")
267+
);
256268
}
257269

258270
void AppModuleProperties::onPropertyChanged(Property* prop)

src/app/app_module_properties.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class AppModuleProperties : public PropertyGroup {
5757
const Settings::GroupIndex groupId_application;
5858
const Settings::GroupIndex groupId_meshing;
5959
const Settings::GroupIndex groupId_graphics;
60+
const Settings::GroupIndex groupId_import;
61+
const Settings::GroupIndex groupId_export;
6062

6163
// System
6264
PropertyInt unitSystemDecimals{ this, textId("decimalCount") };
@@ -91,6 +93,8 @@ class AppModuleProperties : public PropertyGroup {
9193
PropertyEnumeration meshDefaultsMaterial{ this, textId("material"), &OcctEnums::Graphic3d_NameOfMaterial() };
9294
PropertyBool meshDefaultsShowEdges{ this, textId("showEgesOn") };
9395
PropertyBool meshDefaultsShowNodes{ this, textId("showNodesOn") };
96+
// Import
97+
PropertyBool autoExpandCompoundToAssembly{ this, textId("autoExpandCompoundToAssembly") };
9498

9599
protected:
96100
// -- from PropertyGroup

src/base/application.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class Document::FormatXmlRetrievalDriver : public XmlXCAFDrivers_DocumentRetriev
5050
struct Application::Private {
5151
std::atomic<Document::Identifier> m_seqDocumentIdentifier = {};
5252
std::unordered_map<Document::Identifier, DocumentPtr> m_mapIdentifierDocument;
53+
bool m_autoExpandCompoundToAssembly = true;
5354
};
5455

5556
struct ApplicationI18N {
@@ -143,6 +144,16 @@ void Application::closeDocument(const DocumentPtr& doc)
143144
//doc->Main().ForgetAllAttributes(true/*clearChildren*/);
144145
}
145146

147+
bool Application::autoExpandCompoundToAssembly() const
148+
{
149+
return d->m_autoExpandCompoundToAssembly;
150+
}
151+
152+
void Application::setAutoExpandCompoundToAssembly(bool on)
153+
{
154+
d->m_autoExpandCompoundToAssembly = on;
155+
}
156+
146157
void Application::defineMayoFormat(const ApplicationPtr& app)
147158
{
148159
const char strFougueCopyright[] = "Copyright (c) 2024, Fougue Ltd. <https://www.fougue.pro>";

0 commit comments

Comments
 (0)