Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
279 changes: 235 additions & 44 deletions TIGLCreator/src/TIGLCreatorDocument.cpp

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions TIGLCreator/src/TIGLCreatorDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public slots:

// Wing slots
void drawWingProfiles();
void drawWing();
void drawWing(const QString& Uid=nullptr);
void drawWingOverlayProfilePoints();
void drawWingGuideCurves();
void drawWingTriangulation();
Expand All @@ -102,8 +102,8 @@ public slots:
void drawWingComponentSegment();
void drawWingComponentSegmentPoints();
void drawWingShells();
void drawWingFlaps();
void drawWingStructure();
void drawWingFlaps(const QString& wingUID=nullptr);
void drawWingStructure(const QString& wingUID=nullptr);

// Fuselage slots
void drawFuselageProfiles();
Expand Down Expand Up @@ -164,7 +164,7 @@ private slots:
// Wing selection dialogs
QString dlgGetWingOrRotorBladeSelection();
QString dlgGetWingSelection();
QString dlgGetWingComponentSegmentSelection();
QString dlgGetWingComponentSegmentSelection(const QString& wingUID=nullptr);
QString dlgGetWingSegmentSelection();
QString dlgGetWingProfileSelection();

Expand Down Expand Up @@ -216,6 +216,7 @@ private slots:
void drawWingShells(tigl::CCPACSWing& wing);
bool drawWingFlaps(tigl::CCPACSWing& wing);
void drawWingFlap(const QString& flapUID);
void removeWingFlaps(const QString& Uid);

void createShapeTriangulation(const class TopoDS_Shape& shape, class TopoDS_Compound& compound);

Expand Down
96 changes: 84 additions & 12 deletions TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "../TIGLCreatorContext.h"
#include "ui_ModificatorDisplayOptionsWidget.h"
#include <QFileDialog>
#include "TIGLCreatorWindow.h"

#define BTN_STYLE "#%2 {background-color: %1; color: black; border: 1px solid black; border-radius: 5px;} #%2:hover {border: 1px solid white;}"

Expand All @@ -56,7 +57,7 @@ ModificatorDisplayOptionsWidget::ModificatorDisplayOptionsWidget(QWidget* parent
materialCombo->addItem(kv.first);
}

