PartDesign: New features AdditiveHelix and SubtractiveHelix
These features, based on the code for the Pipe class, allow the user to simply create a helical sweep within PartDesign workbench. Sample application is threads, springs, coils, augers, etc. Also, remove needless requirement for positive cone angle on helixes. Thanks to @bitacovir for helping with the icons Thanks to @chennes for review Thanks to @vosk for review Thanks to @wwmayer for review Enforce that links stay within scope for ProfileBased features This also ensures that the Body itself is not used for creating features within the body, causing a "Graph not a DAG" error.
This commit is contained in:
@@ -61,6 +61,7 @@
|
||||
#include "ViewProviderThickness.h"
|
||||
#include "ViewProviderPipe.h"
|
||||
#include "ViewProviderLoft.h"
|
||||
#include "ViewProviderHelix.h"
|
||||
#include "ViewProviderShapeBinder.h"
|
||||
#include "ViewProviderBase.h"
|
||||
|
||||
@@ -156,6 +157,7 @@ PyMOD_INIT_FUNC(PartDesignGui)
|
||||
PartDesignGui::ViewProviderPrimitive ::init();
|
||||
PartDesignGui::ViewProviderPipe ::init();
|
||||
PartDesignGui::ViewProviderLoft ::init();
|
||||
PartDesignGui::ViewProviderHelix ::init();
|
||||
PartDesignGui::ViewProviderBase ::init();
|
||||
|
||||
// add resources and reloads the translators
|
||||
|
||||
@@ -55,6 +55,7 @@ set(PartDesignGui_MOC_HDRS
|
||||
TaskPrimitiveParameters.h
|
||||
TaskPipeParameters.h
|
||||
TaskLoftParameters.h
|
||||
TaskHelixParameters.h
|
||||
)
|
||||
fc_wrap_cpp(PartDesignGui_MOC_SRCS ${PartDesignGui_MOC_HDRS})
|
||||
SOURCE_GROUP("Moc" FILES ${PartDesignGui_MOC_SRCS})
|
||||
@@ -89,6 +90,7 @@ set(PartDesignGui_UIC_SRCS
|
||||
TaskPipeScaling.ui
|
||||
TaskLoftParameters.ui
|
||||
DlgReference.ui
|
||||
TaskHelixParameters.ui
|
||||
)
|
||||
|
||||
if(BUILD_QT5)
|
||||
@@ -158,7 +160,9 @@ SET(PartDesignGuiViewProvider_SRCS
|
||||
ViewProviderPipe.cpp
|
||||
ViewProviderLoft.h
|
||||
ViewProviderLoft.cpp
|
||||
ViewProviderBase.h
|
||||
ViewProviderHelix.h
|
||||
ViewProviderHelix.cpp
|
||||
ViewProviderBase.h
|
||||
ViewProviderBase.cpp
|
||||
)
|
||||
SOURCE_GROUP("ViewProvider" FILES ${PartDesignGuiViewProvider_SRCS})
|
||||
@@ -237,6 +241,9 @@ SET(PartDesignGuiTaskDlgs_SRCS
|
||||
TaskLoftParameters.ui
|
||||
TaskLoftParameters.h
|
||||
TaskLoftParameters.cpp
|
||||
TaskHelixParameters.ui
|
||||
TaskHelixParameters.h
|
||||
TaskHelixParameters.cpp
|
||||
)
|
||||
SOURCE_GROUP("TaskDialogs" FILES ${PartDesignGuiTaskDlgs_SRCS})
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
#include <Mod/PartDesign/App/FeatureGroove.h>
|
||||
#include <Mod/PartDesign/App/FeatureRevolution.h>
|
||||
|
||||
#include <Mod/PartDesign/App/FeatureTransformed.h>
|
||||
#include <Mod/PartDesign/App/FeatureMultiTransform.h>
|
||||
#include <Mod/PartDesign/App/DatumPoint.h>
|
||||
@@ -384,7 +385,7 @@ void CmdPartDesignSubShapeBinder::activated(int iMsg)
|
||||
}
|
||||
values = std::move(links);
|
||||
}
|
||||
|
||||
|
||||
PartDesign::SubShapeBinder *binder = 0;
|
||||
try {
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Create SubShapeBinder"));
|
||||
@@ -403,7 +404,7 @@ void CmdPartDesignSubShapeBinder::activated(int iMsg)
|
||||
commitCommand();
|
||||
} catch (Base::Exception &e) {
|
||||
e.ReportException();
|
||||
QMessageBox::critical(Gui::getMainWindow(),
|
||||
QMessageBox::critical(Gui::getMainWindow(),
|
||||
QObject::tr("Sub-Shape Binder"), QString::fromUtf8(e.what()));
|
||||
abortCommand();
|
||||
}
|
||||
@@ -994,7 +995,7 @@ void prepareProfileBased(PartDesign::Body *pcActiveBody, Gui::Command* cmd, cons
|
||||
|
||||
FCMD_OBJ_CMD(pcActiveBody,"newObject('PartDesign::" << which << "','" << FeatName << "')");
|
||||
auto Feat = pcActiveBody->getDocument()->getObject(FeatName.c_str());
|
||||
|
||||
|
||||
auto objCmd = Gui::Command::getObjectCmd(feature);
|
||||
if (feature->isDerivedFrom(Part::Part2DObject::getClassTypeId()) || subs.empty()) {
|
||||
FCMD_OBJ_CMD(Feat,"Profile = " << objCmd);
|
||||
@@ -1003,7 +1004,7 @@ void prepareProfileBased(PartDesign::Body *pcActiveBody, Gui::Command* cmd, cons
|
||||
std::ostringstream ss;
|
||||
for (auto &s : subs)
|
||||
ss << "'" << s << "',";
|
||||
FCMD_OBJ_CMD(Feat,"Profile = (" << objCmd << ", [" << ss.str() << "])");
|
||||
FCMD_OBJ_CMD(Feat,"Profile = (" << objCmd << ", [" << ss.str() << "])");
|
||||
}
|
||||
|
||||
//for additive and subtractive lofts allow the user to preselect the sections
|
||||
@@ -1042,10 +1043,44 @@ void prepareProfileBased(PartDesign::Body *pcActiveBody, Gui::Command* cmd, cons
|
||||
func(static_cast<Part::Feature*>(feature), Feat);
|
||||
};
|
||||
|
||||
|
||||
// in case of subtractive types, check that there is something to subtract from
|
||||
if ((which.find("Subtractive") != std::string::npos) ||
|
||||
(which.compare("Groove") == 0) ||
|
||||
(which.compare("Pocket") == 0)) {
|
||||
|
||||
if (!pcActiveBody->isSolid()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QObject::tr("Cannot use this command as there is no solid to subtract from."));
|
||||
msgBox.setInformativeText(QObject::tr("Ensure that the body contains a feature before attempting a subtractive command."));
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.exec();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//if a profile is selected we can make our life easy and fast
|
||||
std::vector<Gui::SelectionObject> selection = cmd->getSelection().getSelectionEx();
|
||||
if (!selection.empty()) {
|
||||
base_worker(selection.front().getObject(), selection.front().getSubNames());
|
||||
bool onlyAllowed = true;
|
||||
for (auto it = selection.begin(); it!=selection.end(); ++it){
|
||||
if (PartDesign::Body::findBodyOf((*it).getObject()) != pcActiveBody) { // the selected objects must belong to the body
|
||||
onlyAllowed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!onlyAllowed) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QObject::tr("Cannot use selected object. Selected object must belong to the active body"));
|
||||
msgBox.setInformativeText(QObject::tr("Consider using a ShapeBinder or a BaseFeature to reference external geometry in a body."));
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.exec();
|
||||
} else {
|
||||
base_worker(selection.front().getObject(), selection.front().getSubNames());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1418,7 +1453,7 @@ void CmdPartDesignGroove::activated(int iMsg)
|
||||
else {
|
||||
FCMD_OBJ_CMD(Feat,"ReferenceAxis = ("<<getObjectCmd(pcActiveBody->getOrigin()->getY())<<",[''])");
|
||||
}
|
||||
|
||||
|
||||
FCMD_OBJ_CMD(Feat,"Angle = 360.0");
|
||||
|
||||
try {
|
||||
@@ -1643,6 +1678,119 @@ bool CmdPartDesignSubtractiveLoft::isActive(void)
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// PartDesign_Additive_Helix
|
||||
//===========================================================================
|
||||
DEF_STD_CMD_A(CmdPartDesignAdditiveHelix)
|
||||
|
||||
CmdPartDesignAdditiveHelix::CmdPartDesignAdditiveHelix()
|
||||
: Command("PartDesign_AdditiveHelix")
|
||||
{
|
||||
sAppModule = "PartDesign";
|
||||
sGroup = QT_TR_NOOP("PartDesign");
|
||||
sMenuText = QT_TR_NOOP("Additive helix");
|
||||
sToolTipText = QT_TR_NOOP("Sweep a selected sketch along a helix");
|
||||
sWhatsThis = "PartDesign_AdditiveHelix";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "PartDesign_Additive_Helix";
|
||||
}
|
||||
|
||||
void CmdPartDesignAdditiveHelix::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
App::Document *doc = getDocument();
|
||||
if (!PartDesignGui::assureModernWorkflow(doc))
|
||||
return;
|
||||
|
||||
PartDesign::Body *pcActiveBody = PartDesignGui::getBody(true);
|
||||
|
||||
if (!pcActiveBody)
|
||||
return;
|
||||
|
||||
Gui::Command* cmd = this;
|
||||
auto worker = [cmd, &pcActiveBody](Part::Feature* sketch, App::DocumentObject *Feat) {
|
||||
|
||||
if (!Feat) return;
|
||||
|
||||
// specific parameters for helix
|
||||
Gui::Command::updateActive();
|
||||
|
||||
if (sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId())) {
|
||||
FCMD_OBJ_CMD(Feat,"ReferenceAxis = (" << getObjectCmd(sketch) << ",['V_Axis'])");
|
||||
}
|
||||
else {
|
||||
FCMD_OBJ_CMD(Feat,"ReferenceAxis = (" << getObjectCmd(pcActiveBody->getOrigin()->getY()) << ",[''])");
|
||||
}
|
||||
|
||||
finishProfileBased(cmd, sketch, Feat);
|
||||
cmd->adjustCameraPosition();
|
||||
};
|
||||
|
||||
prepareProfileBased(pcActiveBody, this, "AdditiveHelix", worker);
|
||||
}
|
||||
|
||||
bool CmdPartDesignAdditiveHelix::isActive(void)
|
||||
{
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// PartDesign_Subtractive_Helix
|
||||
//===========================================================================
|
||||
DEF_STD_CMD_A(CmdPartDesignSubtractiveHelix)
|
||||
|
||||
CmdPartDesignSubtractiveHelix::CmdPartDesignSubtractiveHelix()
|
||||
: Command("PartDesign_SubtractiveHelix")
|
||||
{
|
||||
sAppModule = "PartDesign";
|
||||
sGroup = QT_TR_NOOP("PartDesign");
|
||||
sMenuText = QT_TR_NOOP("Subtractive helix");
|
||||
sToolTipText = QT_TR_NOOP("Sweep a selected sketch along a helix and remove it from the body");
|
||||
sWhatsThis = "PartDesign_SubtractiveHelix";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "PartDesign_Subtractive_Helix";
|
||||
}
|
||||
|
||||
void CmdPartDesignSubtractiveHelix::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
App::Document *doc = getDocument();
|
||||
if (!PartDesignGui::assureModernWorkflow(doc))
|
||||
return;
|
||||
|
||||
PartDesign::Body *pcActiveBody = PartDesignGui::getBody(true);
|
||||
|
||||
if (!pcActiveBody)
|
||||
return;
|
||||
|
||||
Gui::Command* cmd = this;
|
||||
auto worker = [cmd, &pcActiveBody](Part::Feature* sketch, App::DocumentObject *Feat) {
|
||||
|
||||
if (!Feat) return;
|
||||
|
||||
// specific parameters for helix
|
||||
Gui::Command::updateActive();
|
||||
|
||||
if (sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId())) {
|
||||
FCMD_OBJ_CMD(Feat,"ReferenceAxis = (" << getObjectCmd(sketch) << ",['V_Axis'])");
|
||||
}
|
||||
else {
|
||||
FCMD_OBJ_CMD(Feat,"ReferenceAxis = (" << getObjectCmd(pcActiveBody->getOrigin()->getY()) << ",[''])");
|
||||
}
|
||||
|
||||
finishProfileBased(cmd, sketch, Feat);
|
||||
cmd->adjustCameraPosition();
|
||||
};
|
||||
|
||||
prepareProfileBased(pcActiveBody, this, "SubtractiveHelix", worker);
|
||||
}
|
||||
|
||||
bool CmdPartDesignSubtractiveHelix::isActive(void)
|
||||
{
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Common utility functions for Dressup features
|
||||
//===========================================================================
|
||||
@@ -2176,7 +2324,7 @@ void CmdPartDesignPolarPattern::activated(int iMsg)
|
||||
}
|
||||
if (!direction) {
|
||||
auto body = static_cast<PartDesign::Body*>(Part::BodyBase::findBodyOf(features.front()));
|
||||
if (body) {
|
||||
if (body) {
|
||||
FCMD_OBJ_CMD(Feat,"Axis = ("<<Gui::Command::getObjectCmd(body->getOrigin()->getZ())<<",[''])");
|
||||
}
|
||||
}
|
||||
@@ -2397,7 +2545,7 @@ void CmdPartDesignBoolean::activated(int iMsg)
|
||||
std::string FeatName = getUniqueObjectName("Boolean",pcActiveBody);
|
||||
FCMD_OBJ_CMD(pcActiveBody,"newObject('PartDesign::Boolean','"<<FeatName<<"')");
|
||||
auto Feat = pcActiveBody->getDocument()->getObject(FeatName.c_str());
|
||||
|
||||
|
||||
// If we don't add an object to the boolean group then don't update the body
|
||||
// as otherwise this will fail and it will be marked as invalid
|
||||
bool updateDocument = false;
|
||||
@@ -2456,6 +2604,8 @@ void CreatePartDesignCommands(void)
|
||||
rcCmdMgr.addCommand(new CmdPartDesignSubtractivePipe);
|
||||
rcCmdMgr.addCommand(new CmdPartDesignAdditiveLoft);
|
||||
rcCmdMgr.addCommand(new CmdPartDesignSubtractiveLoft);
|
||||
rcCmdMgr.addCommand(new CmdPartDesignAdditiveHelix);
|
||||
rcCmdMgr.addCommand(new CmdPartDesignSubtractiveHelix);
|
||||
|
||||
rcCmdMgr.addCommand(new CmdPartDesignFillet());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignDraft());
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<file>icons/PartDesign_Additive_Ellipsoid.svg</file>
|
||||
<file>icons/PartDesign_Additive_Loft.svg</file>
|
||||
<file>icons/PartDesign_Additive_Pipe.svg</file>
|
||||
<file>icons/PartDesign_Additive_Helix.svg</file>
|
||||
<file>icons/PartDesign_Additive_Prism.svg</file>
|
||||
<file>icons/PartDesign_Additive_Sphere.svg</file>
|
||||
<file>icons/PartDesign_Additive_Torus.svg</file>
|
||||
@@ -50,6 +51,7 @@
|
||||
<file>icons/PartDesign_Subtractive_Ellipsoid.svg</file>
|
||||
<file>icons/PartDesign_Subtractive_Loft.svg</file>
|
||||
<file>icons/PartDesign_Subtractive_Pipe.svg</file>
|
||||
<file>icons/PartDesign_Subtractive_Helix.svg</file>
|
||||
<file>icons/PartDesign_Subtractive_Prism.svg</file>
|
||||
<file>icons/PartDesign_Subtractive_Sphere.svg</file>
|
||||
<file>icons/PartDesign_Subtractive_Torus.svg</file>
|
||||
|
||||
1456
src/Mod/PartDesign/Gui/Resources/icons/PartDesign_Additive_Helix.svg
Normal file
1456
src/Mod/PartDesign/Gui/Resources/icons/PartDesign_Additive_Helix.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 53 KiB |
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 53 KiB |
511
src/Mod/PartDesign/Gui/TaskHelixParameters.cpp
Normal file
511
src/Mod/PartDesign/Gui/TaskHelixParameters.cpp
Normal file
@@ -0,0 +1,511 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* 2020 David Österberg *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#endif
|
||||
|
||||
#include <Base/UnitsApi.h>
|
||||
#include <Base/Console.h>
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/Origin.h>
|
||||
#include <App/OriginFeature.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Gui/WaitCursor.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/ViewProviderOrigin.h>
|
||||
#include <Mod/PartDesign/App/DatumLine.h>
|
||||
#include <Mod/PartDesign/App/FeatureHelix.h>
|
||||
#include <Mod/PartDesign/App/FeatureGroove.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
#include <QString>
|
||||
|
||||
#include "ReferenceSelection.h"
|
||||
#include "Utils.h"
|
||||
|
||||
#include "ui_TaskHelixParameters.h"
|
||||
#include "TaskHelixParameters.h"
|
||||
|
||||
using namespace PartDesignGui;
|
||||
using namespace Gui;
|
||||
|
||||
|
||||
/* TRANSLATOR PartDesignGui::TaskHelixParameters */
|
||||
|
||||
TaskHelixParameters::TaskHelixParameters(PartDesignGui::ViewProviderHelix *HelixView, QWidget *parent)
|
||||
: TaskSketchBasedParameters(HelixView, parent, "PartDesign_Additive_Helix",tr("Helix parameters")),
|
||||
ui (new Ui_TaskHelixParameters)
|
||||
{
|
||||
// we need a separate container widget to add all controls to
|
||||
proxy = new QWidget(this);
|
||||
ui->setupUi(proxy);
|
||||
QMetaObject::connectSlotsByName(this);
|
||||
|
||||
connect(ui->pitch, SIGNAL(valueChanged(double)),
|
||||
this, SLOT(onPitchChanged(double)));
|
||||
connect(ui->height, SIGNAL(valueChanged(double)),
|
||||
this, SLOT(onHeightChanged(double)));
|
||||
connect(ui->turns, SIGNAL(valueChanged(double)),
|
||||
this, SLOT(onTurnsChanged(double)));
|
||||
connect(ui->coneAngle, SIGNAL(valueChanged(double)),
|
||||
this, SLOT(onAngleChanged(double)));
|
||||
connect(ui->axis, SIGNAL(activated(int)),
|
||||
this, SLOT(onAxisChanged(int)));
|
||||
connect(ui->checkBoxLeftHanded, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onLeftHandedChanged(bool)));
|
||||
connect(ui->checkBoxReversed, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onReversedChanged(bool)));
|
||||
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onUpdateView(bool)));
|
||||
connect(ui->inputMode, SIGNAL(activated(int)),
|
||||
this, SLOT(onModeChanged(int)));
|
||||
connect(ui->checkBoxOutside, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onOutsideChanged(bool)));
|
||||
|
||||
this->groupLayout()->addWidget(proxy);
|
||||
|
||||
// Temporarily prevent unnecessary feature recomputes
|
||||
ui->axis->blockSignals(true);
|
||||
ui->pitch->blockSignals(true);
|
||||
ui->height->blockSignals(true);
|
||||
ui->turns->blockSignals(true);
|
||||
ui->coneAngle->blockSignals(true);
|
||||
ui->checkBoxLeftHanded->blockSignals(true);
|
||||
ui->checkBoxReversed->blockSignals(true);
|
||||
ui->checkBoxOutside->blockSignals(true);
|
||||
|
||||
//bind property mirrors
|
||||
PartDesign::ProfileBased* pcFeat = static_cast<PartDesign::ProfileBased*>(vp->getObject());
|
||||
|
||||
PartDesign::Helix* rev = static_cast<PartDesign::Helix*>(vp->getObject());
|
||||
|
||||
if (!(rev->HasBeenEdited).getValue()) {
|
||||
rev->proposeParameters();
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
this->propAngle = &(rev->Angle);
|
||||
this->propPitch = &(rev->Pitch);
|
||||
this->propHeight = &(rev->Height);
|
||||
this->propTurns = &(rev->Turns);
|
||||
this->propReferenceAxis = &(rev->ReferenceAxis);
|
||||
this->propLeftHanded = &(rev->LeftHanded);
|
||||
this->propReversed = &(rev->Reversed);
|
||||
this->propMode = &(rev->Mode);
|
||||
this->propOutside = &(rev->Outside);
|
||||
|
||||
double pitch = propPitch->getValue();
|
||||
double height = propHeight->getValue();
|
||||
double turns = propTurns->getValue();
|
||||
double angle = propAngle->getValue();
|
||||
bool leftHanded = propLeftHanded->getValue();
|
||||
bool reversed = propReversed->getValue();
|
||||
int index = propMode->getValue();
|
||||
bool outside = propOutside->getValue();
|
||||
|
||||
ui->pitch->setValue(pitch);
|
||||
ui->height->setValue(height);
|
||||
ui->turns->setValue(turns);
|
||||
ui->coneAngle->setValue(angle);
|
||||
ui->checkBoxLeftHanded->setChecked(leftHanded);
|
||||
ui->checkBoxReversed->setChecked(reversed);
|
||||
ui->inputMode->setCurrentIndex(index);
|
||||
ui->checkBoxOutside->setChecked(outside);
|
||||
|
||||
blockUpdate = false;
|
||||
updateUI();
|
||||
|
||||
// enable use of parametric expressions for the numerical fields
|
||||
ui->pitch->bind(static_cast<PartDesign::Helix *>(pcFeat)->Pitch);
|
||||
ui->height->bind(static_cast<PartDesign::Helix *>(pcFeat)->Height);
|
||||
ui->turns->bind(static_cast<PartDesign::Helix *>(pcFeat)->Turns);
|
||||
ui->coneAngle->bind(static_cast<PartDesign::Helix *>(pcFeat)->Angle);
|
||||
|
||||
ui->axis->blockSignals(false);
|
||||
ui->pitch->blockSignals(false);
|
||||
ui->height->blockSignals(false);
|
||||
ui->turns->blockSignals(false);
|
||||
ui->coneAngle->blockSignals(false);
|
||||
ui->checkBoxLeftHanded->blockSignals(false);
|
||||
ui->checkBoxReversed->blockSignals(false);
|
||||
ui->checkBoxOutside->blockSignals(false);
|
||||
|
||||
setFocus ();
|
||||
|
||||
//show the parts coordinate system axis for selection
|
||||
PartDesign::Body * body = PartDesign::Body::findBodyOf ( vp->getObject () );
|
||||
if(body) {
|
||||
try {
|
||||
App::Origin *origin = body->getOrigin();
|
||||
ViewProviderOrigin* vpOrigin;
|
||||
vpOrigin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->getViewProvider(origin));
|
||||
vpOrigin->setTemporaryVisibility(true, false);
|
||||
} catch (const Base::Exception &ex) {
|
||||
ex.ReportException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskHelixParameters::fillAxisCombo(bool forceRefill)
|
||||
{
|
||||
bool oldVal_blockUpdate = blockUpdate;
|
||||
blockUpdate = true;
|
||||
|
||||
if (axesInList.empty())
|
||||
forceRefill = true;//not filled yet, full refill
|
||||
|
||||
if (forceRefill){
|
||||
ui->axis->clear();
|
||||
|
||||
this->axesInList.clear();
|
||||
|
||||
//add sketch axes
|
||||
PartDesign::ProfileBased* pcFeat = static_cast<PartDesign::ProfileBased*>(vp->getObject());
|
||||
Part::Part2DObject* pcSketch = dynamic_cast<Part::Part2DObject*>(pcFeat->Profile.getValue());
|
||||
if (pcSketch){
|
||||
addAxisToCombo(pcSketch,"V_Axis",QObject::tr("Vertical sketch axis"));
|
||||
addAxisToCombo(pcSketch,"H_Axis",QObject::tr("Horizontal sketch axis"));
|
||||
for (int i=0; i < pcSketch->getAxisCount(); i++) {
|
||||
QString itemText = QObject::tr("Construction line %1").arg(i+1);
|
||||
std::stringstream sub;
|
||||
sub << "Axis" << i;
|
||||
addAxisToCombo(pcSketch,sub.str(),itemText);
|
||||
}
|
||||
}
|
||||
|
||||
//add part axes
|
||||
PartDesign::Body * body = PartDesign::Body::findBodyOf ( pcFeat );
|
||||
if (body) {
|
||||
try {
|
||||
App::Origin* orig = body->getOrigin();
|
||||
addAxisToCombo(orig->getX(),"",tr("Base X axis"));
|
||||
addAxisToCombo(orig->getY(),"",tr("Base Y axis"));
|
||||
addAxisToCombo(orig->getZ(),"",tr("Base Z axis"));
|
||||
} catch (const Base::Exception &ex) {
|
||||
ex.ReportException();
|
||||
}
|
||||
}
|
||||
|
||||
//add "Select reference"
|
||||
addAxisToCombo(0,std::string(),tr("Select reference..."));
|
||||
}//endif forceRefill
|
||||
|
||||
//add current link, if not in list
|
||||
//first, figure out the item number for current axis
|
||||
int indexOfCurrent = -1;
|
||||
App::DocumentObject* ax = propReferenceAxis->getValue();
|
||||
const std::vector<std::string> &subList = propReferenceAxis->getSubValues();
|
||||
for (size_t i = 0; i < axesInList.size(); i++) {
|
||||
if (ax == axesInList[i]->getValue() && subList == axesInList[i]->getSubValues())
|
||||
indexOfCurrent = i;
|
||||
}
|
||||
if (indexOfCurrent == -1 && ax) {
|
||||
assert(subList.size() <= 1);
|
||||
std::string sub;
|
||||
if (!subList.empty())
|
||||
sub = subList[0];
|
||||
addAxisToCombo(ax, sub, getRefStr(ax, subList));
|
||||
indexOfCurrent = axesInList.size()-1;
|
||||
}
|
||||
|
||||
//highlight current.
|
||||
if (indexOfCurrent != -1)
|
||||
ui->axis->setCurrentIndex(indexOfCurrent);
|
||||
|
||||
blockUpdate = oldVal_blockUpdate;
|
||||
}
|
||||
|
||||
void TaskHelixParameters::addAxisToCombo(App::DocumentObject* linkObj,
|
||||
std::string linkSubname,
|
||||
QString itemText)
|
||||
{
|
||||
this->ui->axis->addItem(itemText);
|
||||
this->axesInList.emplace_back(new App::PropertyLinkSub);
|
||||
App::PropertyLinkSub &lnk = *(axesInList[axesInList.size()-1]);
|
||||
lnk.setValue(linkObj,std::vector<std::string>(1,linkSubname));
|
||||
}
|
||||
|
||||
void TaskHelixParameters::updateUI()
|
||||
{
|
||||
fillAxisCombo();
|
||||
|
||||
auto pcHelix = static_cast<PartDesign::Helix*>(vp->getObject());
|
||||
auto status = std::string(pcHelix->getStatusString());
|
||||
if (status.compare("Valid")==0 || status.compare("Touched")==0) {
|
||||
if (pcHelix->safePitch() > propPitch->getValue())
|
||||
status = "Warning: helix might be self intersecting";
|
||||
else
|
||||
status = "";
|
||||
}
|
||||
ui->labelMessage->setText(QString::fromUtf8(status.c_str()));
|
||||
|
||||
bool isPitchVisible = false;
|
||||
bool isHeightVisible = false;
|
||||
bool isTurnsVisible = false;
|
||||
bool isOutsideVisible = false;
|
||||
|
||||
if(pcHelix->getAddSubType() == PartDesign::FeatureAddSub::Subtractive)
|
||||
isOutsideVisible = true;
|
||||
|
||||
switch (propMode->getValue()) {
|
||||
case 0:
|
||||
isPitchVisible = true;
|
||||
isHeightVisible = true;
|
||||
break;
|
||||
case 1:
|
||||
isPitchVisible = true;
|
||||
isTurnsVisible = true;
|
||||
break;
|
||||
default:
|
||||
isHeightVisible = true;
|
||||
isTurnsVisible = true;
|
||||
}
|
||||
|
||||
ui->pitch->setVisible(isPitchVisible);
|
||||
ui->labelPitch->setVisible(isPitchVisible);
|
||||
|
||||
ui->height->setVisible(isHeightVisible);
|
||||
ui->labelHeight->setVisible(isHeightVisible);
|
||||
|
||||
ui->turns->setVisible(isTurnsVisible);
|
||||
ui->labelTurns->setVisible(isTurnsVisible);
|
||||
|
||||
ui->checkBoxOutside->setVisible(isOutsideVisible);
|
||||
|
||||
}
|
||||
|
||||
void TaskHelixParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
|
||||
exitSelectionMode();
|
||||
std::vector<std::string> axis;
|
||||
App::DocumentObject* selObj;
|
||||
if (getReferencedSelection(vp->getObject(), msg, selObj, axis) && selObj) {
|
||||
propReferenceAxis->setValue(selObj, axis);
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TaskHelixParameters::onPitchChanged(double len)
|
||||
{
|
||||
propPitch->setValue(len);
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskHelixParameters::onHeightChanged(double len)
|
||||
{
|
||||
propHeight->setValue(len);
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskHelixParameters::onTurnsChanged(double len)
|
||||
{
|
||||
propTurns->setValue(len);
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskHelixParameters::onAngleChanged(double len)
|
||||
{
|
||||
propAngle->setValue(len);
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskHelixParameters::onAxisChanged(int num)
|
||||
{
|
||||
PartDesign::ProfileBased* pcHelix = static_cast<PartDesign::ProfileBased*>(vp->getObject());
|
||||
|
||||
if (axesInList.empty())
|
||||
return;
|
||||
|
||||
App::DocumentObject *oldRefAxis = propReferenceAxis->getValue();
|
||||
std::vector<std::string> oldSubRefAxis = propReferenceAxis->getSubValues();
|
||||
std::string oldRefName;
|
||||
if (!oldSubRefAxis.empty())
|
||||
oldRefName = oldSubRefAxis.front();
|
||||
|
||||
App::PropertyLinkSub &lnk = *(axesInList[num]);
|
||||
if (lnk.getValue() == 0) {
|
||||
// enter reference selection mode
|
||||
TaskSketchBasedParameters::onSelectReference(true, true, false, true);
|
||||
} else {
|
||||
if (!pcHelix->getDocument()->isIn(lnk.getValue())){
|
||||
Base::Console().Error("Object was deleted\n");
|
||||
return;
|
||||
}
|
||||
propReferenceAxis->Paste(lnk);
|
||||
exitSelectionMode();
|
||||
}
|
||||
|
||||
try {
|
||||
App::DocumentObject *newRefAxis = propReferenceAxis->getValue();
|
||||
const std::vector<std::string> &newSubRefAxis = propReferenceAxis->getSubValues();
|
||||
std::string newRefName;
|
||||
if (!newSubRefAxis.empty())
|
||||
newRefName = newSubRefAxis.front();
|
||||
|
||||
if (oldRefAxis != newRefAxis ||
|
||||
oldSubRefAxis.size() != newSubRefAxis.size() ||
|
||||
oldRefName != newRefName) {
|
||||
bool reversed = propReversed->getValue();
|
||||
if (reversed != propReversed->getValue()) {
|
||||
propReversed->setValue(reversed);
|
||||
ui->checkBoxReversed->blockSignals(true);
|
||||
ui->checkBoxReversed->setChecked(reversed);
|
||||
ui->checkBoxReversed->blockSignals(false);
|
||||
}
|
||||
}
|
||||
|
||||
recomputeFeature();
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
e.ReportException();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskHelixParameters::onModeChanged(int index)
|
||||
{
|
||||
|
||||
propMode->setValue(index);
|
||||
|
||||
ui->pitch->setValue(propPitch->getValue());
|
||||
ui->height->setValue(propHeight->getValue());
|
||||
ui->turns->setValue((propHeight->getValue())/(propPitch->getValue()));
|
||||
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskHelixParameters::onLeftHandedChanged(bool on)
|
||||
{
|
||||
propLeftHanded->setValue(on);
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskHelixParameters::onReversedChanged(bool on)
|
||||
{
|
||||
propReversed->setValue(on);
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskHelixParameters::onOutsideChanged(bool on)
|
||||
{
|
||||
propOutside->setValue(on);
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
|
||||
|
||||
TaskHelixParameters::~TaskHelixParameters()
|
||||
{
|
||||
try {
|
||||
//hide the parts coordinate system axis for selection
|
||||
PartDesign::Body * body = vp ? PartDesign::Body::findBodyOf(vp->getObject()) : 0;
|
||||
if (body) {
|
||||
App::Origin *origin = body->getOrigin();
|
||||
ViewProviderOrigin* vpOrigin;
|
||||
vpOrigin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->getViewProvider(origin));
|
||||
vpOrigin->resetTemporaryVisibility();
|
||||
}
|
||||
} catch (const Base::Exception &ex) {
|
||||
ex.ReportException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TaskHelixParameters::changeEvent(QEvent *e)
|
||||
{
|
||||
TaskBox::changeEvent(e);
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(proxy);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskHelixParameters::getReferenceAxis(App::DocumentObject*& obj, std::vector<std::string>& sub) const
|
||||
{
|
||||
if (axesInList.empty())
|
||||
throw Base::RuntimeError("Not initialized!");
|
||||
|
||||
int num = ui->axis->currentIndex();
|
||||
const App::PropertyLinkSub &lnk = *(axesInList[num]);
|
||||
if (lnk.getValue() == 0) {
|
||||
throw Base::RuntimeError("Still in reference selection mode; reference wasn't selected yet");
|
||||
} else {
|
||||
PartDesign::ProfileBased* pcRevolution = static_cast<PartDesign::ProfileBased*>(vp->getObject());
|
||||
if (!pcRevolution->getDocument()->isIn(lnk.getValue())){
|
||||
throw Base::RuntimeError("Object was deleted");
|
||||
}
|
||||
|
||||
obj = lnk.getValue();
|
||||
sub = lnk.getSubValues();
|
||||
}
|
||||
}
|
||||
|
||||
// this is used for logging the command fully when recording macros
|
||||
void TaskHelixParameters::apply()
|
||||
{
|
||||
std::vector<std::string> sub;
|
||||
App::DocumentObject* obj;
|
||||
getReferenceAxis(obj, sub);
|
||||
std::string axis = buildLinkSingleSubPythonStr(obj, sub);
|
||||
auto tobj = vp->getObject();
|
||||
FCMD_OBJ_CMD(tobj,"ReferenceAxis = " << axis);
|
||||
FCMD_OBJ_CMD(tobj,"Mode = " << propMode->getValue());
|
||||
FCMD_OBJ_CMD(tobj,"Pitch = " << propPitch->getValue());
|
||||
FCMD_OBJ_CMD(tobj,"Height = " << propHeight->getValue());
|
||||
FCMD_OBJ_CMD(tobj,"Turns = " << propTurns->getValue());
|
||||
FCMD_OBJ_CMD(tobj,"Angle = " << propAngle->getValue());
|
||||
FCMD_OBJ_CMD(tobj,"LeftHanded = " << (propLeftHanded->getValue() ? 1 : 0));
|
||||
FCMD_OBJ_CMD(tobj,"Reversed = " << (propReversed->getValue() ? 1 : 0));
|
||||
}
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
//**************************************************************************
|
||||
// TaskDialog
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
TaskDlgHelixParameters::TaskDlgHelixParameters(ViewProviderHelix *HelixView)
|
||||
: TaskDlgSketchBasedParameters(HelixView)
|
||||
{
|
||||
assert(HelixView);
|
||||
Content.push_back(new TaskHelixParameters(HelixView));
|
||||
}
|
||||
|
||||
|
||||
#include "moc_TaskHelixParameters.cpp"
|
||||
131
src/Mod/PartDesign/Gui/TaskHelixParameters.h
Normal file
131
src/Mod/PartDesign/Gui/TaskHelixParameters.h
Normal file
@@ -0,0 +1,131 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef GUI_TASKVIEW_TaskHelixParameters_H
|
||||
#define GUI_TASKVIEW_TaskHelixParameters_H
|
||||
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
#include "TaskSketchBasedParameters.h"
|
||||
#include "ViewProviderHelix.h"
|
||||
|
||||
class Ui_TaskHelixParameters;
|
||||
|
||||
namespace App {
|
||||
class Property;
|
||||
}
|
||||
|
||||
namespace Gui {
|
||||
class ViewProvider;
|
||||
}
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
|
||||
|
||||
class TaskHelixParameters : public TaskSketchBasedParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskHelixParameters(ViewProviderHelix *HelixView,QWidget *parent = 0);
|
||||
~TaskHelixParameters();
|
||||
|
||||
virtual void apply() override;
|
||||
|
||||
/**
|
||||
* @brief fillAxisCombo fills the combo and selects the item according to
|
||||
* current value of revolution object's axis reference.
|
||||
* @param forceRefill if true, the combo box will be completely refilled. If
|
||||
* false, the current value of revolution object's axis will be added to the
|
||||
* list (if necessary), and selected. If the list is empty, it will be refilled anyway.
|
||||
*/
|
||||
void fillAxisCombo(bool forceRefill = false);
|
||||
void addAxisToCombo(App::DocumentObject *linkObj, std::string linkSubname, QString itemText);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onPitchChanged(double);
|
||||
void onHeightChanged(double);
|
||||
void onTurnsChanged(double);
|
||||
void onAngleChanged(double);
|
||||
void onAxisChanged(int);
|
||||
void onLeftHandedChanged(bool);
|
||||
void onReversedChanged(bool);
|
||||
void onModeChanged(int);
|
||||
void onOutsideChanged(bool);
|
||||
|
||||
|
||||
protected:
|
||||
void onSelectionChanged(const Gui::SelectionChanges& msg) override;
|
||||
void changeEvent(QEvent *e) override;
|
||||
bool updateView() const;
|
||||
void getReferenceAxis(App::DocumentObject *&obj, std::vector<std::string> &sub) const;
|
||||
|
||||
|
||||
//mirrors of helixes's properties
|
||||
App::PropertyLength* propPitch;
|
||||
App::PropertyLength* propHeight;
|
||||
App::PropertyFloat* propTurns;
|
||||
App::PropertyBool* propLeftHanded;
|
||||
App::PropertyBool* propReversed;
|
||||
App::PropertyLinkSub* propReferenceAxis;
|
||||
App::PropertyAngle* propAngle;
|
||||
App::PropertyEnumeration* propMode;
|
||||
App::PropertyBool* propOutside;
|
||||
|
||||
|
||||
private:
|
||||
void updateUI();
|
||||
|
||||
private:
|
||||
QWidget* proxy;
|
||||
Ui_TaskHelixParameters* ui;
|
||||
|
||||
/**
|
||||
* @brief axesInList is the list of links corresponding to axis combo; must
|
||||
* be kept in sync with the combo. A special value of zero-pointer link is
|
||||
* for "Select axis" item.
|
||||
*
|
||||
* It is a list of pointers, because properties prohibit assignment. Use new
|
||||
* when adding stuff, and delete when removing stuff.
|
||||
*/
|
||||
std::vector<std::unique_ptr<App::PropertyLinkSub>> axesInList;
|
||||
};
|
||||
|
||||
/// simulation dialog for the TaskView
|
||||
class TaskDlgHelixParameters : public TaskDlgSketchBasedParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskDlgHelixParameters(ViewProviderHelix *HelixView);
|
||||
|
||||
ViewProviderHelix* getHelixView() const
|
||||
{ return static_cast<ViewProviderHelix*>(vp); }
|
||||
};
|
||||
|
||||
} //namespace PartDesignGui
|
||||
|
||||
#endif // GUI_TASKVIEW_TaskHelixParameters_H
|
||||
303
src/Mod/PartDesign/Gui/TaskHelixParameters.ui
Normal file
303
src/Mod/PartDesign/Gui/TaskHelixParameters.ui
Normal file
@@ -0,0 +1,303 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PartDesignGui::TaskHelixParameters</class>
|
||||
<widget class="QWidget" name="PartDesignGui::TaskHelixParameters">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>278</width>
|
||||
<height>193</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutStatus">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelStatus">
|
||||
<property name="text">
|
||||
<string>Status:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelMessage">
|
||||
<property name="text">
|
||||
<string>Valid</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label0">
|
||||
<property name="text">
|
||||
<string>Axis:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="axis">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Base X axis</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Base Y axis</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Base Z axis</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Horizontal sketch axis</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Vertical sketch axis</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Select reference...</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutMode">
|
||||
<item>
|
||||
<widget class="QLabel" name="label4">
|
||||
<property name="text">
|
||||
<string>Mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="inputMode">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Pitch-Height</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Pitch-Turns</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Height-Turns</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutPitch">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelPitch">
|
||||
<property name="text">
|
||||
<string>Pitch:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::QuantitySpinBox" name="pitch">
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">mm</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>10.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutHeight">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelHeight">
|
||||
<property name="text">
|
||||
<string>Height:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::QuantitySpinBox" name="height">
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">mm</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>30.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutTurns">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelTurns">
|
||||
<property name="text">
|
||||
<string>Turns:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::QuantitySpinBox" name="turns">
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>3.0000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutConeAngle">
|
||||
<item>
|
||||
<widget class="QLabel" name="label5">
|
||||
<property name="text">
|
||||
<string>Cone angle:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::QuantitySpinBox" name="coneAngle">
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">deg</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-89.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>89.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>5.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxLeftHanded">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Left handed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxReversed">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reversed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxOutside">
|
||||
<property name="text">
|
||||
<string>Remove outside of profile</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxUpdateView">
|
||||
<property name="text">
|
||||
<string>Update view</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
|
||||
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::QuantitySpinBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Gui/QuantitySpinBox.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
120
src/Mod/PartDesign/Gui/ViewProviderHelix.cpp
Normal file
120
src/Mod/PartDesign/Gui/ViewProviderHelix.cpp
Normal file
@@ -0,0 +1,120 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QAction>
|
||||
# include <QMenu>
|
||||
#endif
|
||||
|
||||
#include <Mod/PartDesign/App/FeatureHelix.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
#include <Mod/PartDesign/App/FeatureSketchBased.h>
|
||||
|
||||
#include "TaskHelixParameters.h"
|
||||
#include "ViewProviderHelix.h"
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
PROPERTY_SOURCE(PartDesignGui::ViewProviderHelix,PartDesignGui::ViewProvider)
|
||||
|
||||
|
||||
ViewProviderHelix::ViewProviderHelix()
|
||||
{
|
||||
}
|
||||
|
||||
ViewProviderHelix::~ViewProviderHelix()
|
||||
{
|
||||
}
|
||||
|
||||
void ViewProviderHelix::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
{
|
||||
QAction* act;
|
||||
act = menu->addAction(QObject::tr("Edit helix"), receiver, member);
|
||||
act->setData(QVariant((int)ViewProvider::Default));
|
||||
PartDesignGui::ViewProviderAddSub::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
TaskDlgFeatureParameters *ViewProviderHelix::getEditDialog()
|
||||
{
|
||||
return new TaskDlgHelixParameters( this );
|
||||
}
|
||||
|
||||
QIcon ViewProviderHelix::getIcon(void) const {
|
||||
QString str = QString::fromLatin1("PartDesign_");
|
||||
auto* prim = static_cast<PartDesign::Helix*>(getObject());
|
||||
if(prim->getAddSubType() == PartDesign::FeatureAddSub::Additive)
|
||||
str += QString::fromLatin1("Additive_");
|
||||
else
|
||||
str += QString::fromLatin1("Subtractive_");
|
||||
|
||||
str += QString::fromLatin1("Helix.svg");
|
||||
return PartDesignGui::ViewProvider::mergeGreyableOverlayIcons(Gui::BitmapFactory().pixmap(str.toStdString().c_str()));
|
||||
}
|
||||
|
||||
bool ViewProviderHelix::setEdit(int ModNum)
|
||||
{
|
||||
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
auto* prim = static_cast<PartDesign::Helix*>(getObject());
|
||||
setPreviewDisplayMode(prim->getAddSubType() == PartDesign::FeatureAddSub::Subtractive);
|
||||
}
|
||||
return ViewProviderAddSub::setEdit(ModNum);
|
||||
}
|
||||
|
||||
void ViewProviderHelix::unsetEdit(int ModNum)
|
||||
{
|
||||
setPreviewDisplayMode(false);
|
||||
// Rely on parent class to:
|
||||
// restitute old workbench (set setEdit above) and close the dialog if exiting editing
|
||||
PartDesignGui::ViewProvider::unsetEdit(ModNum);
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> ViewProviderHelix::claimChildren(void) const {
|
||||
std::vector<App::DocumentObject*> temp;
|
||||
App::DocumentObject* sketch = static_cast<PartDesign::ProfileBased*>(getObject())->Profile.getValue();
|
||||
if (sketch != NULL && sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
|
||||
temp.push_back(sketch);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
bool ViewProviderHelix::onDelete(const std::vector<std::string> &s) {
|
||||
PartDesign::ProfileBased* feature = static_cast<PartDesign::ProfileBased*>(getObject());
|
||||
|
||||
// get the Sketch
|
||||
Sketcher::SketchObject *pcSketch = 0;
|
||||
if (feature->Profile.getValue())
|
||||
pcSketch = static_cast<Sketcher::SketchObject*>(feature->Profile.getValue());
|
||||
|
||||
// if abort command deleted the object the sketch is visible again
|
||||
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
|
||||
Gui::Application::Instance->getViewProvider(pcSketch)->show();
|
||||
|
||||
return ViewProvider::onDelete(s);
|
||||
}
|
||||
|
||||
62
src/Mod/PartDesign/Gui/ViewProviderHelix.h
Normal file
62
src/Mod/PartDesign/Gui/ViewProviderHelix.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef PARTGUI_ViewProviderHelix_H
|
||||
#define PARTGUI_ViewProviderHelix_H
|
||||
|
||||
#include "ViewProviderAddSub.h"
|
||||
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
class PartDesignGuiExport ViewProviderHelix : public ViewProviderAddSub
|
||||
{
|
||||
PROPERTY_HEADER(PartDesignGui::ViewProviderHelix);
|
||||
|
||||
public:
|
||||
/// constructor
|
||||
ViewProviderHelix();
|
||||
/// destructor
|
||||
virtual ~ViewProviderHelix();
|
||||
|
||||
void setupContextMenu(QMenu*, QObject*, const char*);
|
||||
|
||||
/// grouping handling
|
||||
std::vector<App::DocumentObject*> claimChildren(void)const;
|
||||
|
||||
virtual bool onDelete(const std::vector<std::string> &);
|
||||
|
||||
protected:
|
||||
virtual QIcon getIcon(void) const;
|
||||
|
||||
/// Returns a newly created TaskDlgHelixParameters
|
||||
virtual TaskDlgFeatureParameters *getEditDialog();
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
};
|
||||
|
||||
|
||||
} // namespace PartDesignGui
|
||||
|
||||
|
||||
#endif // PARTGUI_ViewProviderHelix_H
|
||||
@@ -72,3 +72,4 @@ bool ViewProviderSketchBased::onDelete(const std::vector<std::string> &s) {
|
||||
|
||||
return ViewProvider::onDelete(s);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#ifndef VIEWPROVIDERSKETCHBASED_H_QKP3UG9A
|
||||
#define VIEWPROVIDERSKETCHBASED_H_QKP3UG9A
|
||||
|
||||
#include "ViewProvider.h"
|
||||
#include "ViewProviderAddSub.h"
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
std::vector<App::DocumentObject*> claimChildren(void)const;
|
||||
|
||||
virtual bool onDelete(const std::vector<std::string> &);
|
||||
|
||||
};
|
||||
|
||||
} /* PartDesignGui */
|
||||
|
||||
@@ -409,6 +409,8 @@ void Workbench::activated()
|
||||
"PartDesign_SubtractivePipe",
|
||||
"PartDesign_AdditiveLoft",
|
||||
"PartDesign_SubtractiveLoft",
|
||||
"PartDesign_AdditiveHelix",
|
||||
"PartDesign_SubtractiveHelix",
|
||||
0};
|
||||
Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
|
||||
"SELECT Sketcher::SketchObject COUNT 1",
|
||||
@@ -496,14 +498,14 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
Gui::MenuItem* additives = new Gui::MenuItem;
|
||||
additives->setCommand("Create an additive feature");
|
||||
*additives << "PartDesign_Pad" << "PartDesign_Revolution"
|
||||
<< "PartDesign_AdditiveLoft" << "PartDesign_AdditivePipe";
|
||||
<< "PartDesign_AdditiveLoft" << "PartDesign_AdditivePipe" << "PartDesign_AdditiveHelix";
|
||||
|
||||
// subtractives
|
||||
Gui::MenuItem* subtractives = new Gui::MenuItem;
|
||||
subtractives->setCommand("Create a subtractive feature");
|
||||
*subtractives << "PartDesign_Pocket" << "PartDesign_Hole"
|
||||
<< "PartDesign_Groove" << "PartDesign_SubtractiveLoft"
|
||||
<< "PartDesign_SubtractivePipe";
|
||||
<< "PartDesign_SubtractivePipe" << "PartDesign_SubtractiveHelix";
|
||||
|
||||
// transformations
|
||||
Gui::MenuItem* transformations = new Gui::MenuItem;
|
||||
@@ -598,6 +600,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
<< "PartDesign_Revolution"
|
||||
<< "PartDesign_AdditiveLoft"
|
||||
<< "PartDesign_AdditivePipe"
|
||||
<< "PartDesign_AdditiveHelix"
|
||||
<< "PartDesign_CompPrimitiveAdditive"
|
||||
<< "Separator"
|
||||
<< "PartDesign_Pocket"
|
||||
@@ -605,6 +608,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
<< "PartDesign_Groove"
|
||||
<< "PartDesign_SubtractiveLoft"
|
||||
<< "PartDesign_SubtractivePipe"
|
||||
<< "PartDesign_SubtractiveHelix"
|
||||
<< "PartDesign_CompPrimitiveSubtractive"
|
||||
<< "Separator"
|
||||
<< "PartDesign_Mirrored"
|
||||
|
||||
Reference in New Issue
Block a user