diff --git a/TIGLCreator/src/DrawOptionsActions.cpp b/TIGLCreator/src/DrawOptionsActions.cpp new file mode 100644 index 000000000..1c5d44c37 --- /dev/null +++ b/TIGLCreator/src/DrawOptionsActions.cpp @@ -0,0 +1,82 @@ +#include "DrawOptionsActions.h" +#include + +// Forward declaration for example +void onColorChosen(); + + +// WING actions +const std::vector& getWingDrawOptionsActions() { + static std::vector actions = { + { "Show Wing", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawWing(uid);} }, + { "Show Fused wing", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawFusedWing(uid);} }, + { "Show Wing Shells", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawWingShells(uid); } }, + { "Show Wing Component segment", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawWingComponentSegment(uid); } }, + { "Show Wing Structure", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawWingStructure(uid);} }, + { "Show Wing triangulation", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawWingTriangulation(uid); } }, + { "Show Wing Profiles", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawWingProfiles(); } }, + { "Show Wing Guide curves", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawWingGuideCurves(uid);} }, + { "Show Wing Flaps", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawWingFlaps(uid);} }, + { "Show Wing Sample points", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawWingSamplePoints(uid);} }, + { "Show Wing Overlay profile points", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawWingOverlayProfilePoints(uid); } }, + { "Show Wing Component segment points", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawWingComponentSegmentPoints(uid);} } + }; + return actions; +} + +// FUSELAGE actions +const std::vector& getFuselageDrawOptionsActions() { + static std::vector actions = { + { "Show Fuselage", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawFuselage(uid);} }, + { "Show Fuselage Profiles", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawFuselageProfiles(); } }, + { "Show Fuselage Guide Curves", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawFuselageGuideCurves(uid); } }, + { "Show Fuselage triangulation", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawFuselageTriangulation(uid); } }, + { "Show Fuselage Sample points", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawFuselageSamplePoints(uid); } }, + { "Show Fuselage Sample points at angle", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawFuselageSamplePointsAngle(uid); } }, + { "Show Fused fuselage", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawFusedFuselage(uid); } } + }; + return actions; +} + +// PLANE actions +const std::vector& getPlaneDrawOptionsActions() { + static std::vector actions = { + { "Show the complete aircraft", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawConfiguration(); } }, + { "Show the complete aircraft with duct cutouts", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawConfigurationWithDuctCutouts(); } }, + { "Show he complete aircraft fused (slow)", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawFusedAircraft(); } }, + { "Show fused aircraft triangulation (slow)", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawFusedAircraftTriangulation(); } }, + { "Show intersection line", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawIntersectionLine(); } }, + { "Draw Far Field", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawFarField(); } }, + { "Draw Systems", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawSystems();} }, + { "Draw any Component", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawComponent(); } }, + { "Draw Control Point Net", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawControlPointNet(); } } + }; + return actions; +} + +// ROTORBLADE actions +const std::vector& getRotorBladeDrawOptionsActions() { + static std::vector actions = { + { "Show Rotor Blade", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawRotorBlade(uid); } }, + { "Show Rotor Blade Guide curves", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawRotorBladeGuideCurves(); } }, + { "Show Rotor Blade overlay profile points", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawRotorBladeOverlayProfilePoints(uid); } }, + { "Show Rotor Blade Triangulation", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawRotorBladeTriangulation(uid); } }, + { "Show Sample Rotor Blade points", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawRotorBladeSamplePoints(uid); } }, + { "Show Fused Rotor Blade", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawFusedRotorBlade(uid); } }, + { "Show Rotor Blade Component segment", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawRotorBladeComponentSegment(uid); } }, + { "Show Rotor Blade Component segment points", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawRotorBladeComponentSegmentPoints(uid); } }, + { "Show Rotor Blade Shells", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawRotorBladeShells(uid); } }, + { "Show all Rotors, Wings and Fuselages", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawAllFuselagesAndWingsSurfacePoints(); } } + }; + return actions; +} + +// ROTOR actions +const std::vector& getRotorDrawOptionsActions() { + static std::vector actions = { + { "Show Rotor", [](TIGLCreatorDocument* doc, const QString& uid){ doc->drawRotorByUID(uid);} }, + { "Show Rotor Disk", [](TIGLCreatorDocument* doc, const QString& uid){doc->drawRotorDisk(uid);} }, + { "Show Rotor Properties", [](TIGLCreatorDocument* doc, const QString& uid){ doc->showRotorProperties(uid);} } + }; + return actions; +} diff --git a/TIGLCreator/src/DrawOptionsActions.h b/TIGLCreator/src/DrawOptionsActions.h new file mode 100644 index 000000000..1eb06bed0 --- /dev/null +++ b/TIGLCreator/src/DrawOptionsActions.h @@ -0,0 +1,16 @@ +#pragma once +#include +#include "TIGLCreatorDocument.h" + +void handleDrawOption(const QString& actionName); + +struct DrawOptionAction { + QString label; // User-facing label + std::function handler; +}; + +const std::vector& getWingDrawOptionsActions(); +const std::vector& getFuselageDrawOptionsActions(); +const std::vector& getPlaneDrawOptionsActions(); +const std::vector& getRotorBladeDrawOptionsActions(); +const std::vector& getRotorDrawOptionsActions(); \ No newline at end of file diff --git a/TIGLCreator/src/TIGLCreatorContext.cpp b/TIGLCreator/src/TIGLCreatorContext.cpp index a54b25926..43dd45db6 100644 --- a/TIGLCreator/src/TIGLCreatorContext.cpp +++ b/TIGLCreator/src/TIGLCreatorContext.cpp @@ -410,7 +410,7 @@ Handle(AIS_Shape) TIGLCreatorContext::displayShape(const PNamedShape& pshape, bo } // Displays a point on the screen -void TIGLCreatorContext::displayPoint(const gp_Pnt& aPoint, +Handle(AIS_Shape) TIGLCreatorContext::displayPoint(const gp_Pnt& aPoint, const char* aText, Standard_Boolean UpdateViewer, Standard_Real anXoffset, @@ -419,16 +419,17 @@ void TIGLCreatorContext::displayPoint(const gp_Pnt& aPoint, Standard_Real TextScale) { if (std::string(aText).empty()) { - displayShape(BRepBuilderAPI_MakeVertex(gp_Pnt(aPoint.X() + anXoffset, aPoint.Y() + anYoffset, aPoint.Z() + aZoffset)), UpdateViewer, Quantity_NOC_YELLOW); + return displayShape(BRepBuilderAPI_MakeVertex(gp_Pnt(aPoint.X() + anXoffset, aPoint.Y() + anYoffset, aPoint.Z() + aZoffset)), UpdateViewer, Quantity_NOC_YELLOW); } else { Handle(ISession_Point) aGraphicPoint = new ISession_Point(aPoint.X(), aPoint.Y(), aPoint.Z()); myContext->Display(aGraphicPoint,UpdateViewer); Handle(ISession_Text) aGraphicText = new ISession_Text(aText, aPoint.X() + anXoffset, - aPoint.Y() + anYoffset, - aPoint.Z() + aZoffset); + aPoint.Y() + anYoffset, + aPoint.Z() + aZoffset); aGraphicText->SetScale(TextScale); myContext->Display(aGraphicText,UpdateViewer); + return Handle(AIS_Shape)::DownCast(aGraphicPoint); } } diff --git a/TIGLCreator/src/TIGLCreatorContext.h b/TIGLCreator/src/TIGLCreatorContext.h index aa9bb8b95..ed3942739 100644 --- a/TIGLCreator/src/TIGLCreatorContext.h +++ b/TIGLCreator/src/TIGLCreatorContext.h @@ -61,7 +61,7 @@ class TIGLCreatorContext : public QObject void setGridOffset (Standard_Real offset); - void displayPoint(const gp_Pnt& aPoint, + Handle(AIS_Shape) displayPoint(const gp_Pnt& aPoint, const char* aText, Standard_Boolean UpdateViewer, Standard_Real anXoffset, diff --git a/TIGLCreator/src/TIGLCreatorDocument.cpp b/TIGLCreator/src/TIGLCreatorDocument.cpp index ee31b37ee..74f9c2630 100644 --- a/TIGLCreator/src/TIGLCreatorDocument.cpp +++ b/TIGLCreator/src/TIGLCreatorDocument.cpp @@ -65,6 +65,7 @@ #include "CTiglPoint.h" #include "CTiglError.h" #include "TIGLCreatorSettings.h" +#include "CTiglTransformation.h" #include "CTiglIntersectionCalculation.h" #include "TIGLCreatorWindow.h" #include "TIGLCreatorEtaXsiDialog.h" @@ -81,6 +82,8 @@ #include "tiglcommonfunctions.h" #include "CTiglPoint.h" #include "CTiglExportCollada.h" +#include "CNamedShape.h" +#include "TiglSymmetryAxis.h" #include "CCPACSWingCSStructure.h" #include "CCPACSWingSparSegment.h" #include "CCPACSWingRibsDefinition.h" @@ -411,24 +414,30 @@ QString TIGLCreatorDocument::dlgGetWingOrRotorBladeSelection() } // Wing selection Dialog -QString TIGLCreatorDocument::dlgGetWingSelection() +QString TIGLCreatorDocument::dlgGetWingSelection(const QString& wingUid) { QStringList wings; bool ok; // Initialize wing list tigl::CCPACSConfiguration& config = GetConfiguration(); - int wingCount = config.GetWingCount(); - for (int i = 1; i <= wingCount; i++) { - tigl::CCPACSWing& wing = config.GetWing(i); - if (!wing.IsRotorBlade()) { - std::string name = wing.GetUID(); - if (name.empty()) { - name = "Unknown wing"; + + if (wingUid.isEmpty()) { + int wingCount = config.GetWingCount(); + for (int i = 1; i <= wingCount; i++) { + tigl::CCPACSWing& wing = config.GetWing(i); + if (!wing.IsRotorBlade()) { + std::string name = wing.GetUID(); + if (name.empty()) { + name = "Unknown wing"; + } + wings << name.c_str(); } - wings << name.c_str(); } } + else { + return wingUid; + } QString choice = QInputDialog::getItem(app, tr("Select Wing"), tr("Available Wings:"), wings, 0, false, &ok); if (ok) { @@ -440,24 +449,40 @@ QString TIGLCreatorDocument::dlgGetWingSelection() } // Wing Component Segment selection Dialog -QString TIGLCreatorDocument::dlgGetWingComponentSegmentSelection() +QString TIGLCreatorDocument::dlgGetWingComponentSegmentSelection(const QString& wingUID) { QStringList compSegs; bool ok; - // Initialize wing list tigl::CCPACSConfiguration& config = GetConfiguration(); - int wingCount = config.GetWingCount(); - for (int i = 1; i <= wingCount; i++) { - tigl::CCPACSWing& wing = config.GetWing(i); - if (wing.IsRotorBlade()) { - continue; + if (wingUID.isEmpty()) { + + int wingCount = config.GetWingCount(); + for (int i = 1; i <= wingCount; i++) { + tigl::CCPACSWing& wing = config.GetWing(i); + if (wing.IsRotorBlade()) { + continue; + } + // Get all component segments + for (int j = 1; j <= wing.GetComponentSegmentCount(); ++j) { + tigl::CCPACSWingComponentSegment& segment = wing.GetComponentSegment(j); + compSegs << segment.GetUID().c_str(); + } } - + } + else { + tigl::CCPACSWing& wing = config.GetWing(wingUID.toStdString()); + if (wing.IsRotorBlade()) { + throw tigl::CTiglError("Selected wing is a rotor blade!", TIGL_ERROR); + } + // Only get component segments of the selected wing for (int j = 1; j <= wing.GetComponentSegmentCount(); ++j) { tigl::CCPACSWingComponentSegment& segment = wing.GetComponentSegment(j); compSegs << segment.GetUID().c_str(); } + if (wing.GetComponentSegmentCount() == 1 && !compSegs.empty()) { + return compSegs[0]; + } } QString choice = QInputDialog::getItem(app, tr("Select Component Segment"), tr("Available Component Segments:"), @@ -528,11 +553,13 @@ QString TIGLCreatorDocument::dlgGetWingProfileSelection() } // Rotor selection Dialog -QString TIGLCreatorDocument::dlgGetRotorSelection() +QString TIGLCreatorDocument::dlgGetRotorSelection(const QString& rotorUid) { QStringList rotors; bool ok; - + if (!rotorUid.isEmpty()) { + return rotorUid; + } // Initialize rotorBlade list tigl::CCPACSConfiguration& config = GetConfiguration(); int rotorCount = config.GetRotorCount(); @@ -555,11 +582,13 @@ QString TIGLCreatorDocument::dlgGetRotorSelection() } // Rotor Blade selection Dialog -QString TIGLCreatorDocument::dlgGetRotorBladeSelection() +QString TIGLCreatorDocument::dlgGetRotorBladeSelection(const QString& rotorBladeUid) { QStringList wings; bool ok; - + if (!rotorBladeUid.isEmpty()) { + return rotorBladeUid; + } // Initialize wing list tigl::CCPACSConfiguration& config = GetConfiguration(); int wingCount = config.GetWingCount(); @@ -585,11 +614,14 @@ QString TIGLCreatorDocument::dlgGetRotorBladeSelection() } // Rotor Blade Component Segment Selection Dialog -QString TIGLCreatorDocument::dlgGetRotorBladeComponentSegmentSelection() +QString TIGLCreatorDocument::dlgGetRotorBladeComponentSegmentSelection(const QString& rotorBladeCompSegUid) { QStringList compSegs; bool ok; + if (!rotorBladeCompSegUid.isEmpty()) { + return rotorBladeCompSegUid; + } // Initialize wing list tigl::CCPACSConfiguration& config = GetConfiguration(); int wingCount = config.GetWingCount(); @@ -670,12 +702,15 @@ QString TIGLCreatorDocument::dlgGetRotorProfileSelection() } // Fuselage selection Dialog -QString TIGLCreatorDocument::dlgGetFuselageSelection() +QString TIGLCreatorDocument::dlgGetFuselageSelection(const QString& Uid) { QStringList fuselages; bool ok; - // Initialize wing list + if (!Uid.isEmpty()) { + return Uid; + } + // Initialize fuselage list tigl::CCPACSConfiguration& config = GetConfiguration(); int fuselageCount = config.GetFuselageCount(); for (int i = 1; i <= fuselageCount; i++) { @@ -779,12 +814,12 @@ void TIGLCreatorDocument::drawComponentByUID(const QString& uid) if (loft) { double opacity = 0; bool shaded = true; - // By default, we display the wing without cutouts (for performance). + // By default, we display the wing without cutouts (for performance). // Therefore, it is visually better to display the flaps using a wireframe rendering by default if (component.GetComponentType() == TIGL_COMPONENT_CONTROL_SURFACE_DEVICE) { shaded = false; } - + auto shape = app->getScene()->displayShape(loft, true, getDefaultShapeColor(), opacity, shaded); app->getScene()->GetShapeManager().addObject(uid.toStdString(), shape); @@ -831,10 +866,10 @@ void TIGLCreatorDocument::drawComponentByUID(const QString& uid) void TIGLCreatorDocument::drawControlPointNet() { - auto pre_filter = [](auto* shape) { + auto pre_filter = [](auto* shape) { return shape != nullptr && shape->GetComponentType() != TIGL_COMPONENT_PLANE && - shape->GetComponentType() != TIGL_COMPONENT_CROSS_BEAM_STRUT; + shape->GetComponentType() != TIGL_COMPONENT_CROSS_BEAM_STRUT; }; TIGLGeometryChoserDialog dialog(GetConfiguration().GetUIDManager(), app, pre_filter); @@ -939,7 +974,7 @@ void TIGLCreatorDocument::drawControlPointNetByUID(const QString& uid) void TIGLCreatorDocument::drawConfiguration(bool withDuctCutouts) { tiglConfigurationSetWithDuctCutouts(m_cpacsHandle, (TiglBoolean)withDuctCutouts); - + std::vector shapesToDraw; shapesToDraw.push_back(TIGL_COMPONENT_FUSELAGE); shapesToDraw.push_back(TIGL_COMPONENT_WING); @@ -991,9 +1026,9 @@ void TIGLCreatorDocument::drawWingProfiles() } } -void TIGLCreatorDocument::drawWingOverlayProfilePoints() +void TIGLCreatorDocument::drawWingOverlayProfilePoints(const QString& Uid) { - QString wingUid = dlgGetWingSelection(); + QString wingUid = dlgGetWingSelection(Uid); try { tigl::CCPACSWing& wing = GetConfiguration().GetWing(wingUid.toStdString()); drawWingOverlayProfilePoints(wing); @@ -1003,9 +1038,9 @@ void TIGLCreatorDocument::drawWingOverlayProfilePoints() } } -void TIGLCreatorDocument::drawWingGuideCurves() +void TIGLCreatorDocument::drawWingGuideCurves(const QString& uid) { - QString wingUid = dlgGetWingSelection(); + QString wingUid = dlgGetWingSelection(uid); if (wingUid == "") { return; } @@ -1091,9 +1126,9 @@ void TIGLCreatorDocument::drawFuselageProfiles() } } -void TIGLCreatorDocument::drawFuselageGuideCurves() +void TIGLCreatorDocument::drawFuselageGuideCurves(const QString& Uid) { - QString fuselageUid = dlgGetFuselageSelection(); + QString fuselageUid = dlgGetFuselageSelection(Uid); if (fuselageUid == "") { return; } @@ -1123,43 +1158,25 @@ void TIGLCreatorDocument::drawFuselageGuideCurves() app->getScene()->getContext()->UpdateCurrentViewer(); } -void TIGLCreatorDocument::drawWing() +void TIGLCreatorDocument::drawWing(const QString& Uid) { - QString wingUid = dlgGetWingSelection(); - if (wingUid == "") { - return; - } - else { - drawComponentByUID(wingUid); - } + QString wingUid = dlgGetWingSelection(Uid); tigl::CCPACSWing& wing = GetConfiguration().GetWing(wingUid.toStdString()); - if (wing.GetComponentSegments()) - { - for (auto& pcs : wing.GetComponentSegments()->GetComponentSegments()) { - if (!pcs->GetControlSurfaces() || pcs->GetControlSurfaces()->ControlSurfaceCount() == 0) { - continue; - } - if (auto& teds = pcs->GetControlSurfaces()->GetTrailingEdgeDevices()) { - for (auto& ted : teds->GetTrailingEdgeDevices()) { - drawComponentByUID(ted->GetUID().c_str()); - } - } - if (auto& leds = pcs->GetControlSurfaces()->GetLeadingEdgeDevices()) { - for (auto& led : leds->GetLeadingEdgeDevices()) { - drawComponentByUID(led->GetUID().c_str()); - } - } - } + auto objects = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(wingUid.toStdString()); + for (auto& obj : objects) { + app->getScene()->GetShapeManager().removeObject(obj); + app->getScene()->getContext()->Remove(obj, Standard_False); } + removeWingFlaps(wingUid); + drawComponentByUID(wingUid); + + app->getScene()->updateViewer(); } -void TIGLCreatorDocument::drawWingFlaps() +void TIGLCreatorDocument::drawWingFlaps(const QString& Uid) { - QString wingUid = dlgGetWingSelection(); - if (wingUid == "") { - return; - } + QString wingUid = dlgGetWingSelection(Uid); try { tigl::CCPACSWing& wing = GetConfiguration().GetWing(wingUid.toStdString()); @@ -1199,8 +1216,17 @@ bool TIGLCreatorDocument::drawWingFlaps(tigl::CCPACSWing& wing) return false; } - app->getScene()->deleteAllObjects(); - app->getScene()->displayShape(wing.GetLoftWithCutouts(), true, getDefaultShapeColor()); + removeWing(QString::fromStdString(wing.GetUID())); + + auto shape = app->getScene()->displayShape(wing.GetLoftWithCutouts(), true, getDefaultShapeColor()); + app->getScene()->GetShapeManager().addObject(wing.GetUID(), shape); + + PNamedShape loftNamed(new CNamedShape(wing.GetLoftWithCutouts(), wing.GetUID().c_str())); + PNamedShape mirroredLoft = wing.GetMirroredLoft(loftNamed); + if (mirroredLoft) { + auto shape = app->getScene()->displayShape(mirroredLoft, true, getDefaultShapeSymmetryColor()); + app->getScene()->GetShapeManager().addObject(wing.GetUID(), shape); + } for (auto& pcs : wing.GetComponentSegments()->GetComponentSegments()) { if (!pcs->GetControlSurfaces() || pcs->GetControlSurfaces()->ControlSurfaceCount() == 0) { @@ -1209,18 +1235,33 @@ bool TIGLCreatorDocument::drawWingFlaps(tigl::CCPACSWing& wing) if (auto& teds = pcs->GetControlSurfaces()->GetTrailingEdgeDevices()) { for (auto& ted : teds->GetTrailingEdgeDevices()) { + auto objs = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(ted->GetUID()); + // remove old wireframe flap shapes + for (auto& obj : objs) { + app->getScene()->getContext()->Remove(obj, Standard_True); + app->getScene()->GetShapeManager().removeObject(obj); + } drawWingFlap(ted->GetUID().c_str()); + + } } if (auto& leds = pcs->GetControlSurfaces()->GetLeadingEdgeDevices()) { for (auto& led : leds->GetLeadingEdgeDevices()) { + auto objs = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(led->GetUID()); + // remove old wireframe flap shapes + for (auto& obj : objs) { + app->getScene()->getContext()->Remove(obj, Standard_True); + app->getScene()->GetShapeManager().removeObject(obj); + } drawWingFlap(led->GetUID().c_str()); } } } app->getScene()->updateViewer(); } + catch (tigl::CTiglError& ex) { displayError(ex.what(), "Error"); return false; @@ -1237,13 +1278,31 @@ void TIGLCreatorDocument::drawWingFlap(const QString& uid) if (*obj.type == typeid(tigl::CCPACSTrailingEdgeDevice)) { auto* ted = static_cast(obj.ptr); app->getScene()->displayShape(ted->GetLoft(), false, Quantity_NOC_GREEN); + + // if flap has mirrored loft, display it too (not mirrored), to later update its transform and then mirror it + PNamedShape mirrored_loft = ted->GetMirroredLoft(); + if (mirrored_loft) { + PNamedShape mirror_named(new CNamedShape(ted->GetLoft()->Shape(), (ted->GetUID() + "M").c_str())); + auto mirror_shape = app->getScene()->displayShape(mirror_named, false, Quantity_NOC_GREEN); + app->getScene()->GetShapeManager().addObject(ted->GetUID(), mirror_shape); + } updateFlapTransform(ted->GetUID()); + } else if (*obj.type == typeid(tigl::CCPACSLeadingEdgeDevice)) { - auto* ted = static_cast(obj.ptr); - app->getScene()->displayShape(ted->GetLoft(), false, Quantity_NOC_GREEN); - updateFlapTransform(ted->GetUID()); + auto* led = static_cast(obj.ptr); + app->getScene()->displayShape(led->GetLoft(), false, Quantity_NOC_GREEN); + + // if flap has mirrored loft, display it too (not mirrored), to later update its transform and then mirror it + PNamedShape mirrored_loft = led->GetMirroredLoft(); + if (mirrored_loft) { + PNamedShape mirror_named(new CNamedShape(led->GetLoft()->Shape(), (led->GetUID() + "M").c_str())); + auto mirror_shape = app->getScene()->displayShape(mirror_named, false, Quantity_NOC_GREEN); + app->getScene()->GetShapeManager().addObject(led->GetUID(), mirror_shape); + + } + updateFlapTransform(led->GetUID()); } } catch (const tigl::CTiglError& ex) { @@ -1257,6 +1316,7 @@ void TIGLCreatorDocument::updateFlapTransform(const std::string& controlUID) gp_Trsf trsf; IObjectList flaps; + IObjectList mflaps; if (*obj.type == typeid(tigl::CCPACSTrailingEdgeDevice)) { auto* controlSurfaceDevice = static_cast(obj.ptr); @@ -1265,6 +1325,8 @@ void TIGLCreatorDocument::updateFlapTransform(const std::string& controlUID) flaps = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(controlSurfaceDevice->GetUID()); + mflaps = + app->getScene()->GetShapeManager().GetIObjectsFromShapeName(controlSurfaceDevice->GetUID()+"M"); } catch (const tigl::CTiglError&) { displayError(QString("Error computing control surface device '%1'").arg(controlUID.c_str()), @@ -1279,23 +1341,102 @@ void TIGLCreatorDocument::updateFlapTransform(const std::string& controlUID) flaps = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(controlSurfaceDevice->GetUID()); + mflaps = + app->getScene()->GetShapeManager().GetIObjectsFromShapeName(controlSurfaceDevice->GetUID()+"M"); } catch (const tigl::CTiglError&) { displayError(QString("Error computing control surface device '%1'").arg(controlUID.c_str()), QString("Error")); } } - + for (const auto& flap : flaps) { app->getScene()->getContext()->SetLocation(flap, trsf); } - + + for (const auto& mflap : mflaps) { + // apply mirroring on transformed flap + tigl::ITiglGeometricComponent& component = GetConfiguration().GetUIDManager().GetGeometricComponent(controlUID); + auto* geometricComp = dynamic_cast(&component); + if (geometricComp) { + TiglSymmetryAxis sym = geometricComp->GetSymmetryAxis(); + if (sym != TIGL_NO_SYMMETRY) { + gp_Trsf mirror_trsf; + tigl::CTiglTransformation trafo(trsf); + if (sym == TIGL_X_Z_PLANE) { + mirror_trsf.SetMirror(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 1, 0))); + } + else if (sym == TIGL_X_Y_PLANE) { + mirror_trsf.SetMirror(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1))); + } + else if (sym == TIGL_Y_Z_PLANE) { + mirror_trsf.SetMirror(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0))); + } + + app->getScene()->getContext()->SetLocation(mflap, mirror_trsf * trsf); + + } + } + } + app->getViewer()->update(); } -void TIGLCreatorDocument::drawFuselage() +void TIGLCreatorDocument::removeWing(const QString& Uid) { - QString fuselageUid = dlgGetFuselageSelection(); + tigl::CCPACSWing& wing = GetConfiguration().GetWing(Uid.toStdString()); + + auto objects = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(wing.GetUID()); + for (auto& obj : objects) { + app->getScene()->getContext()->Remove(obj, Standard_False); + app->getScene()->GetShapeManager().removeObject(obj); + } +} + +void TIGLCreatorDocument::removeWingFlaps(const QString& Uid) +{ + tigl::CCPACSWing& wing = GetConfiguration().GetWing(Uid.toStdString()); + + for (int j = 1; j <= wing.GetComponentSegmentCount(); ++j) { + tigl::CCPACSWingComponentSegment& cs = wing.GetComponentSegment(j); + + if (auto& teds = cs.GetControlSurfaces()->GetTrailingEdgeDevices()) { + for (auto& ted : teds->GetTrailingEdgeDevices()) { + auto objs = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(ted->GetUID()); + // remove flap shapes + for (auto& obj : objs) { + app->getScene()->getContext()->Remove(obj, Standard_True); + app->getScene()->GetShapeManager().removeObject(obj); + } + } + } + if (auto& leds = cs.GetControlSurfaces()->GetLeadingEdgeDevices()) { + for (auto& led : leds->GetLeadingEdgeDevices()) { + auto objs = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(led->GetUID()); + // remove flap shapes + for (auto& obj : objs) { + app->getScene()->getContext()->Remove(obj, Standard_True); + app->getScene()->GetShapeManager().removeObject(obj); + } + } + } + } +} + +void TIGLCreatorDocument::removeFuselage(const QString& Uid) + { + tigl::CCPACSFuselage& fuselage = GetConfiguration().GetFuselage(Uid.toStdString()); + + auto objects = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(fuselage.GetUID()); + for (auto& obj : objects) { + app->getScene()->getContext()->Remove(obj, Standard_False); + app->getScene()->GetShapeManager().removeObject(obj); + } + } + +void TIGLCreatorDocument::drawFuselage(const QString& Uid) +{ + QString fuselageUid = dlgGetFuselageSelection(Uid); if (fuselageUid == "") { return; } @@ -1303,7 +1444,7 @@ void TIGLCreatorDocument::drawFuselage() START_COMMAND() auto& fuselage = GetConfiguration().GetFuselage(fuselageUid.toStdString()); - app->getScene()->deleteAllObjects(); + removeFuselage(fuselageUid); for (int i = 1; i <= fuselage.GetSegmentCount(); i++) { // Draw segment loft @@ -1312,9 +1453,9 @@ void TIGLCreatorDocument::drawFuselage() } } -void TIGLCreatorDocument::drawWingTriangulation() +void TIGLCreatorDocument::drawWingTriangulation(const QString& Uid) { - QString wingUid = dlgGetWingSelection(); + QString wingUid = dlgGetWingSelection(Uid); try { tigl::CCPACSWing& wing = GetConfiguration().GetWing(wingUid.toStdString()); drawWingTriangulation(wing); @@ -1324,9 +1465,9 @@ void TIGLCreatorDocument::drawWingTriangulation() } } -void TIGLCreatorDocument::drawFuselageTriangulation() +void TIGLCreatorDocument::drawFuselageTriangulation(const QString& Uid) { - QString fuselageUid = dlgGetFuselageSelection(); + QString fuselageUid = dlgGetFuselageSelection(Uid); if (fuselageUid == "") { return; } @@ -1335,18 +1476,19 @@ void TIGLCreatorDocument::drawFuselageTriangulation() auto& fuselage = GetConfiguration().GetFuselage(fuselageUid.toStdString()); //clear screen - app->getScene()->deleteAllObjects(); - const TopoDS_Shape& fusedWing = fuselage.GetLoft()->Shape(); + removeFuselage(fuselageUid); + const TopoDS_Shape& fusedFuselage = fuselage.GetLoft()->Shape(); TopoDS_Compound triangulation; - createShapeTriangulation(fusedWing, triangulation); + createShapeTriangulation(fusedFuselage, triangulation); - app->getScene()->displayShape(triangulation, true, getDefaultShapeColor()); + auto shape = app->getScene()->displayShape(triangulation, true, getDefaultShapeColor()); + app->getScene()->GetShapeManager().addObject(fuselageUid.toStdString(), shape); } -void TIGLCreatorDocument::drawWingSamplePoints() +void TIGLCreatorDocument::drawWingSamplePoints(const QString& Uid) { - QString wingUid = dlgGetWingSelection(); + QString wingUid = dlgGetWingSelection(Uid); try { tigl::CCPACSWing& wing = GetConfiguration().GetWing(wingUid.toStdString()); drawWingSamplePoints(wing); @@ -1356,9 +1498,9 @@ void TIGLCreatorDocument::drawWingSamplePoints() } } -void TIGLCreatorDocument::drawFuselageSamplePoints() +void TIGLCreatorDocument::drawFuselageSamplePoints(const QString& Uid) { - QString fuselageUid = dlgGetFuselageSelection(); + QString fuselageUid = dlgGetFuselageSelection(Uid); if (fuselageUid == "") { return; } @@ -1376,14 +1518,21 @@ void TIGLCreatorDocument::drawFuselageSamplePoints() 1, // TODO: we need to implement that function to use UID instead of index! segmentIndex, eta, zeta, &x, &y, &z); - app->getScene()->displayPoint(gp_Pnt(x, y, z), "", false, 0, 0, 0, 1.0); + auto points = app->getScene()->displayPoint(gp_Pnt(x, y, z), "", false, 0, 0, 0, 1.0); + app->getScene()->GetShapeManager().addObject(fuselageUid.toStdString(), points); } } } + app->getScene()->updateViewer(); } -void TIGLCreatorDocument::drawFuselageSamplePointsAngle() +void TIGLCreatorDocument::drawFuselageSamplePointsAngle(const QString& Uid) { + QString fuselageUid = dlgGetFuselageSelection(Uid); + if (fuselageUid == "") { + return; + } + // ask user defined angle bool ok = false; double angle = @@ -1393,10 +1542,10 @@ void TIGLCreatorDocument::drawFuselageSamplePointsAngle() } START_COMMAND() - int fuselageIndex = 1; + int fuselageIndex = GetConfiguration().GetFuselageIndex(fuselageUid.toStdString()); double x, y, z; - app->getScene()->deleteAllObjects(); + removeFuselage(fuselageUid); auto& fuselage = GetConfiguration().GetFuselage(fuselageIndex); // Draw the fuselage @@ -1408,8 +1557,10 @@ void TIGLCreatorDocument::drawFuselageSamplePointsAngle() // Display the intersection point tiglFuselageGetPointAngle(m_cpacsHandle, fuselageIndex, i, 0.5, angle, &x, &y, &z); - app->getScene()->displayPoint(gp_Pnt(x, y, z), "", Standard_False, 0., 0., 0., 1.); + auto points = app->getScene()->displayPoint(gp_Pnt(x, y, z), "", Standard_False, 0., 0., 0., 1.); + app->getScene()->GetShapeManager().addObject(fuselageUid.toStdString(), points); } + app->getScene()->updateViewer(); } void TIGLCreatorDocument::drawAllFuselagesAndWingsSurfacePoints() @@ -1464,6 +1615,7 @@ void TIGLCreatorDocument::drawAllFuselagesAndWingsSurfacePoints() app->getScene()->updateViewer(); } + // ----------------------- // Export Functions // ----------------------- @@ -2014,29 +2166,23 @@ void TIGLCreatorDocument::exportFuselageCurvesBRep() } } -void TIGLCreatorDocument::drawFusedFuselage() +void TIGLCreatorDocument::drawFusedFuselage(const QString& Uid) { - QString fuselageUid = dlgGetFuselageSelection(); + QString fuselageUid = dlgGetFuselageSelection(Uid); if (fuselageUid == "") { return; } START_COMMAND() - app->getScene()->deleteAllObjects(); + removeFuselage(fuselageUid); auto& fuselage = GetConfiguration().GetFuselage(fuselageUid.toStdString()); app->getScene()->displayShape(fuselage.GetLoft(), true, getDefaultShapeColor()); } -void TIGLCreatorDocument::drawFusedWing() +void TIGLCreatorDocument::drawFusedWing(const QString& Uid) { - QString wingUid = dlgGetWingSelection(); - try { - tigl::CCPACSWing& wing = GetConfiguration().GetWing(wingUid.toStdString()); - drawFusedWing(wing); - } - catch (tigl::CTiglError& ex) { - displayError(ex.what()); - } + // check if function can be removed entirely + drawWing(Uid); } void TIGLCreatorDocument::drawFusedAircraft() @@ -2210,19 +2356,41 @@ void TIGLCreatorDocument::drawIntersectionLine() delete Intersector; } -void TIGLCreatorDocument::drawWingComponentSegment() +void TIGLCreatorDocument::drawWingComponentSegment(const QString& Uid) { - QString csUid = dlgGetWingComponentSegmentSelection(); + QString csUid = dlgGetWingComponentSegmentSelection(Uid); if (csUid == "") { return; } - drawComponentByUID(csUid); + auto& cs = GetConfiguration().GetUIDManager().ResolveObject(csUid.toStdString()); + + auto objects = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(Uid.toStdString()); + for (auto& obj : objects) { + app->getScene()->getContext()->Remove(obj, Standard_False); + app->getScene()->GetShapeManager().removeObject(obj); + } + + removeWingFlaps(Uid); + tigl::CCPACSWing& wing = GetConfiguration().GetWing(Uid.toStdString()); + + // display component segment shape with transparency + auto cs_shape = app->getScene()->displayShape(cs.GetLoft(), true, getDefaultShapeColor()); + app->getScene()->GetShapeManager().addObject(Uid.toStdString(), cs_shape); + PNamedShape mirroredLoft = wing.GetMirroredLoft(cs.GetLoft()); + if (mirroredLoft) + { + auto shape = app->getScene()->displayShape(mirroredLoft, true, getDefaultShapeSymmetryColor()); + app->getScene()->GetShapeManager().addObject(Uid.toStdString(), shape); + + } + + app->getScene()->updateViewer(); } -void TIGLCreatorDocument::drawWingComponentSegmentPoints() +void TIGLCreatorDocument::drawWingComponentSegmentPoints(const QString& Uid) { - QString csUid = dlgGetWingComponentSegmentSelection(); + QString csUid = dlgGetWingComponentSegmentSelection(Uid); if (csUid == "") { return; } @@ -2235,9 +2403,10 @@ void TIGLCreatorDocument::drawWingComponentSegmentPoints() } } -void TIGLCreatorDocument::drawWingShells() +void TIGLCreatorDocument::drawWingShells(const QString& Uid) { - QString wingUid = dlgGetWingSelection(); + QString wingUid = dlgGetWingSelection(Uid); + try { tigl::CCPACSWing& wing = GetConfiguration().GetWing(wingUid.toStdString()); drawWingShells(wing); @@ -2247,9 +2416,9 @@ void TIGLCreatorDocument::drawWingShells() } } -void TIGLCreatorDocument::drawWingStructure() +void TIGLCreatorDocument::drawWingStructure(const QString& Uid) { - QString csUid = dlgGetWingComponentSegmentSelection(); + QString csUid = dlgGetWingComponentSegmentSelection(Uid); if (csUid == "") { return; } @@ -2284,10 +2453,25 @@ void TIGLCreatorDocument::drawWingStructure() return; } - app->getScene()->deleteAllObjects(); + auto objects = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(Uid.toStdString()); + for (auto& obj : objects) { + app->getScene()->getContext()->Remove(obj, Standard_False); + app->getScene()->GetShapeManager().removeObject(obj); + } + + removeWingFlaps(Uid); + tigl::CCPACSWing& wing = GetConfiguration().GetWing(Uid.toStdString()); // display component segment shape with transparency - app->getScene()->displayShape(cs.GetLoft(), true, Quantity_NOC_ShapeCol, 0.5); + auto cs_shape = app->getScene()->displayShape(cs.GetLoft(), true, Quantity_NOC_ShapeCol, 0.5); + app->getScene()->GetShapeManager().addObject(Uid.toStdString(), cs_shape); + PNamedShape mirroredLoft = wing.GetMirroredLoft(cs.GetLoft()); + if (mirroredLoft) + { + auto shape = app->getScene()->displayShape(mirroredLoft, true, Quantity_NOC_ShapeCol, 0.5); + app->getScene()->GetShapeManager().addObject(Uid.toStdString(), shape); + + } const tigl::CCPACSWingCSStructure& structure = *cs.GetStructure(); @@ -2295,14 +2479,35 @@ void TIGLCreatorDocument::drawWingStructure() for (int ispar = 1; ispar <= structure.GetSparSegmentCount(); ++ispar) { const tigl::CCPACSWingSparSegment& spar = structure.GetSparSegment(ispar); TopoDS_Shape sparGeom = spar.GetSparGeometry(); - app->getScene()->displayShape(sparGeom, true, Quantity_NOC_RED); + auto spar_shape = app->getScene()->displayShape(sparGeom, true, Quantity_NOC_RED); + app->getScene()->GetShapeManager().addObject(Uid.toStdString(), spar_shape); + + PNamedShape loftNamed(new CNamedShape(sparGeom, Uid.toStdString())); + PNamedShape mirroredLoft = wing.GetMirroredLoft(loftNamed); + if (mirroredLoft) + { + auto shape = app->getScene()->displayShape(mirroredLoft, true, Quantity_NOC_RED); + app->getScene()->GetShapeManager().addObject(Uid.toStdString(), shape); + + } } // draw ribs for (int irib = 1; irib <= structure.GetRibsDefinitionCount(); ++irib) { const tigl::CCPACSWingRibsDefinition& rib = structure.GetRibsDefinition(irib); TopoDS_Shape ribGeom = rib.GetRibsGeometry(); - app->getScene()->displayShape(ribGeom, true, Quantity_NOC_RED); + auto rib_shape = app->getScene()->displayShape(ribGeom, true, Quantity_NOC_RED); + app->getScene()->GetShapeManager().addObject(Uid.toStdString(), rib_shape); + + PNamedShape loftNamed(new CNamedShape(ribGeom, Uid.toStdString())); + tigl::CCPACSWing& wing = GetConfiguration().GetWing(Uid.toStdString()); + PNamedShape mirroredLoft = wing.GetMirroredLoft(loftNamed); + if (mirroredLoft) + { + auto shape = app->getScene()->displayShape(mirroredLoft, true, Quantity_NOC_RED); + app->getScene()->GetShapeManager().addObject(Uid.toStdString(), shape); + + } } } catch (tigl::CTiglError& err) { @@ -2370,9 +2575,9 @@ void TIGLCreatorDocument::drawRotorProfiles() } } -void TIGLCreatorDocument::drawRotorBladeOverlayProfilePoints() +void TIGLCreatorDocument::drawRotorBladeOverlayProfilePoints(const QString& Uid) { - QString wingUid = dlgGetRotorBladeSelection(); + QString wingUid = dlgGetRotorBladeSelection(Uid); try { tigl::CCPACSWing& wing = GetConfiguration().GetWing(wingUid.toStdString()); drawWingOverlayProfilePoints(wing); @@ -2395,9 +2600,9 @@ void TIGLCreatorDocument::drawRotorBladeGuideCurves() } } -void TIGLCreatorDocument::drawRotorBlade() +void TIGLCreatorDocument::drawRotorBlade(const QString& Uid) { - QString wingUid = dlgGetRotorBladeSelection(); + QString wingUid = dlgGetRotorBladeSelection(Uid); try { tigl::CCPACSWing& wing = GetConfiguration().GetWing(wingUid.toStdString()); drawWing(wing); @@ -2407,9 +2612,9 @@ void TIGLCreatorDocument::drawRotorBlade() } } -void TIGLCreatorDocument::drawRotorBladeTriangulation() +void TIGLCreatorDocument::drawRotorBladeTriangulation(const QString& Uid) { - QString wingUid = dlgGetRotorBladeSelection(); + QString wingUid = dlgGetRotorBladeSelection(Uid); try { tigl::CCPACSWing& wing = GetConfiguration().GetWing(wingUid.toStdString()); drawWingTriangulation(wing); @@ -2419,9 +2624,9 @@ void TIGLCreatorDocument::drawRotorBladeTriangulation() } } -void TIGLCreatorDocument::drawRotorBladeSamplePoints() +void TIGLCreatorDocument::drawRotorBladeSamplePoints(const QString& Uid) { - QString wingUid = dlgGetRotorBladeSelection(); + QString wingUid = dlgGetRotorBladeSelection(Uid); try { tigl::CCPACSWing& wing = GetConfiguration().GetWing(wingUid.toStdString()); drawWingSamplePoints(wing); @@ -2431,9 +2636,9 @@ void TIGLCreatorDocument::drawRotorBladeSamplePoints() } } -void TIGLCreatorDocument::drawFusedRotorBlade() +void TIGLCreatorDocument::drawFusedRotorBlade(const QString& Uid) { - QString wingUid = dlgGetRotorBladeSelection(); + QString wingUid = dlgGetRotorBladeSelection(Uid); try { tigl::CCPACSWing& wing = GetConfiguration().GetWing(wingUid.toStdString()); drawFusedWing(wing); @@ -2443,9 +2648,9 @@ void TIGLCreatorDocument::drawFusedRotorBlade() } } -void TIGLCreatorDocument::drawRotorBladeComponentSegment() +void TIGLCreatorDocument::drawRotorBladeComponentSegment(const QString& Uid) { - QString csUid = dlgGetRotorBladeComponentSegmentSelection(); + QString csUid = dlgGetRotorBladeComponentSegmentSelection(Uid); if (csUid == "") { return; } @@ -2462,9 +2667,9 @@ void TIGLCreatorDocument::drawRotorBladeComponentSegment() } } -void TIGLCreatorDocument::drawRotorBladeComponentSegmentPoints() +void TIGLCreatorDocument::drawRotorBladeComponentSegmentPoints(const QString& Uid) { - QString csUid = dlgGetRotorBladeComponentSegmentSelection(); + QString csUid = dlgGetRotorBladeComponentSegmentSelection(Uid); if (csUid == "") { return; } @@ -2476,9 +2681,9 @@ void TIGLCreatorDocument::drawRotorBladeComponentSegmentPoints() } } -void TIGLCreatorDocument::drawRotorBladeShells() +void TIGLCreatorDocument::drawRotorBladeShells(const QString& Uid) { - QString wingUid = dlgGetRotorBladeSelection(); + QString wingUid = dlgGetRotorBladeSelection(Uid); try { tigl::CCPACSWing& wing = GetConfiguration().GetWing(wingUid.toStdString()); drawWingShells(wing); @@ -2551,9 +2756,9 @@ void TIGLCreatorDocument::drawRotor() drawRotorByUID(rotorUid); } -void TIGLCreatorDocument::drawRotorDisk() +void TIGLCreatorDocument::drawRotorDisk(const QString& uid) { - QString rotorUid = dlgGetRotorSelection(); + QString rotorUid = dlgGetRotorSelection(uid); if (rotorUid == "") { return; } @@ -2570,9 +2775,9 @@ void TIGLCreatorDocument::drawRotorDisk() app->getScene()->displayShape(rotorDisk, true, Quantity_NOC_RotorCol, 0.9); } -void TIGLCreatorDocument::showRotorProperties() +void TIGLCreatorDocument::showRotorProperties(const QString& uid) { - QString rotorUid = dlgGetRotorSelection(); + QString rotorUid = dlgGetRotorSelection(uid); if (rotorUid == "") { return; } @@ -2746,6 +2951,8 @@ void TIGLCreatorDocument::drawAirfoil(tigl::CCPACSWingProfile& profile) void TIGLCreatorDocument::drawWingOverlayProfilePoints(tigl::CCPACSWing& wing) { START_COMMAND() + + drawWing(QString::fromStdString(wing.GetUID())); for (int i = 1; i <= wing.GetSegmentCount(); i++) { // Get segment @@ -2764,7 +2971,8 @@ void TIGLCreatorDocument::drawWingOverlayProfilePoints(tigl::CCPACSWing& wing) gp_Pnt pnt = j.Get_gp_Pnt(); pnt = innerT.Transform(pnt); - app->getScene()->displayPoint(pnt, "", Standard_False, 0.0, 0.0, 0.0, 2.0); + auto point = app->getScene()->displayPoint(pnt, "", Standard_False, 0.0, 0.0, 0.0, 2.0); + app->getScene()->GetShapeManager().addObject(wing.GetUID(), point); } // Get outer profile point list @@ -2782,9 +2990,11 @@ void TIGLCreatorDocument::drawWingOverlayProfilePoints(tigl::CCPACSWing& wing) gp_Pnt pnt = j.Get_gp_Pnt(); pnt = outerT.Transform(pnt); - app->getScene()->displayPoint(pnt, "", Standard_False, 0.0, 0.0, 0.0, 2.0); + auto point = app->getScene()->displayPoint(pnt, "", Standard_False, 0.0, 0.0, 0.0, 2.0); + app->getScene()->GetShapeManager().addObject(wing.GetUID(), point); } } + app->getScene()->updateViewer(); } /* @@ -2810,14 +3020,25 @@ void TIGLCreatorDocument::drawWingTriangulation(tigl::CCPACSWing& wing) START_COMMAND() //clear screen - app->getScene()->deleteAllObjects(); + removeWing(QString::fromStdString(wing.GetUID())); + removeWingFlaps(QString::fromStdString(wing.GetUID())); //we do not fuse segments anymore but build it from scratch with the profiles const TopoDS_Shape& fusedWing = wing.GetLoft()->Shape(); TopoDS_Compound compound; createShapeTriangulation(fusedWing, compound); - app->getScene()->displayShape(compound, true, getDefaultShapeColor()); + auto shape = app->getScene()->displayShape(compound, true, getDefaultShapeColor()); + app->getScene()->GetShapeManager().addObject(wing.GetUID(), shape); + + PNamedShape loftNamed(new CNamedShape(compound, wing.GetUID().c_str())); + PNamedShape mirroredLoft = wing.GetMirroredLoft(loftNamed); + if (mirroredLoft) + { + auto shape = app->getScene()->displayShape(mirroredLoft, true, getDefaultShapeSymmetryColor()); + app->getScene()->GetShapeManager().addObject(wing.GetUID(), shape); + } + app->getScene()->updateViewer(); } /* @@ -2840,28 +3061,41 @@ void TIGLCreatorDocument::drawWingSamplePoints(tigl::CCPACSWing& wing) return; } - app->getScene()->deleteAllObjects(); + removeWing(QString::fromStdString(wing.GetUID())); + removeWingFlaps(QString::fromStdString(wing.GetUID())); for (int segmentIndex = 1; segmentIndex <= wing.GetSegmentCount(); segmentIndex++) { // Draw segment loft auto& segment = (tigl::CCPACSWingSegment&)wing.GetSegment(segmentIndex); - app->getScene()->displayShape(segment.GetLoft(), true, getDefaultShapeColor()); + auto shape = app->getScene()->displayShape(segment.GetLoft(), true, getDefaultShapeColor()); + app->getScene()->GetShapeManager().addObject(wing.GetUID(), shape); + PNamedShape mirroredLoft = wing.GetMirroredLoft(segment.GetLoft()); + if (mirroredLoft) + { + auto shape = app->getScene()->displayShape(mirroredLoft, true, getDefaultShapeSymmetryColor()); + app->getScene()->GetShapeManager().addObject(wing.GetUID(), shape); + + } + // Draw some points on the wing segment for (double eta = 0.0; eta <= 1.0; eta += 0.1) { for (double xsi = 0.0; xsi <= 1.0; xsi += 0.1) { double x, y, z; tiglWingGetUpperPoint(m_cpacsHandle, wingIndex, segmentIndex, eta, xsi, &x, &y, &z); - app->getScene()->displayPoint(gp_Pnt(x, y, z), "", Standard_False, 0., 0., 0., 1.); + auto point = app->getScene()->displayPoint(gp_Pnt(x, y, z), "", Standard_False, 0., 0., 0., 1.); + app->getScene()->GetShapeManager().addObject(wing.GetUID(), point); tiglWingGetLowerPoint(m_cpacsHandle, wingIndex, segmentIndex, eta, xsi, &x, &y, &z); - app->getScene()->displayPoint(gp_Pnt(x, y, z), "", Standard_False, 0., 0., 0., 1.); + point = app->getScene()->displayPoint(gp_Pnt(x, y, z), "", Standard_False, 0., 0., 0., 1.); + app->getScene()->GetShapeManager().addObject(wing.GetUID(), point); } } } + app->getScene()->updateViewer(); } /* @@ -2932,10 +3166,25 @@ void TIGLCreatorDocument::drawWingComponentSegmentPoint(const std::string& csUID void TIGLCreatorDocument::drawWingShells(tigl::CCPACSWing& wing) { START_COMMAND() - app->getScene()->deleteAllObjects(); - app->getScene()->displayShape(wing.GetUpperShape(), true, Quantity_NOC_GREEN); - app->getScene()->displayShape(wing.GetLowerShape(), true, Quantity_NOC_RED); + removeWing(QString::fromStdString(wing.GetUID())); + removeWingFlaps(QString::fromStdString(wing.GetUID())); + + TopoDS_Shape shapes[2] = {wing.GetUpperShape(), wing.GetLowerShape()}; + Quantity_NameOfColor colors[2] = {Quantity_NOC_GREEN, Quantity_NOC_RED}; + for (int i = 0; i < 2; ++i) { + + auto shape = app->getScene()->displayShape(shapes[i], true, colors[i]); + app->getScene()->GetShapeManager().addObject(wing.GetUID(), shape); + + PNamedShape loftNamed(new CNamedShape(shapes[i], wing.GetUID().c_str())); + PNamedShape mirroredLoft = wing.GetMirroredLoft(loftNamed); + if (mirroredLoft) { + auto shape = app->getScene()->displayShape(mirroredLoft, true, colors[i]); + app->getScene()->GetShapeManager().addObject(wing.GetUID(), shape); + } + } + app->getScene()->getViewer()->Update(); } /* diff --git a/TIGLCreator/src/TIGLCreatorDocument.h b/TIGLCreator/src/TIGLCreatorDocument.h index 57671c70d..5f67b6007 100644 --- a/TIGLCreator/src/TIGLCreatorDocument.h +++ b/TIGLCreator/src/TIGLCreatorDocument.h @@ -93,44 +93,44 @@ public slots: // Wing slots void drawWingProfiles(); - void drawWing(); - void drawWingOverlayProfilePoints(); - void drawWingGuideCurves(); - void drawWingTriangulation(); - void drawWingSamplePoints(); - void drawFusedWing(); - void drawWingComponentSegment(); - void drawWingComponentSegmentPoints(); - void drawWingShells(); - void drawWingFlaps(); - void drawWingStructure(); + void drawWing(const QString& Uid=nullptr); + void drawWingOverlayProfilePoints(const QString& wingUID=nullptr); + void drawWingGuideCurves(const QString& wingUID=nullptr); + void drawWingTriangulation(const QString& wingUID=nullptr); + void drawWingSamplePoints(const QString& wingUID=nullptr); + void drawFusedWing(const QString& wingUID=nullptr); + void drawWingComponentSegment(const QString& wingUID=nullptr); + void drawWingComponentSegmentPoints(const QString& wingUID=nullptr); + void drawWingShells(const QString& wingUID=nullptr); + void drawWingFlaps(const QString& wingUID=nullptr); + void drawWingStructure(const QString& wingUID=nullptr); // Fuselage slots void drawFuselageProfiles(); - void drawFuselage(); - void drawFuselageTriangulation(); - void drawFuselageSamplePoints(); - void drawFuselageSamplePointsAngle(); - void drawFusedFuselage(); - void drawFuselageGuideCurves(); + void drawFuselage(const QString& Uid=nullptr); + void drawFuselageTriangulation(const QString& Uid=nullptr); + void drawFuselageSamplePoints(const QString& Uid=nullptr); + void drawFuselageSamplePointsAngle(const QString& Uid=nullptr); + void drawFusedFuselage(const QString& Uid=nullptr); + void drawFuselageGuideCurves(const QString& Uid=nullptr); // Rotor blade slots void drawRotorProfiles(); - void drawRotorBlade(); - void drawRotorBladeOverlayProfilePoints(); + void drawRotorBlade(const QString& uid=nullptr); + void drawRotorBladeOverlayProfilePoints(const QString& uid=nullptr); void drawRotorBladeGuideCurves(); - void drawRotorBladeTriangulation(); - void drawRotorBladeSamplePoints(); - void drawFusedRotorBlade(); - void drawRotorBladeComponentSegment(); - void drawRotorBladeComponentSegmentPoints(); - void drawRotorBladeShells(); + void drawRotorBladeTriangulation(const QString& uid=nullptr); + void drawRotorBladeSamplePoints(const QString& uid=nullptr); + void drawFusedRotorBlade(const QString& uid=nullptr); + void drawRotorBladeComponentSegment(const QString& uid=nullptr); + void drawRotorBladeComponentSegmentPoints(const QString& uid=nullptr); + void drawRotorBladeShells(const QString& uid=nullptr); // Rotorcraft slots - void drawRotorByUID(const QString& uid); + void drawRotorByUID(const QString& uid=nullptr); void drawRotor(); - void drawRotorDisk(); - void showRotorProperties(); + void drawRotorDisk(const QString& uid=nullptr); + void showRotorProperties(const QString& uid=nullptr); // TIGL slots void exportAsIges(); @@ -163,22 +163,22 @@ private slots: // Wing selection dialogs QString dlgGetWingOrRotorBladeSelection(); - QString dlgGetWingSelection(); - QString dlgGetWingComponentSegmentSelection(); + QString dlgGetWingSelection(const QString& wingUID=nullptr); + QString dlgGetWingComponentSegmentSelection(const QString& wingUID=nullptr); QString dlgGetWingSegmentSelection(); QString dlgGetWingProfileSelection(); // Rotor selection dialogs - QString dlgGetRotorSelection(); + QString dlgGetRotorSelection(const QString& rotorUid=nullptr); // Rotor Blade selection dialogs - QString dlgGetRotorBladeSelection(); - QString dlgGetRotorBladeComponentSegmentSelection(); + QString dlgGetRotorBladeSelection(const QString& rotorBladeUid=nullptr); + QString dlgGetRotorBladeComponentSegmentSelection(const QString& rotorBladeCompSegUid=nullptr); QString dlgGetRotorBladeSegmentSelection(); QString dlgGetRotorProfileSelection(); // Fuselage selection dialogs - QString dlgGetFuselageSelection(); + QString dlgGetFuselageSelection(const QString& Uid=nullptr); QString dlgGetFuselageSegmentSelection(); QString dlgGetFuselageProfileSelection(); @@ -216,6 +216,9 @@ private slots: void drawWingShells(tigl::CCPACSWing& wing); bool drawWingFlaps(tigl::CCPACSWing& wing); void drawWingFlap(const QString& flapUID); + void removeWing(const QString& Uid); + void removeWingFlaps(const QString& Uid); + void removeFuselage(const QString& Uid); void createShapeTriangulation(const class TopoDS_Shape& shape, class TopoDS_Compound& compound); diff --git a/TIGLCreator/src/TIGLCreatorWindow.cpp b/TIGLCreator/src/TIGLCreatorWindow.cpp index fd20e6da8..4a1e0429c 100644 --- a/TIGLCreator/src/TIGLCreatorWindow.cpp +++ b/TIGLCreator/src/TIGLCreatorWindow.cpp @@ -51,6 +51,7 @@ #include "TIGLCreatorLoggerHTMLDecorator.h" #include "TIGLCreatorScreenshotDialog.h" #include "TIGLCreatorScopedCommand.h" +#include "DrawOptionsActions.h" #include "tigl_config.h" #include "api/tigl_version.h" #include "TIGLCreatorMaterials.h" @@ -192,6 +193,7 @@ TIGLCreatorWindow::TIGLCreatorWindow() connectSignals(); createMenus(); + setupDrawMenus(); updateMenus(); loadSettings(); @@ -906,57 +908,6 @@ void TIGLCreatorWindow::connectConfiguration() return; } - // CPACS Wing Actions - connect(drawWingProfilesAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawWingProfiles())); - connect(drawWingOverlayCPACSProfilePointsAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawWingOverlayProfilePoints())); - connect(drawWingGuideCurvesAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawWingGuideCurves())); - connect(drawWingsAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawWing())); - connect(drawWingTriangulationAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawWingTriangulation())); - connect(drawWingSamplePointsAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawWingSamplePoints())); - connect(drawFusedWingAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawFusedWing())); - connect(drawWingComponentSegmentAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawWingComponentSegment())); - connect(drawWingCSPointAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawWingComponentSegmentPoints())); - connect(drawWingShellAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawWingShells())); - connect(drawWingStructureAction, SIGNAL(triggered(bool)), cpacsConfiguration, SLOT(drawWingStructure())); - connect(drawWingFlapsAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawWingFlaps())); - - // CPACS Aircraft Actions - connect(showAllWingsAndFuselagesAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawConfiguration())); - connect(showAllWingsAndFuselageDuctCutoutsAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawConfigurationWithDuctCutouts())); - connect(showAllWingsAndFuselagesSurfacePointsAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawAllFuselagesAndWingsSurfacePoints())); - connect(drawFusedAircraftAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawFusedAircraft())); - connect(drawIntersectionAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawIntersectionLine())); - connect(showFusedAirplaneTriangulation, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawFusedAircraftTriangulation())); - connect(drawFarFieldAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawFarField())); - connect(drawSystemsAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawSystems())); - connect(drawComponentAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawComponent())); - connect(drawControlPointNetAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawControlPointNet())); - - // CPACS Fuselage Actions - connect(drawFuselageProfilesAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawFuselageProfiles())); - connect(drawFuselageAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawFuselage())); - connect(drawFuselageTriangulationAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawFuselageTriangulation())); - connect(drawFuselageSamplePointsAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawFuselageSamplePoints())); - connect(drawFuselageSamplePointsAngleAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawFuselageSamplePointsAngle())); - connect(drawFusedFuselageAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawFusedFuselage())); - connect(drawFuselageGuideCurvesAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawFuselageGuideCurves())); - - // CPACS RotorBlade Actions - connect(drawRotorProfilesAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawRotorProfiles())); - connect(drawRotorBladeOverlayCPACSProfilePointsAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawRotorBladeOverlayProfilePoints())); - connect(drawRotorBladeGuideCurvesAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawRotorBladeGuideCurves())); - connect(drawRotorBladesAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawRotorBlade())); - connect(drawRotorBladeTriangulationAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawRotorBladeTriangulation())); - connect(drawRotorBladeSamplePointsAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawRotorBladeSamplePoints())); - connect(drawFusedRotorBladeAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawFusedRotorBlade())); - connect(drawRotorBladeComponentSegmentAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawRotorBladeComponentSegment())); - connect(drawRotorBladeCSPointAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawRotorBladeComponentSegmentPoints())); - connect(drawRotorBladeShellAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawRotorBladeShells())); - - // CPACS Rotorcraft Actions - connect(drawRotorsAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(drawRotor())); - connect(showRotorPropertiesAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(showRotorProperties())); - // Export functions connect(tiglExportFusedIgesAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(exportFusedAsIges())); connect(tiglExportIgesAction, SIGNAL(triggered()), cpacsConfiguration, SLOT(exportAsIges())); @@ -1207,10 +1158,6 @@ void TIGLCreatorWindow::updateMenus() } } catch(tigl::CTiglError& ){} - drawFarFieldAction->setEnabled(hasFarField); - showAllWingsAndFuselageDuctCutoutsAction->setEnabled(hasDucts); - drawSystemsAction->setEnabled(hasACSystems); - drawRotorsAction->setEnabled(nRotors > 0); menuRotorcraft->setEnabled((nRotors > 0) || (nRotorBlades > 0)); menuRotorBlades->setEnabled(nRotorBlades > 0); menuWings->setEnabled(nWings - nRotorBlades > 0); @@ -1470,3 +1417,64 @@ void TIGLCreatorWindow::onSetMaterialRequested(const QString &m) myScene->setObjectsMaterial(it->second); } } + + +void TIGLCreatorWindow::populateDrawMenu( + QMenu* menu, + const std::vector& actions, + bool needsUid) +{ + for (const auto& action : actions) { + QAction* qa = new QAction(action.label, this); + + connect(qa, &QAction::triggered, this, + [this, action, needsUid]() { + QString uid; + if (needsUid && treeWidget) { + uid = treeWidget->getSelectedUID(); + } + action.handler(cpacsConfiguration, uid); + }); + + menu->addAction(qa); + } +} + +void TIGLCreatorWindow::setupDrawMenus() +{ + // Aircraft (plane-level, no UID needed) + populateDrawMenu( + menuAircraft, + getPlaneDrawOptionsActions(), + false + ); + + // Wings + populateDrawMenu( + menuWings, + getWingDrawOptionsActions(), + true + ); + + // Fuselages + populateDrawMenu( + menuFuselages, + getFuselageDrawOptionsActions(), + true + ); + + // Rotor blades + populateDrawMenu( + menuRotorBlades, + getRotorBladeDrawOptionsActions(), + true + ); + + // Rotors + populateDrawMenu( + menuRotorcraft, + getRotorDrawOptionsActions(), + true + ); +} + diff --git a/TIGLCreator/src/TIGLCreatorWindow.h b/TIGLCreator/src/TIGLCreatorWindow.h index a09145fe2..73af41831 100644 --- a/TIGLCreator/src/TIGLCreatorWindow.h +++ b/TIGLCreator/src/TIGLCreatorWindow.h @@ -30,6 +30,7 @@ #include "CSharedPtr.h" #include "ui_TIGLCreatorWindow.h" +#include "DrawOptionsActions.h" #include "ModificatorModel.h" @@ -141,6 +142,9 @@ private slots: void closeEvent(QCloseEvent* event) override; bool deleteEnvVar(const char* varname); + void populateDrawMenu(QMenu* menu, const std::vector& actions, bool needsUid); + void setupDrawMenus(); + QAction *recentFileActions[MaxRecentFiles]; // The OpenCASCADE context; diff --git a/TIGLCreator/src/TIGLCreatorWindow.ui b/TIGLCreator/src/TIGLCreatorWindow.ui index 5344bcde5..efa9733fd 100644 --- a/TIGLCreator/src/TIGLCreatorWindow.ui +++ b/TIGLCreator/src/TIGLCreatorWindow.ui @@ -162,46 +162,16 @@ Aircraft - - - - - - - - - - Wings - - - - - - - - - - - - - Fuselages - - - - - - - @@ -214,17 +184,6 @@ Rotor blades - - - - - - - - - - - @@ -519,272 +478,6 @@ Ctrl+V - - - Show the complete Aircraft - - - Show all Fuselages and Wings - - - Show all Fuselages and Wings - - - - - Show sample Surface points on Fuselage and Wings - - - Show sample Surface points on Fuselages and Wings - - - Show sample Surface points on Fuselages and Wings - - - - - Show the complete Aircraft fused (slow) - - - Show the complete Aircraft fused - - - - - Show Wing - - - Show a wing only - - - - - Show Wing Profiles - - - Show the profiles of a wing - - - Show the profiles of a wing - - - - - Show Wing overlay profile points - - - Show the points of a wing profile - - - - - Show Wing triangulation - - - Shows the triangulation of a wing - - - - - Show Sample Wing points - - - Show sample points on a wing - - - - - - - - Show Fused Wing - - - Shows a fused wing - - - Shows a fused wing - - - - - Show Wing Component Segment - - - Shows a wing component segment - - - Shows a wing component segment - - - - - Show Rotor Blade - - - Show a rotor blade only - - - - - Show Rotor Profiles - - - Show the profiles of a rotor - - - Show the profiles of a rotor - - - - - Show Rotor Blade overlay profile points - - - Show the points of a rotor blade profile - - - - - Show Rotor Blade triangulation - - - Shows the triangulation of a rotor blade - - - - - Show Sample Rotor Blade points - - - Show sample points on a rotor blade - - - - - - - - Show Fused Rotor Blade - - - Shows a fused rotor blade - - - Shows a fused rotor blade - - - - - Show Rotor Blade Component Segment - - - Shows a rotor blade component segment - - - Shows a rotor blade component segment - - - - - Show Rotor Blade Component Segment Point - - - - - Show Rotor Blade Shells - - - - - Show all Rotors, Wings and Fuselages - - - Show all Rotors, Wings and Fuselages - - - - - Show a Rotor - - - Show only one rotor - - - - - Show Rotor Properties... - - - Show properties of a rotor - - - - - Show Fuselage - - - Shows a fuselage - - - Shows a fuselage. - - - - - Show Fuselage Profiles - - - Show the profiles of a fuselage - - - Show the profiles of a fuselage - - - - - Show Fuselage triangulation - - - Shows the triangulation of a fuselage - - - Shows the triangulation of a fuselage. - - - - - Show Sample Fuselage points - - - Show sample points on a fuselage - - - Show sample points on a fuselage. - - - - - Show Sample Fuselage point at Angle - - - Show sample point on a fuselage at user defined angle and eta = 0.5 - - - Show sample point on a fuselage at user defined angle and eta = 0.5 - - - - - Show Fused Fuselage - - - Show a fused fuselage - - - Show a fused fuselage. - - Export Configuration @@ -1202,16 +895,6 @@ Ctrl+W - - - Show Intersection Line - - - - - Show fused Airplane Triangulation (slow) - - @@ -1243,11 +926,6 @@ Settings - - - Show Wing Shells - - Export Model as structed IGES @@ -1269,11 +947,6 @@ Export Fuselage - - - Show Wing Component Segment Point - - Export fused Configuration (slow) @@ -1284,14 +957,6 @@ Export Configuration (not fused) - - - false - - - Draw Far Field - - Export fused/trimmed Configuration @@ -1312,21 +977,6 @@ Export Fused Configuration (slow) - - - Show Wing Guide Curves - - - - - Show Rotor Blade Guide Curves - - - - - Show Fuselage Guide Curves - - Export Wing Curves @@ -1366,16 +1016,6 @@ Draw Vector - - - Draw Systems - - - - - Show Wing Structure - - Export Configuration @@ -1402,16 +1042,6 @@ false - - - Draw any Component - - - - - Draw Control Point Net - - Select all @@ -1420,22 +1050,6 @@ Ctrl+A - - - Show Wing Flaps - - - - - Show the complete Aircraft with Duct Cutouts - - - Show all Fuselages and Wings with Duct Cutouts - - - Show all Fuselages and Wings with Duct Cutouts - - diff --git a/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.cpp b/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.cpp index 172ab7f1a..e62ccfeae 100644 --- a/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.cpp +++ b/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.cpp @@ -31,6 +31,8 @@ #include "../TIGLCreatorContext.h" #include "ui_ModificatorDisplayOptionsWidget.h" #include +#include "TIGLCreatorWindow.h" +#include "../DrawOptionsActions.h" #define BTN_STYLE "#%2 {background-color: %1; color: black; border: 1px solid black; border-radius: 5px;} #%2:hover {border: 1px solid white;}" @@ -56,12 +58,21 @@ 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 &))); connect(buttonColorChoser, SIGNAL(clicked()), this, SLOT(onColorChosen())); connect(buttonResetOptions, SIGNAL(clicked()), this, SLOT(onResetOptions())); + + // for (const auto& action : getDrawOptionsActions()) { + // QAction* act = findChild(action.name); + // if (act) { + // connect(act, &QAction::triggered, this, [this, action]() { + // action.handler(currentUid); // Pass the UID + // }); + // } + // } } ModificatorDisplayOptionsWidget::~ModificatorDisplayOptionsWidget() = default; @@ -81,21 +92,24 @@ 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->labelDrawOptions->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) { @@ -105,21 +119,21 @@ 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->labelDrawOptions->setVisible(true); + ui->drawOptionsCombo->setVisible(true); } - - // get current values auto &sm = context->GetShapeManager(); - if (sm.HasShapeEntry(uid)) { - auto objs = sm.GetIObjectsFromShapeName(uid); + if (sm.HasShapeEntry(uid.toStdString())) { + auto objs = sm.GetIObjectsFromShapeName(uid.toStdString()); if (objs.empty()) { - LOG(WARNING) << "No objects found for shape with uid " << uid; + LOG(WARNING) << "No objects found for shape with uid " << uid.toStdString(); return; } auto obj = objs[0]; @@ -143,6 +157,22 @@ void ModificatorDisplayOptionsWidget::setFromItem(cpcr::CPACSTreeItem* item, TIG materialCombo->setCurrentIndex(0); } + else if (comp->GetComponentType() == TIGL_COMPONENT_PLANE) { + if (ui) { + ui->infoLabel->setVisible(true); + ui->labelTransparency->setVisible(false); + ui->transparencySlider->setVisible(false); + ui->labelRenderingMode->setVisible(false); + ui->renderingModeCombo->setVisible(false); + ui->buttonColorChoser->setVisible(false); + ui->labelColor->setVisible(false); + ui->labelMaterial->setVisible(false); + ui->materialCombo->setVisible(false); + ui->buttonResetOptions->setVisible(false); + ui->labelDrawOptions->setVisible(true); + ui->drawOptionsCombo->setVisible(true); + } + } } } else { @@ -153,13 +183,111 @@ 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->labelDrawOptions->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) { + drawCallbacks.clear(); + ui->drawOptionsCombo->clear(); + for (const auto& action : getWingDrawOptionsActions()) { + ui->drawOptionsCombo->addItem(tr(action.label.toUtf8())); + drawCallbacks.push_back([this, action, uid, doc]() { + action.handler(doc, uid); + }); + } + connect(ui->drawOptionsCombo, QOverload::of(&QComboBox::activated), this, + [this](int idx) { + if (idx >= 0 && idx < static_cast(drawCallbacks.size()) && drawCallbacks[idx]) { + drawCallbacks[idx](); + } + }, Qt::UniqueConnection); + } + + if (type == TIGL_COMPONENT_FUSELAGE) { + drawCallbacks.clear(); + ui->drawOptionsCombo->clear(); + for (const auto& action : getFuselageDrawOptionsActions()) { + ui->drawOptionsCombo->addItem(tr(action.label.toUtf8())); + drawCallbacks.push_back([this, action, uid, doc]() { + action.handler(doc, uid); + }); + } + connect(ui->drawOptionsCombo, QOverload::of(&QComboBox::activated), this, + [this](int idx) { + if (idx >= 0 && idx < static_cast(drawCallbacks.size()) && drawCallbacks[idx]) { + drawCallbacks[idx](); + } + }, Qt::UniqueConnection); + } + + if (type == TIGL_COMPONENT_PLANE) { + drawCallbacks.clear(); + ui->drawOptionsCombo->clear(); + for (const auto& action : getPlaneDrawOptionsActions()) { + ui->drawOptionsCombo->addItem(tr(action.label.toUtf8())); + drawCallbacks.push_back([this, action, uid, doc]() { + action.handler(doc, uid); + }); + } + connect(ui->drawOptionsCombo, QOverload::of(&QComboBox::activated), this, + [this](int idx) { + if (idx >= 0 && idx < static_cast(drawCallbacks.size()) && drawCallbacks[idx]) { + drawCallbacks[idx](); + } + }, Qt::UniqueConnection); + } + + if (type == TIGL_COMPONENT_ROTORBLADE) { + drawCallbacks.clear(); + ui->drawOptionsCombo->clear(); + for (const auto& action : getRotorBladeDrawOptionsActions()) { + ui->drawOptionsCombo->addItem(tr(action.label.toUtf8())); + drawCallbacks.push_back([this, action, uid, doc]() { + action.handler(doc, uid); + }); + } + connect(ui->drawOptionsCombo, QOverload::of(&QComboBox::activated), this, + [this](int idx) { + if (idx >= 0 && idx < static_cast(drawCallbacks.size()) && drawCallbacks[idx]) { + drawCallbacks[idx](); + } + }, Qt::UniqueConnection); + } + + if (type == TIGL_COMPONENT_ROTOR) { + drawCallbacks.clear(); + ui->drawOptionsCombo->clear(); + for (const auto& action : getRotorDrawOptionsActions()) { + ui->drawOptionsCombo->addItem(tr(action.label.toUtf8())); + drawCallbacks.push_back([this, action, uid, doc]() { + action.handler(doc, uid); + }); + } + connect(ui->drawOptionsCombo, QOverload::of(&QComboBox::activated), this, + [this](int idx) { + if (idx >= 0 && idx < static_cast(drawCallbacks.size()) && drawCallbacks[idx]) { + drawCallbacks[idx](); + } + }, Qt::UniqueConnection); + } + + } + } + } bool ModificatorDisplayOptionsWidget::apply() @@ -418,9 +546,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(); } diff --git a/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.h b/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.h index cb6742a71..1f9154b63 100644 --- a/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.h +++ b/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.h @@ -35,6 +35,9 @@ class QButtonGroup; class QPushButton; class QComboBox; class QColor; +// callbacks used for draw options (avoid direct QAction dependency) +#include +#include class ModificatorDisplayOptionsWidget : public CpacsEditorBase { @@ -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> drawCallbacks; + cpcr::CPACSTreeItem* currentItem{nullptr}; TIGLCreatorDocument* currentDoc{nullptr}; TIGLCreatorContext* currentContext{nullptr}; diff --git a/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.ui b/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.ui index 863c7d10d..c15408140 100644 --- a/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.ui +++ b/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.ui @@ -66,7 +66,7 @@ - + Color: @@ -107,22 +107,26 @@ - - - - Draw Options: - - - false - - - - - - false - - + + + + + Draw Options: + + + false + + + + + + + false + + + + diff --git a/src/wing/CCPACSWing.cpp b/src/wing/CCPACSWing.cpp index 09347ebea..6eebe56ae 100644 --- a/src/wing/CCPACSWing.cpp +++ b/src/wing/CCPACSWing.cpp @@ -64,6 +64,7 @@ #include #include #include +#include "CNamedShape.h" #include "CTiglLogging.h" #include #include @@ -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() { diff --git a/src/wing/CCPACSWing.h b/src/wing/CCPACSWing.h index 94788ccb0..8ca9ccbb3 100644 --- a/src/wing/CCPACSWing.h +++ b/src/wing/CCPACSWing.h @@ -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