// interactions
// General Display Options
connect(transparencySlider, SIGNAL(valueChanged(int)), this, SLOT(onTransparencyChanged(int)));
connect(renderingModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onRenderingModeChanged(int)));
connect(materialCombo, SIGNAL(currentTextChanged(const QString &)), this, SLOT(onMaterialChanged(const QString &)));
Expand All @@ -81,21 +82,23 @@ void ModificatorDisplayOptionsWidget::setFromItem(cpcr::CPACSTreeItem* item, TIG
ui->transparencySlider->setVisible(false);
ui->labelRenderingMode->setVisible(false);
ui->renderingModeCombo->setVisible(false);
ui->labelColor->setVisible(false);
ui->buttonColorChoser->setVisible(false);
ui->label_color->setVisible(false);
ui->labelColor->setVisible(false);
ui->labelMaterial->setVisible(false);
ui->materialCombo->setVisible(false);
ui->buttonResetOptions->setVisible(false);
ui->drawOptionsCombo->setVisible(false);
}
currentItem = nullptr;
return;
}
if (item)
{
if ((!item->getUid().empty() && doc->GetConfiguration().GetUIDManager().HasGeometricComponent(item->getUid()))) {
auto uid = item->getUid();
const QString uid = QString::fromStdString(item->getUid());
if ((!uid.isEmpty() && doc->GetConfiguration().GetUIDManager().HasGeometricComponent(uid.toStdString()))) {
const auto& shapes = doc->GetConfiguration().GetUIDManager().GetShapeContainer();
auto it = shapes.find(uid);
auto it = shapes.find(uid.toStdString());
if (it != shapes.end() && it->second != nullptr) {
tigl::ITiglGeometricComponent* comp = it->second;
if (comp->GetComponentType() != TIGL_COMPONENT_PLANE && comp->GetComponentType() != TIGL_COMPONENT_CROSS_BEAM_STRUT) {
Expand All @@ -105,15 +108,14 @@ void ModificatorDisplayOptionsWidget::setFromItem(cpcr::CPACSTreeItem* item, TIG
ui->transparencySlider->setVisible(true);
ui->labelRenderingMode->setVisible(true);
ui->renderingModeCombo->setVisible(true);
ui->label_color->setVisible(true);
ui->labelColor->setVisible(true);
ui->buttonColorChoser->setVisible(true);
ui->labelMaterial->setVisible(true);
ui->materialCombo->setVisible(true);
ui->buttonResetOptions->setVisible(true);
ui->drawOptionsCombo->setVisible(true);
}

const QString type = QString::fromStdString(item->getType());
const QString uid = QString::fromStdString(item->getUid());



// get current values
Expand Down Expand Up @@ -152,13 +154,70 @@ void ModificatorDisplayOptionsWidget::setFromItem(cpcr::CPACSTreeItem* item, TIG
ui->labelRenderingMode->setVisible(false);
ui->renderingModeCombo->setVisible(false);
ui->buttonColorChoser->setVisible(false);
ui->label_color->setVisible(false);
ui->labelColor->setVisible(false);
ui->labelMaterial->setVisible(false);
ui->materialCombo->setVisible(false);
ui->buttonResetOptions->setVisible(false);
ui->drawOptionsCombo->setVisible(false);
}
}
}


// Populate draw options combo when the selected item is a wing (type or uid == "wing").
ui->drawOptionsCombo->clear();
drawCallbacks.clear();
if (!uid.isEmpty() && doc->GetConfiguration().GetUIDManager().HasGeometricComponent(uid.toStdString())) {
auto type = doc->GetConfiguration().GetUIDManager().GetGeometricComponent(uid.toStdString()).GetComponentType();

if (type == TIGL_COMPONENT_WING) {
// Add entries and store callbacks that call the document drawing functions
ui->drawOptionsCombo->addItem(tr("Wing"));
drawCallbacks.push_back([doc, uid]() { if (doc) doc->drawWing(uid); });

ui->drawOptionsCombo->addItem(tr("Profiles"));
drawCallbacks.push_back([doc]() { if (doc) doc->drawWingProfiles(); });

ui->drawOptionsCombo->addItem(tr("Overlay profile points"));
drawCallbacks.push_back([doc]() { if (doc) doc->drawWingOverlayProfilePoints(); });

ui->drawOptionsCombo->addItem(tr("Guide curves"));
drawCallbacks.push_back([doc]() { if (doc) doc->drawWingGuideCurves(); });

ui->drawOptionsCombo->addItem(tr("Triangulation"));
drawCallbacks.push_back([doc]() { if (doc) doc->drawWingTriangulation(); });

ui->drawOptionsCombo->addItem(tr("Sample points"));
drawCallbacks.push_back([doc]() { if (doc) doc->drawWingSamplePoints(); });

ui->drawOptionsCombo->addItem(tr("Fused wing"));
drawCallbacks.push_back([doc]() { if (doc) doc->drawFusedWing(); });

ui->drawOptionsCombo->addItem(tr("Component segment"));
drawCallbacks.push_back([doc]() { if (doc) doc->drawWingComponentSegment(); });

ui->drawOptionsCombo->addItem(tr("Component segment points"));
drawCallbacks.push_back([doc]() { if (doc) doc->drawWingComponentSegmentPoints(); });

ui->drawOptionsCombo->addItem(tr("Shells"));
drawCallbacks.push_back([doc]() { if (doc) doc->drawWingShells(); });

ui->drawOptionsCombo->addItem(tr("Structure"));
drawCallbacks.push_back([doc, uid]() { if (doc) doc->drawWingStructure(uid); });

ui->drawOptionsCombo->addItem(tr("Flaps"));
drawCallbacks.push_back([doc, uid]() { if (doc) doc->drawWingFlaps(uid); });

// Trigger the corresponding callback when an item is activated. Use UniqueConnection to avoid duplicate connections.
connect(ui->drawOptionsCombo, QOverload<int>::of(&QComboBox::activated), this,
[this](int idx) {
if (idx >= 0 && idx < static_cast<int>(drawCallbacks.size()) && drawCallbacks[idx]) {
drawCallbacks[idx]();
}
}, Qt::UniqueConnection);
}
}
}

}

bool ModificatorDisplayOptionsWidget::apply()
Expand Down Expand Up @@ -417,9 +476,22 @@ void ModificatorDisplayOptionsWidget::onResetOptions()
// redraw component to reset options (necessary to reset different colors on mirrored components)
context->Remove(obj, Standard_False);
sm.removeObject(obj);
currentDoc->drawComponentByUID(uid);

}
}

auto type = currentDoc->GetConfiguration().GetUIDManager().GetGeometricComponent(uid.toStdString()).GetComponentType();
if (type == TIGL_COMPONENT_WING) {
tigl::CCPACSWing& wing = currentDoc->GetConfiguration().GetWing(uid.toStdString());
wing.SetBuildFlaps(false);
currentDoc->drawWing(uid);

}

else {
currentDoc->drawComponentByUID(uid);
}

if (!currentContext->getContext().IsNull()) {
currentContext->updateViewer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class QButtonGroup;
class QPushButton;
class QComboBox;
class QColor;
// callbacks used for draw options (avoid direct QAction dependency)
#include <vector>
#include <functional>

class ModificatorDisplayOptionsWidget : public CpacsEditorBase
{
Expand Down Expand Up @@ -74,6 +77,9 @@ private slots:
QComboBox* materialCombo{nullptr};
QPushButton* buttonResetOptions{nullptr};

// Callbacks mapped to indices of ui->drawOptionsCombo (used for wing draw options)
std::vector<std::function<void()>> drawCallbacks;

cpcr::CPACSTreeItem* currentItem{nullptr};
TIGLCreatorDocument* currentDoc{nullptr};
TIGLCreatorContext* currentContext{nullptr};
Expand Down
36 changes: 20 additions & 16 deletions TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_Color">
<item>
<widget class="QLabel" name="label_color">
<widget class="QLabel" name="labelColor">
<property name="text">
<string>Color:</string>
</property>
Expand Down Expand Up @@ -107,22 +107,26 @@
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="labelDraw">
<property name="text">
<string>Draw Options:</string>
</property>
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="drawOptionsCombo">
<property name="visible">
<bool>false</bool>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_drawOptions">
<item>
<widget class="QLabel" name="labelDrawOptions">
<property name="text">
<string>Material:</string>
</property>
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="drawOptionsCombo">
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="buttonResetOptions">
Expand Down
34 changes: 34 additions & 0 deletions src/wing/CCPACSWing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS.hxx>
#include "CNamedShape.h"
#include "CTiglLogging.h"
#include <BRepMesh_IncrementalMesh.hxx>
#include <BRepBuilderAPI_Transform.hxx>
Expand Down Expand Up @@ -305,6 +306,39 @@ CCPACSWingComponentSegment& CCPACSWing::GetComponentSegment(const std::string& u
return m_componentSegments->GetComponentSegment(uid);
}

PNamedShape CCPACSWing::GetMirroredLoft(PNamedShape input_shape) const
{
if (!input_shape) {
input_shape = GetLoft();
}
const TiglSymmetryAxis& symmetryAxis = GetSymmetryAxis();
if (symmetryAxis == TIGL_NO_SYMMETRY) {
return PNamedShape();
}

CTiglTransformation trafo;
if (symmetryAxis == TIGL_X_Z_PLANE) {
trafo.AddMirroringAtXZPlane();
}
else if (symmetryAxis == TIGL_X_Y_PLANE) {
trafo.AddMirroringAtXYPlane();
}
else if (symmetryAxis == TIGL_Y_Z_PLANE) {
trafo.AddMirroringAtYZPlane();
}

PNamedShape mirroredShape = trafo.Transform(input_shape);

std::string mirrorName = mirroredShape->Name();
mirrorName += "M";
std::string mirrorShortName = mirroredShape->ShortName();
mirrorShortName += "M";
mirroredShape->SetName(mirrorName.c_str());
mirroredShape->SetShortName(mirrorShortName.c_str());
return mirroredShape;
}


// Gets the loft of the whole wing with modeled leading edge.
TopoDS_Shape& CCPACSWing::GetLoftWithLeadingEdge()
{
Expand Down
6 changes: 6 additions & 0 deletions src/wing/CCPACSWing.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ friend class CTiglWingBuilder;
*/
TIGL_EXPORT CCPACSWingComponentSegment& GetComponentSegment(const std::string& uid);

/**
* @brief Returns the mirrored loft at the wings symmetry plane
* @param input_shape Shape to be mirrored with the wings symmetry
* @return PNamedShape
*/
TIGL_EXPORT PNamedShape GetMirroredLoft(PNamedShape input_shape = nullptr) const;
/**
* @brief Returns the positioning transformation for a given section uid
* @param sectionUID
Expand Down
Loading