Merge branch 'master' of git://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad
This commit is contained in:
commit
8d8715e55a
|
@ -45,7 +45,7 @@ Feature::Feature()
|
|||
{
|
||||
}
|
||||
|
||||
TopoDS_Shape Feature::getSolid(const TopoDS_Shape& shape) const
|
||||
TopoDS_Shape Feature::getSolid(const TopoDS_Shape& shape)
|
||||
{
|
||||
if (shape.IsNull())
|
||||
Standard_Failure::Raise("Shape is null");
|
||||
|
@ -58,7 +58,7 @@ TopoDS_Shape Feature::getSolid(const TopoDS_Shape& shape) const
|
|||
return TopoDS_Shape();
|
||||
}
|
||||
|
||||
const gp_Pnt Feature::getPointFromFace(const TopoDS_Face& f) const
|
||||
const gp_Pnt Feature::getPointFromFace(const TopoDS_Face& f)
|
||||
{
|
||||
if (!f.Infinite()) {
|
||||
TopExp_Explorer exp;
|
||||
|
|
|
@ -49,10 +49,10 @@ protected:
|
|||
/**
|
||||
* Get a solid of the given shape. If no solid is found an exception is raised.
|
||||
*/
|
||||
TopoDS_Shape getSolid(const TopoDS_Shape&) const;
|
||||
static TopoDS_Shape getSolid(const TopoDS_Shape&);
|
||||
|
||||
/// Grab any point from the given face
|
||||
const gp_Pnt getPointFromFace(const TopoDS_Face& f) const;
|
||||
static const gp_Pnt getPointFromFace(const TopoDS_Face& f);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
# include <BRepAlgoAPI_Cut.hxx>
|
||||
# include <BRep_Builder.hxx>
|
||||
# include <TopExp.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <TopTools_IndexedMapOfShape.hxx>
|
||||
# include <Bnd_Box.hxx>
|
||||
# include <BRepBndLib.hxx>
|
||||
|
@ -50,7 +51,7 @@ namespace PartDesign {
|
|||
|
||||
PROPERTY_SOURCE(PartDesign::Transformed, PartDesign::Feature)
|
||||
|
||||
Transformed::Transformed()
|
||||
Transformed::Transformed() : rejected(0)
|
||||
{
|
||||
ADD_PROPERTY(Originals,(0));
|
||||
Originals.setSize(0);
|
||||
|
@ -58,12 +59,12 @@ Transformed::Transformed()
|
|||
|
||||
void Transformed::positionBySupport(void)
|
||||
{
|
||||
Part::Feature *support = static_cast<Part::Feature*>(getOriginalObject());
|
||||
Part::Feature *support = static_cast<Part::Feature*>(getSupportObject());
|
||||
if ((support != NULL) && support->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
this->Placement.setValue(support->Placement.getValue());
|
||||
}
|
||||
|
||||
App::DocumentObject* Transformed::getOriginalObject() const
|
||||
App::DocumentObject* Transformed::getSupportObject() const
|
||||
{
|
||||
if (!Originals.getValues().empty())
|
||||
return Originals.getValues().front();
|
||||
|
@ -80,6 +81,8 @@ short Transformed::mustExecute() const
|
|||
|
||||
App::DocumentObjectExecReturn *Transformed::execute(void)
|
||||
{
|
||||
rejected.clear();
|
||||
|
||||
std::vector<App::DocumentObject*> originals = Originals.getValues();
|
||||
if (originals.empty()) // typically InsideMultiTransform
|
||||
return App::DocumentObject::StdReturn;
|
||||
|
@ -101,10 +104,10 @@ App::DocumentObjectExecReturn *Transformed::execute(void)
|
|||
// NOTE: Because of the way we define the support, FeatureTransformed can only work on
|
||||
// one Body feature at a time
|
||||
// TODO: Currently, the support is simply the first Original. Change this to the Body feature later
|
||||
Part::Feature* supportFeature = static_cast<Part::Feature*>(originals.front());
|
||||
Part::Feature* supportFeature = static_cast<Part::Feature*>(getSupportObject());
|
||||
const Part::TopoShape& supportTopShape = supportFeature->Shape.getShape();
|
||||
if (supportTopShape._Shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Cannot transform invalid shape");
|
||||
return new App::DocumentObjectExecReturn("Cannot transform invalid support shape");
|
||||
|
||||
// create an untransformed copy of the support shape
|
||||
Part::TopoShape supportShape(supportTopShape);
|
||||
|
@ -162,9 +165,10 @@ App::DocumentObjectExecReturn *Transformed::execute(void)
|
|||
Bnd_Box transformed_bb;
|
||||
BRepBndLib::Add(mkTrf.Shape(), transformed_bb);
|
||||
if (support_bb.Distance(transformed_bb) > Precision::Confusion()) {
|
||||
Base::Console().Warning("Transformed shape does not intersect original %s: Removed\n", (*o)->getNameInDocument());
|
||||
Base::Console().Warning("Transformed shape does not intersect support %s: Removed\n", (*o)->getNameInDocument());
|
||||
// Note: The removal happens in getSolid() after the fuse. If we remove here,
|
||||
// the histories get messed up and we get a crash
|
||||
rejected.push_back(*t);
|
||||
}
|
||||
builder.Add(transformedShapes, mkTrf.Shape());
|
||||
v_transformedShapes.push_back(mkTrf.Shape());
|
||||
|
@ -178,7 +182,7 @@ App::DocumentObjectExecReturn *Transformed::execute(void)
|
|||
Bnd_Box transformed_bb;
|
||||
BRepBndLib::Add(trfShape, transformed_bb);
|
||||
if (support_bb.Distance(transformed_bb) > Precision::Confusion()) {
|
||||
Base::Console().Warning("Transformed shape does not intersect original %s: Removed\n", (*o)->getNameInDocument());
|
||||
Base::Console().Warning("Transformed shape does not intersect support %s: Removed\n", (*o)->getNameInDocument());
|
||||
// Note: The removal happens in getSolid() after the fuse. If we remove here,
|
||||
// the histories get messed up and we get a crash
|
||||
}
|
||||
|
@ -231,8 +235,14 @@ App::DocumentObjectExecReturn *Transformed::execute(void)
|
|||
result = this->getSolid(mkFuse.Shape());
|
||||
// lets check if the result is a solid
|
||||
if (result.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Transformed: Resulting shape is not a solid", *o);
|
||||
|
||||
return new App::DocumentObjectExecReturn("Resulting shape is not a solid", *o);
|
||||
// check if mkFuse created more than one solids
|
||||
TopExp_Explorer xp;
|
||||
xp.Init(mkFuse.Shape(),TopAbs_SOLID);
|
||||
if (xp.More())
|
||||
xp.Next();
|
||||
if (!xp.More()) // There are no rejected transformations even
|
||||
rejected.clear(); // if the bb check guessed that there would be
|
||||
} else {
|
||||
BRepAlgoAPI_Cut mkCut(support, transformedShapes);
|
||||
if (!mkCut.IsDone())
|
||||
|
|
|
@ -45,11 +45,12 @@ public:
|
|||
Transformed();
|
||||
|
||||
/** The shapes to be transformed
|
||||
if Originals is empty the instance is just a container for storing transformation data */
|
||||
* if Originals is empty the instance is just a container for storing transformation data
|
||||
*/
|
||||
App::PropertyLinkList Originals;
|
||||
|
||||
/// Return first original, which serves as "Support" until Body feature becomes functional
|
||||
App::DocumentObject* getOriginalObject() const;
|
||||
App::DocumentObject* getSupportObject() const;
|
||||
|
||||
/// Get the list of transformations describing the members of the pattern
|
||||
// Note: Only the Scaled feature requires the originals
|
||||
|
@ -72,11 +73,13 @@ public:
|
|||
|
||||
void positionBySupport(void);
|
||||
|
||||
/** returns a list of the transformations that where rejected during the last execute
|
||||
* because they did not ovelap with the support
|
||||
*/
|
||||
const std::list<gp_Trsf> getRejectedTransformations(void) { return rejected; }
|
||||
|
||||
protected:
|
||||
void buildTransformHistory(BRepBuilderAPI_MakeShape& mkFuse,
|
||||
const TopoDS_Shape& newShape,
|
||||
const TopoDS_Shape& oldShape,
|
||||
const int index);
|
||||
std::list<gp_Trsf> rejected;
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "ViewProviderMirrored.h"
|
||||
#include "ViewProviderLinearPattern.h"
|
||||
#include "ViewProviderPolarPattern.h"
|
||||
//#include "ViewProviderScaled.h"
|
||||
#include "ViewProviderScaled.h"
|
||||
#include "ViewProviderMultiTransform.h"
|
||||
|
||||
//#include "resources/qrc_PartDesign.cpp"
|
||||
|
@ -95,7 +95,7 @@ void PartDesignGuiExport initPartDesignGui()
|
|||
PartDesignGui::ViewProviderMirrored ::init();
|
||||
PartDesignGui::ViewProviderLinearPattern ::init();
|
||||
PartDesignGui::ViewProviderPolarPattern ::init();
|
||||
// PartDesignGui::ViewProviderScaled ::init();
|
||||
PartDesignGui::ViewProviderScaled ::init();
|
||||
PartDesignGui::ViewProviderMultiTransform::init();
|
||||
|
||||
// add resources and reloads the translators
|
||||
|
|
|
@ -25,6 +25,7 @@ set(PartDesignGui_LIBS
|
|||
)
|
||||
|
||||
set(PartDesignGui_MOC_HDRS
|
||||
FeaturePickDialog.h
|
||||
TaskPadParameters.h
|
||||
TaskPocketParameters.h
|
||||
TaskChamferParameters.h
|
||||
|
@ -32,6 +33,7 @@ set(PartDesignGui_MOC_HDRS
|
|||
TaskHoleParameters.h
|
||||
TaskRevolutionParameters.h
|
||||
TaskGrooveParameters.h
|
||||
TaskTransformedMessages.h
|
||||
TaskTransformedParameters.h
|
||||
TaskMirroredParameters.h
|
||||
TaskLinearPatternParameters.h
|
||||
|
@ -45,6 +47,7 @@ SOURCE_GROUP("Moc" FILES ${PartDesignGui_MOC_SRCS})
|
|||
qt4_add_resources(PartDesignGui_SRCS Resources/PartDesign.qrc)
|
||||
|
||||
set(PartDesignGui_UIC_SRCS
|
||||
FeaturePickDialog.ui
|
||||
TaskPadParameters.ui
|
||||
TaskPocketParameters.ui
|
||||
TaskChamferParameters.ui
|
||||
|
@ -52,6 +55,7 @@ set(PartDesignGui_UIC_SRCS
|
|||
TaskHoleParameters.ui
|
||||
TaskRevolutionParameters.ui
|
||||
TaskGrooveParameters.ui
|
||||
TaskTransformedMessages.ui
|
||||
TaskMirroredParameters.ui
|
||||
TaskLinearPatternParameters.ui
|
||||
TaskPolarPatternParameters.ui
|
||||
|
@ -93,6 +97,9 @@ SET(PartDesignGuiViewProvider_SRCS
|
|||
SOURCE_GROUP("ViewProvider" FILES ${PartDesignGuiViewProvider_SRCS})
|
||||
|
||||
SET(PartDesignGuiTaskDlgs_SRCS
|
||||
FeaturePickDialog.ui
|
||||
FeaturePickDialog.cpp
|
||||
FeaturePickDialog.h
|
||||
TaskPadParameters.ui
|
||||
TaskPadParameters.cpp
|
||||
TaskPadParameters.h
|
||||
|
@ -111,8 +118,11 @@ SET(PartDesignGuiTaskDlgs_SRCS
|
|||
TaskGrooveParameters.ui
|
||||
TaskGrooveParameters.cpp
|
||||
TaskGrooveParameters.h
|
||||
TaskTransformedParameters.h
|
||||
TaskTransformedMessages.ui
|
||||
TaskTransformedMessages.cpp
|
||||
TaskTransformedMessages.h
|
||||
TaskTransformedParameters.cpp
|
||||
TaskTransformedParameters.h
|
||||
TaskMirroredParameters.ui
|
||||
TaskMirroredParameters.cpp
|
||||
TaskMirroredParameters.h
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
#include "FeaturePickDialog.h"
|
||||
|
||||
//===========================================================================
|
||||
// Part_Pad
|
||||
//===========================================================================
|
||||
|
@ -717,23 +719,36 @@ CmdPartDesignMirrored::CmdPartDesignMirrored()
|
|||
|
||||
void CmdPartDesignMirrored::activated(int iMsg)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
if (n < 1) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select one or more additive/subtractive features, please."));
|
||||
return;
|
||||
}
|
||||
// Get a valid original from the user
|
||||
// First check selections
|
||||
std::vector<App::DocumentObject*> features = getSelection().getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> subtractive = getSelection().getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Next create a list of all eligible objects
|
||||
if (features.size() == 0) {
|
||||
features = getDocument()->getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
subtractive = getDocument()->getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// If there is more than one selected or eligible object, show dialog and let user pick one
|
||||
if (features.size() > 1) {
|
||||
PartDesignGui::FeaturePickDialog Dlg(features);
|
||||
if ((Dlg.exec() != QDialog::Accepted) || (features = Dlg.getFeatures()).empty())
|
||||
return; // Cancelled or nothing selected
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid features in this document"),
|
||||
QObject::tr("Please create a subtractive or additive feature first, please"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::string FeatName = getUniqueObjectName("Mirrored");
|
||||
|
||||
std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();
|
||||
std::stringstream str;
|
||||
std::vector<std::string> tempSelNames;
|
||||
str << "App.activeDocument()." << FeatName << ".Originals = [";
|
||||
for (std::vector<Gui::SelectionSingleton::SelObj>::iterator it = Sel.begin(); it != Sel.end(); ++it){
|
||||
str << "App.activeDocument()." << it->FeatName << ",";
|
||||
tempSelNames.push_back(it->FeatName);
|
||||
for (std::vector<App::DocumentObject*>::iterator it = features.begin(); it != features.end(); ++it){
|
||||
str << "App.activeDocument()." << (*it)->getNameInDocument() << ",";
|
||||
tempSelNames.push_back((*it)->getNameInDocument());
|
||||
}
|
||||
str << "]";
|
||||
|
||||
|
@ -756,9 +771,7 @@ void CmdPartDesignMirrored::activated(int iMsg)
|
|||
|
||||
bool CmdPartDesignMirrored::isActive(void)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
return n >= 1;
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -780,23 +793,36 @@ CmdPartDesignLinearPattern::CmdPartDesignLinearPattern()
|
|||
|
||||
void CmdPartDesignLinearPattern::activated(int iMsg)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
if (n < 1) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select one or more additive/subtractive features, please."));
|
||||
return;
|
||||
}
|
||||
// Get a valid original from the user
|
||||
// First check selections
|
||||
std::vector<App::DocumentObject*> features = getSelection().getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> subtractive = getSelection().getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Next create a list of all eligible objects
|
||||
if (features.size() == 0) {
|
||||
features = getDocument()->getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
subtractive = getDocument()->getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// If there is more than one selected or eligible object, show dialog and let user pick one
|
||||
if (features.size() > 1) {
|
||||
PartDesignGui::FeaturePickDialog Dlg(features);
|
||||
if ((Dlg.exec() != QDialog::Accepted) || (features = Dlg.getFeatures()).empty())
|
||||
return; // Cancelled or nothing selected
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid features in this document"),
|
||||
QObject::tr("Please create a subtractive or additive feature first, please"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::string FeatName = getUniqueObjectName("LinearPattern");
|
||||
|
||||
std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();
|
||||
std::stringstream str;
|
||||
std::vector<std::string> tempSelNames;
|
||||
str << "App.activeDocument()." << FeatName << ".Originals = [";
|
||||
for (std::vector<Gui::SelectionSingleton::SelObj>::iterator it = Sel.begin(); it != Sel.end(); ++it){
|
||||
str << "App.activeDocument()." << it->FeatName << ",";
|
||||
tempSelNames.push_back(it->FeatName);
|
||||
for (std::vector<App::DocumentObject*>::iterator it = features.begin(); it != features.end(); ++it){
|
||||
str << "App.activeDocument()." << (*it)->getNameInDocument() << ",";
|
||||
tempSelNames.push_back((*it)->getNameInDocument());
|
||||
}
|
||||
str << "]";
|
||||
|
||||
|
@ -819,9 +845,7 @@ void CmdPartDesignLinearPattern::activated(int iMsg)
|
|||
|
||||
bool CmdPartDesignLinearPattern::isActive(void)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
return n >= 1;
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -843,23 +867,36 @@ CmdPartDesignPolarPattern::CmdPartDesignPolarPattern()
|
|||
|
||||
void CmdPartDesignPolarPattern::activated(int iMsg)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
if (n < 1) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select one or more additive/subtractive features, please."));
|
||||
return;
|
||||
}
|
||||
// Get a valid original from the user
|
||||
// First check selections
|
||||
std::vector<App::DocumentObject*> features = getSelection().getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> subtractive = getSelection().getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Next create a list of all eligible objects
|
||||
if (features.size() == 0) {
|
||||
features = getDocument()->getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
subtractive = getDocument()->getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// If there is more than one selected or eligible object, show dialog and let user pick one
|
||||
if (features.size() > 1) {
|
||||
PartDesignGui::FeaturePickDialog Dlg(features);
|
||||
if ((Dlg.exec() != QDialog::Accepted) || (features = Dlg.getFeatures()).empty())
|
||||
return; // Cancelled or nothing selected
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid features in this document"),
|
||||
QObject::tr("Please create a subtractive or additive feature first, please"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::string FeatName = getUniqueObjectName("PolarPattern");
|
||||
|
||||
std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();
|
||||
std::stringstream str;
|
||||
std::vector<std::string> tempSelNames;
|
||||
str << "App.activeDocument()." << FeatName << ".Originals = [";
|
||||
for (std::vector<Gui::SelectionSingleton::SelObj>::iterator it = Sel.begin(); it != Sel.end(); ++it){
|
||||
str << "App.activeDocument()." << it->FeatName << ",";
|
||||
tempSelNames.push_back(it->FeatName);
|
||||
for (std::vector<App::DocumentObject*>::iterator it = features.begin(); it != features.end(); ++it){
|
||||
str << "App.activeDocument()." << (*it)->getNameInDocument() << ",";
|
||||
tempSelNames.push_back((*it)->getNameInDocument());
|
||||
}
|
||||
str << "]";
|
||||
|
||||
|
@ -882,9 +919,7 @@ void CmdPartDesignPolarPattern::activated(int iMsg)
|
|||
|
||||
bool CmdPartDesignPolarPattern::isActive(void)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
return n >= 1;
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -906,23 +941,36 @@ CmdPartDesignScaled::CmdPartDesignScaled()
|
|||
|
||||
void CmdPartDesignScaled::activated(int iMsg)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
if (n < 1) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select one or more additive/subtractive features, please."));
|
||||
return;
|
||||
}
|
||||
// Get a valid original from the user
|
||||
// First check selections
|
||||
std::vector<App::DocumentObject*> features = getSelection().getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> subtractive = getSelection().getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Next create a list of all eligible objects
|
||||
if (features.size() == 0) {
|
||||
features = getDocument()->getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
subtractive = getDocument()->getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// If there is more than one selected or eligible object, show dialog and let user pick one
|
||||
if (features.size() > 1) {
|
||||
PartDesignGui::FeaturePickDialog Dlg(features);
|
||||
if ((Dlg.exec() != QDialog::Accepted) || (features = Dlg.getFeatures()).empty())
|
||||
return; // Cancelled or nothing selected
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid features in this document"),
|
||||
QObject::tr("Please create a subtractive or additive feature first, please"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::string FeatName = getUniqueObjectName("Scaled");
|
||||
|
||||
std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();
|
||||
std::stringstream str;
|
||||
std::vector<std::string> tempSelNames;
|
||||
str << "App.activeDocument()." << FeatName << ".Originals = [";
|
||||
for (std::vector<Gui::SelectionSingleton::SelObj>::iterator it = Sel.begin(); it != Sel.end(); ++it){
|
||||
str << "App.activeDocument()." << it->FeatName << ",";
|
||||
tempSelNames.push_back(it->FeatName);
|
||||
for (std::vector<App::DocumentObject*>::iterator it = features.begin(); it != features.end(); ++it){
|
||||
str << "App.activeDocument()." << (*it)->getNameInDocument() << ",";
|
||||
tempSelNames.push_back((*it)->getNameInDocument());
|
||||
}
|
||||
str << "]";
|
||||
|
||||
|
@ -944,9 +992,7 @@ void CmdPartDesignScaled::activated(int iMsg)
|
|||
|
||||
bool CmdPartDesignScaled::isActive(void)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
return n >= 1;
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -968,23 +1014,36 @@ CmdPartDesignMultiTransform::CmdPartDesignMultiTransform()
|
|||
|
||||
void CmdPartDesignMultiTransform::activated(int iMsg)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
if (n < 1) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select one or more additive/subtractive features, please."));
|
||||
return;
|
||||
}
|
||||
// Get a valid original from the user
|
||||
// First check selections
|
||||
std::vector<App::DocumentObject*> features = getSelection().getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> subtractive = getSelection().getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Next create a list of all eligible objects
|
||||
if (features.size() == 0) {
|
||||
features = getDocument()->getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
subtractive = getDocument()->getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// If there is more than one selected or eligible object, show dialog and let user pick one
|
||||
if (features.size() > 1) {
|
||||
PartDesignGui::FeaturePickDialog Dlg(features);
|
||||
if ((Dlg.exec() != QDialog::Accepted) || (features = Dlg.getFeatures()).empty())
|
||||
return; // Cancelled or nothing selected
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid features in this document"),
|
||||
QObject::tr("Please create a subtractive or additive feature first, please"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::string FeatName = getUniqueObjectName("MultiTransform");
|
||||
|
||||
std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();
|
||||
std::stringstream str;
|
||||
std::vector<std::string> tempSelNames;
|
||||
str << "App.activeDocument()." << FeatName << ".Originals = [";
|
||||
for (std::vector<Gui::SelectionSingleton::SelObj>::iterator it = Sel.begin(); it != Sel.end(); ++it){
|
||||
str << "App.activeDocument()." << it->FeatName << ",";
|
||||
tempSelNames.push_back(it->FeatName);
|
||||
for (std::vector<App::DocumentObject*>::iterator it = features.begin(); it != features.end(); ++it){
|
||||
str << "App.activeDocument()." << (*it)->getNameInDocument() << ",";
|
||||
tempSelNames.push_back((*it)->getNameInDocument());
|
||||
}
|
||||
str << "]";
|
||||
|
||||
|
@ -1002,9 +1061,7 @@ void CmdPartDesignMultiTransform::activated(int iMsg)
|
|||
|
||||
bool CmdPartDesignMultiTransform::isActive(void)
|
||||
{
|
||||
unsigned n = getSelection().countObjectsOfType(PartDesign::Additive::getClassTypeId()) +
|
||||
getSelection().countObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
return n >= 1;
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
|
||||
|
|
75
src/Mod/PartDesign/Gui/FeaturePickDialog.cpp
Normal file
75
src/Mod/PartDesign/Gui/FeaturePickDialog.cpp
Normal file
|
@ -0,0 +1,75 @@
|
|||
/******************************************************************************
|
||||
* Copyright (c)2012 Jan Rheinlaender <jrheinlaender@users.sourceforge.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 <QPixmap>
|
||||
# include <QDialog>
|
||||
# include <QListIterator>
|
||||
#endif
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <App/Document.h>
|
||||
#include <Base/Tools.h>
|
||||
|
||||
#include "ui_FeaturePickDialog.h"
|
||||
#include "FeaturePickDialog.h"
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
FeaturePickDialog::FeaturePickDialog(std::vector<App::DocumentObject*>& objects)
|
||||
: QDialog(Gui::getMainWindow()), ui(new Ui_FeaturePickDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
for (std::vector<App::DocumentObject*>::const_iterator o = objects.begin(); o != objects.end(); o++)
|
||||
ui->listWidget->addItem(QString::fromAscii((*o)->getNameInDocument()));
|
||||
}
|
||||
|
||||
FeaturePickDialog::~FeaturePickDialog()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> FeaturePickDialog::getFeatures() {
|
||||
std::vector<App::DocumentObject*> result;
|
||||
|
||||
for (std::vector<QString>::const_iterator s = features.begin(); s != features.end(); s++)
|
||||
result.push_back(App::GetApplication().getActiveDocument()->getObject(s->toAscii().data()));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FeaturePickDialog::accept()
|
||||
{
|
||||
features.clear();
|
||||
QListIterator<QListWidgetItem*> i(ui->listWidget->selectedItems());
|
||||
while (i.hasNext())
|
||||
features.push_back(i.next()->text());
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
#include "moc_FeaturePickDialog.cpp"
|
55
src/Mod/PartDesign/Gui/FeaturePickDialog.h
Normal file
55
src/Mod/PartDesign/Gui/FeaturePickDialog.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
/******************************************************************************
|
||||
* Copyright (c)2012 Jan Rheinlaender <jrheinlaender@users.sourceforge.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 PARTDESIGNGUI_FeaturePickDialog_H
|
||||
#define PARTDESIGNGUI_FeaturePickDialog_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QString>
|
||||
#include <App/DocumentObject.h>
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
class Ui_FeaturePickDialog;
|
||||
class FeaturePickDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FeaturePickDialog(std::vector<App::DocumentObject*> &objects);
|
||||
~FeaturePickDialog();
|
||||
|
||||
std::vector<App::DocumentObject*> getFeatures();
|
||||
|
||||
void accept();
|
||||
|
||||
protected Q_SLOTS:
|
||||
|
||||
private:
|
||||
Ui_FeaturePickDialog* ui;
|
||||
|
||||
std::vector<QString> features;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // PARTDESIGNGUI_FeaturePickDialog_H
|
67
src/Mod/PartDesign/Gui/FeaturePickDialog.ui
Normal file
67
src/Mod/PartDesign/Gui/FeaturePickDialog.ui
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PartDesignGui::FeaturePickDialog</class>
|
||||
<widget class="QDialog" name="PartDesignGui::FeaturePickDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>218</width>
|
||||
<height>235</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Choose feature</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>PartDesignGui::FeaturePickDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>PartDesignGui::FeaturePickDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "ui_TaskLinearPatternParameters.h"
|
||||
#include "TaskLinearPatternParameters.h"
|
||||
#include "TaskMultiTransformParameters.h"
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <Gui/Application.h>
|
||||
|
@ -41,7 +42,6 @@
|
|||
#include <Gui/Command.h>
|
||||
#include <Mod/PartDesign/App/FeatureLinearPattern.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
#include "TaskMultiTransformParameters.h"
|
||||
|
||||
using namespace PartDesignGui;
|
||||
using namespace Gui;
|
||||
|
@ -62,7 +62,9 @@ TaskLinearPatternParameters::TaskLinearPatternParameters(ViewProviderTransformed
|
|||
ui->buttonOK->hide();
|
||||
ui->checkBoxUpdateView->setEnabled(true);
|
||||
|
||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
referenceSelectionMode = false;
|
||||
|
||||
blockUpdate = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
setupUI();
|
||||
}
|
||||
|
||||
|
@ -79,10 +81,13 @@ TaskLinearPatternParameters::TaskLinearPatternParameters(TaskMultiTransformParam
|
|||
layout->addWidget(proxy);
|
||||
|
||||
ui->buttonOK->setEnabled(true);
|
||||
ui->listFeatures->hide();
|
||||
ui->labelOriginal->hide();
|
||||
ui->lineOriginal->hide();
|
||||
ui->checkBoxUpdateView->hide();
|
||||
|
||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
referenceSelectionMode = false;
|
||||
|
||||
blockUpdate = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
setupUI();
|
||||
}
|
||||
|
||||
|
@ -100,35 +105,24 @@ void TaskLinearPatternParameters::setupUI()
|
|||
this, SLOT(onLength(double)));
|
||||
connect(ui->spinOccurrences, SIGNAL(valueChanged(int)),
|
||||
this, SLOT(onOccurrences(int)));
|
||||
connect(ui->buttonReference, SIGNAL(pressed()),
|
||||
this, SLOT(onButtonReference()));
|
||||
connect(ui->buttonReference, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onButtonReference(bool)));
|
||||
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onUpdateView(bool)));
|
||||
|
||||
// TODO: The following code could be generic in TaskTransformedParameters
|
||||
// if it were possible to make ui_TaskLinearPatternParameters a subclass of
|
||||
// ui_TaskTransformedParameters
|
||||
// ---------------------
|
||||
// Add a context menu to the listview of the originals to delete items
|
||||
QAction* action = new QAction(tr("Delete"), ui->listFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onOriginalDeleted()));
|
||||
ui->listFeatures->addAction(action);
|
||||
ui->listFeatures->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
// Get the feature data
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
std::vector<App::DocumentObject*> originals = pcLinearPattern->Originals.getValues();
|
||||
|
||||
// Fill data into dialog elements
|
||||
ui->listFeatures->setEnabled(true);
|
||||
ui->listFeatures->clear();
|
||||
ui->lineOriginal->setEnabled(false);
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); i++)
|
||||
{
|
||||
if ((*i) != NULL)
|
||||
ui->listFeatures->addItem(QString::fromAscii((*i)->getNameInDocument()));
|
||||
if ((*i) != NULL) { // find the first valid original
|
||||
ui->lineOriginal->setText(QString::fromAscii((*i)->getNameInDocument()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
QMetaObject::invokeMethod(ui->listFeatures, "setFocus", Qt::QueuedConnection);
|
||||
// ---------------------
|
||||
|
||||
ui->buttonX->setEnabled(true);
|
||||
|
@ -144,8 +138,10 @@ void TaskLinearPatternParameters::setupUI()
|
|||
|
||||
void TaskLinearPatternParameters::updateUI()
|
||||
{
|
||||
if (updateUIinProgress) return;
|
||||
updateUIinProgress = true;
|
||||
if (blockUpdate)
|
||||
return;
|
||||
blockUpdate = true;
|
||||
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
|
||||
App::DocumentObject* directionFeature = pcLinearPattern->Direction.getValue();
|
||||
|
@ -155,9 +151,9 @@ void TaskLinearPatternParameters::updateUI()
|
|||
double length = pcLinearPattern->Length.getValue();
|
||||
unsigned occurrences = pcLinearPattern->Occurrences.getValue();
|
||||
|
||||
if ((featureSelectionMode || insideMultiTransform) && !stdDirection.empty())
|
||||
ui->buttonReference->setChecked(referenceSelectionMode);
|
||||
if (!stdDirection.empty())
|
||||
{
|
||||
ui->buttonReference->setDown(false);
|
||||
ui->buttonX->setAutoExclusive(true);
|
||||
ui->buttonY->setAutoExclusive(true);
|
||||
ui->buttonZ->setAutoExclusive(true);
|
||||
|
@ -165,80 +161,65 @@ void TaskLinearPatternParameters::updateUI()
|
|||
ui->buttonY->setChecked(stdDirection == "Y");
|
||||
ui->buttonZ->setChecked(stdDirection == "Z");
|
||||
ui->lineReference->setText(tr(""));
|
||||
} else if ((directionFeature != NULL) && !directions.empty()) {
|
||||
} else if (directionFeature != NULL && !directions.empty()) {
|
||||
ui->buttonX->setAutoExclusive(false);
|
||||
ui->buttonY->setAutoExclusive(false);
|
||||
ui->buttonZ->setAutoExclusive(false);
|
||||
ui->buttonX->setChecked(false);
|
||||
ui->buttonY->setChecked(false);
|
||||
ui->buttonZ->setChecked(false);
|
||||
ui->buttonReference->setDown(!featureSelectionMode);
|
||||
ui->lineReference->setText(QString::fromAscii(directions.front().c_str()));
|
||||
} else {
|
||||
// Error message?
|
||||
ui->lineReference->setText(tr(""));
|
||||
}
|
||||
if (referenceSelectionMode)
|
||||
ui->lineReference->setText(tr("Select an edge or a face"));
|
||||
|
||||
// Note: These three lines would trigger onLength(), on Occurrences() and another updateUI() if we
|
||||
// didn't check for updateUIinProgress
|
||||
// didn't check for blockUpdate
|
||||
ui->checkReverse->setChecked(reverse);
|
||||
ui->spinLength->setValue(length);
|
||||
ui->spinOccurrences->setValue(occurrences);
|
||||
|
||||
updateUIinProgress = false;
|
||||
blockUpdate = false;
|
||||
}
|
||||
|
||||
void TaskLinearPatternParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
App::DocumentObject* selectedObject = pcLinearPattern->getDocument()->getActiveObject();
|
||||
if ((selectedObject == NULL) || !selectedObject->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return;
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
|
||||
if (featureSelectionMode) {
|
||||
if (originalSelected(msg))
|
||||
ui->listFeatures->addItem(QString::fromAscii(selectedObject->getNameInDocument()));
|
||||
} else {
|
||||
if (!msg.pSubName || msg.pSubName[0] == '\0')
|
||||
if (strcmp(msg.pDocName, getObject()->getDocument()->getName()) != 0)
|
||||
return;
|
||||
|
||||
std::string element(msg.pSubName);
|
||||
std::string subName(msg.pSubName);
|
||||
if (originalSelected(msg)) {
|
||||
ui->lineOriginal->setText(QString::fromAscii(msg.pObjectName));
|
||||
} else if (referenceSelectionMode &&
|
||||
((subName.size() > 4 && subName.substr(0,4) == "Edge") ||
|
||||
(subName.size() > 4 && subName.substr(0,4) == "Face"))) {
|
||||
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
// TODO
|
||||
// if (originalElementName == "") {
|
||||
// Base::Console().Error("Element created by this pattern cannot be used for direction\n");
|
||||
// return;
|
||||
// }
|
||||
if (strcmp(msg.pObjectName, getSupportObject()->getNameInDocument()) != 0)
|
||||
return;
|
||||
|
||||
std::vector<std::string> directions;
|
||||
directions.push_back(element.c_str());
|
||||
pcLinearPattern->Direction.setValue(getOriginalObject(), directions);
|
||||
exitSelectionMode();
|
||||
if (!blockUpdate) {
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
std::vector<std::string> directions(1,subName);
|
||||
pcLinearPattern->Direction.setValue(getSupportObject(), directions);
|
||||
pcLinearPattern->StdDirection.setValue("");
|
||||
|
||||
if (insideMultiTransform) {
|
||||
if (parentTask->updateView())
|
||||
recomputeFeature();
|
||||
} else
|
||||
if (ui->checkBoxUpdateView->isChecked())
|
||||
recomputeFeature();
|
||||
|
||||
if (!insideMultiTransform)
|
||||
featureSelectionMode = true; // Jump back to selection of originals
|
||||
|
||||
showObject();
|
||||
hideOriginals();
|
||||
updateUI();
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
else {
|
||||
ui->buttonReference->setChecked(referenceSelectionMode);
|
||||
ui->lineReference->setText(QString::fromAscii(subName.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskLinearPatternParameters::onOriginalDeleted()
|
||||
{
|
||||
int row = ui->listFeatures->currentIndex().row();
|
||||
TaskTransformedParameters::onOriginalDeleted(row);
|
||||
ui->listFeatures->model()->removeRow(row);
|
||||
}
|
||||
|
||||
void TaskLinearPatternParameters::onButtonX() {
|
||||
onStdDirection("X");
|
||||
}
|
||||
|
@ -252,118 +233,124 @@ void TaskLinearPatternParameters::onButtonZ() {
|
|||
}
|
||||
|
||||
void TaskLinearPatternParameters::onCheckReverse(const bool on) {
|
||||
if (updateUIinProgress) return;
|
||||
if (blockUpdate)
|
||||
return;
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
pcLinearPattern->Reversed.setValue(on);
|
||||
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskLinearPatternParameters::onLength(const double l) {
|
||||
if (updateUIinProgress) return;
|
||||
if (blockUpdate)
|
||||
return;
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
pcLinearPattern->Length.setValue(l);
|
||||
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskLinearPatternParameters::onOccurrences(const int n) {
|
||||
if (updateUIinProgress) return;
|
||||
if (blockUpdate)
|
||||
return;
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
pcLinearPattern->Occurrences.setValue(n);
|
||||
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskLinearPatternParameters::onStdDirection(const std::string& dir) {
|
||||
if (updateUIinProgress) return;
|
||||
if (blockUpdate)
|
||||
return;
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
pcLinearPattern->StdDirection.setValue(dir.c_str());
|
||||
pcLinearPattern->Direction.setValue(NULL);
|
||||
if (!insideMultiTransform)
|
||||
featureSelectionMode = true;
|
||||
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskLinearPatternParameters::onButtonReference()
|
||||
void TaskLinearPatternParameters::onButtonReference(bool checked)
|
||||
{
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
pcLinearPattern->StdDirection.setValue("");
|
||||
featureSelectionMode = false;
|
||||
hideObject();
|
||||
showOriginals();
|
||||
if (checked ) {
|
||||
hideObject();
|
||||
showOriginals();
|
||||
referenceSelectionMode = true;
|
||||
Gui::Selection().clearSelection();
|
||||
addReferenceSelectionGate(true, true);
|
||||
} else {
|
||||
exitSelectionMode();
|
||||
}
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskLinearPatternParameters::onUpdateView(bool on)
|
||||
{
|
||||
ui->buttonX->blockSignals(!on);
|
||||
ui->buttonY->blockSignals(!on);
|
||||
ui->buttonZ->blockSignals(!on);
|
||||
ui->listFeatures->blockSignals(!on);
|
||||
ui->checkReverse->blockSignals(!on);
|
||||
ui->spinLength->blockSignals(!on);
|
||||
ui->spinOccurrences->blockSignals(!on);
|
||||
blockUpdate = !on;
|
||||
if (on) {
|
||||
// Do the same like in TaskDlgLinearPatternParameters::accept() but without doCommand
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
|
||||
std::string direction = getDirection();
|
||||
if (!direction.empty()) {
|
||||
std::vector<std::string> directions(1,direction);
|
||||
pcLinearPattern->Direction.setValue(getSupportObject(), directions);
|
||||
} else
|
||||
pcLinearPattern->Direction.setValue(NULL);
|
||||
|
||||
std::string stdDirection = getStdDirection();
|
||||
if (!stdDirection.empty())
|
||||
pcLinearPattern->StdDirection.setValue(stdDirection.c_str());
|
||||
else
|
||||
pcLinearPattern->StdDirection.setValue(NULL);
|
||||
|
||||
pcLinearPattern->Reversed.setValue(getReverse());
|
||||
pcLinearPattern->Length.setValue(getLength());
|
||||
pcLinearPattern->Occurrences.setValue(getOccurrences());
|
||||
|
||||
recomputeFeature();
|
||||
}
|
||||
}
|
||||
|
||||
const std::string TaskLinearPatternParameters::getStdDirection(void) const
|
||||
{
|
||||
std::string stdDirection;
|
||||
|
||||
if (ui->buttonX->isChecked())
|
||||
stdDirection = "X";
|
||||
return std::string("X");
|
||||
else if (ui->buttonY->isChecked())
|
||||
stdDirection = "Y";
|
||||
return std::string("Y");
|
||||
else if (ui->buttonZ->isChecked())
|
||||
stdDirection = "Z";
|
||||
|
||||
if (!stdDirection.empty())
|
||||
return std::string("\"") + stdDirection + "\"";
|
||||
else
|
||||
return std::string("");
|
||||
return std::string("Z");
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
const QString TaskLinearPatternParameters::getDirection(void) const
|
||||
const std::string TaskLinearPatternParameters::getDirection(void) const
|
||||
{
|
||||
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
|
||||
App::DocumentObject* feature = pcLinearPattern->Direction.getValue();
|
||||
if (feature == NULL)
|
||||
return QString::fromUtf8("");
|
||||
std::vector<std::string> directions = pcLinearPattern->Direction.getSubValues();
|
||||
QString buf;
|
||||
|
||||
if ((feature != NULL) && !directions.empty()) {
|
||||
buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
||||
buf = buf.arg(QString::fromUtf8(feature->getNameInDocument()));
|
||||
buf = buf.arg(QString::fromUtf8(directions.front().c_str()));
|
||||
}
|
||||
else
|
||||
buf = QString::fromUtf8("");
|
||||
|
||||
return buf;
|
||||
return ui->lineReference->text().toStdString();
|
||||
}
|
||||
|
||||
const bool TaskLinearPatternParameters::getReverse(void) const {
|
||||
const bool TaskLinearPatternParameters::getReverse(void) const
|
||||
{
|
||||
return ui->checkReverse->isChecked();
|
||||
}
|
||||
|
||||
const double TaskLinearPatternParameters::getLength(void) const {
|
||||
const double TaskLinearPatternParameters::getLength(void) const
|
||||
{
|
||||
return ui->spinLength->value();
|
||||
}
|
||||
|
||||
const unsigned TaskLinearPatternParameters::getOccurrences(void) const {
|
||||
const unsigned TaskLinearPatternParameters::getOccurrences(void) const
|
||||
{
|
||||
return ui->spinOccurrences->value();
|
||||
}
|
||||
|
||||
|
||||
TaskLinearPatternParameters::~TaskLinearPatternParameters()
|
||||
{
|
||||
delete ui;
|
||||
|
@ -404,12 +391,16 @@ bool TaskDlgLinearPatternParameters::accept()
|
|||
return false;
|
||||
|
||||
TaskLinearPatternParameters* linearpatternParameter = static_cast<TaskLinearPatternParameters*>(parameter);
|
||||
std::string direction = linearpatternParameter->getDirection().toStdString();
|
||||
if (!direction.empty())
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = %s", name.c_str(), direction.c_str());
|
||||
std::string direction = linearpatternParameter->getDirection();
|
||||
if (!direction.empty()) {
|
||||
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
||||
buf = buf.arg(QString::fromUtf8(linearpatternParameter->getSupportObject()->getNameInDocument()));
|
||||
buf = buf.arg(QString::fromUtf8(direction.c_str()));
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = %s", name.c_str(), buf.toStdString().c_str());
|
||||
} else
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = None", name.c_str());
|
||||
std::string stdDirection = linearpatternParameter->getStdDirection();
|
||||
if (!stdDirection.empty())
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.StdDirection = %s",name.c_str(),stdDirection.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.StdDirection = \"%s\"",name.c_str(),stdDirection.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),linearpatternParameter->getReverse());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Length = %f",name.c_str(),linearpatternParameter->getLength());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Occurrences = %u",name.c_str(),linearpatternParameter->getOccurrences());
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace Gui {
|
|||
class ViewProvider;
|
||||
}
|
||||
|
||||
namespace PartDesignGui {
|
||||
namespace PartDesignGui {
|
||||
|
||||
class TaskMultiTransformParameters;
|
||||
|
||||
|
@ -56,8 +56,8 @@ public:
|
|||
TaskLinearPatternParameters(TaskMultiTransformParameters *parentTask, QLayout *layout);
|
||||
virtual ~TaskLinearPatternParameters();
|
||||
|
||||
const QString getDirection(void) const;
|
||||
const std::string getStdDirection(void) const;
|
||||
const std::string getDirection(void) const;
|
||||
const bool getReverse(void) const;
|
||||
const double getLength(void) const;
|
||||
const unsigned getOccurrences(void) const;
|
||||
|
@ -70,17 +70,16 @@ private Q_SLOTS:
|
|||
void onCheckReverse(const bool on);
|
||||
void onLength(const double l);
|
||||
void onOccurrences(const int n);
|
||||
virtual void onButtonReference();
|
||||
virtual void onOriginalDeleted();
|
||||
void onButtonReference(const bool checked);
|
||||
virtual void onUpdateView(bool);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *e);
|
||||
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
|
||||
private:
|
||||
void updateUI();
|
||||
void setupUI();
|
||||
void updateUI();
|
||||
|
||||
private:
|
||||
Ui_TaskLinearPatternParameters* ui;
|
||||
|
|
|
@ -15,7 +15,18 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="listFeatures"/>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutOriginal">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelOriginal">
|
||||
<property name="text">
|
||||
<string>Original feature</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineOriginal"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
|
@ -52,6 +63,9 @@
|
|||
<property name="text">
|
||||
<string>Direction</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -132,6 +146,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#include <Mod/PartDesign/App/FeatureMirrored.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
|
||||
|
||||
using namespace PartDesignGui;
|
||||
using namespace Gui;
|
||||
|
||||
|
@ -57,12 +56,15 @@ TaskMirroredParameters::TaskMirroredParameters(ViewProviderTransformed *Transfor
|
|||
ui = new Ui_TaskMirroredParameters();
|
||||
ui->setupUi(proxy);
|
||||
QMetaObject::connectSlotsByName(this);
|
||||
|
||||
this->groupLayout()->addWidget(proxy);
|
||||
|
||||
ui->buttonOK->hide();
|
||||
ui->checkBoxUpdateView->setEnabled(true);
|
||||
|
||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
referenceSelectionMode = false;
|
||||
|
||||
blockUpdate = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
setupUI();
|
||||
}
|
||||
|
||||
|
@ -79,10 +81,13 @@ TaskMirroredParameters::TaskMirroredParameters(TaskMultiTransformParameters *par
|
|||
layout->addWidget(proxy);
|
||||
|
||||
ui->buttonOK->setEnabled(true);
|
||||
ui->listFeatures->hide();
|
||||
ui->labelOriginal->hide();
|
||||
ui->lineOriginal->hide();
|
||||
ui->checkBoxUpdateView->hide();
|
||||
|
||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
referenceSelectionMode = false;
|
||||
|
||||
blockUpdate = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
setupUI();
|
||||
}
|
||||
|
||||
|
@ -94,35 +99,24 @@ void TaskMirroredParameters::setupUI()
|
|||
this, SLOT(onButtonXZ()));
|
||||
connect(ui->buttonYZ, SIGNAL(pressed()),
|
||||
this, SLOT(onButtonYZ()));
|
||||
connect(ui->buttonReference, SIGNAL(pressed()),
|
||||
this, SLOT(onButtonReference()));
|
||||
connect(ui->buttonReference, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onButtonReference(bool)));
|
||||
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onUpdateView(bool)));
|
||||
|
||||
// TODO: The following code could be generic in TaskTransformedParameters
|
||||
// if it were possible to make ui_TaskMirroredParameters a subclass of
|
||||
// ui_TaskTransformedParameters
|
||||
// ---------------------
|
||||
// Add a context menu to the listview of the originals to delete items
|
||||
QAction* action = new QAction(tr("Delete"), ui->listFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onOriginalDeleted()));
|
||||
ui->listFeatures->addAction(action);
|
||||
ui->listFeatures->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
// Get the feature data
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
std::vector<App::DocumentObject*> originals = pcMirrored->Originals.getValues();
|
||||
|
||||
// Fill data into dialog elements
|
||||
ui->listFeatures->setEnabled(true);
|
||||
ui->listFeatures->clear();
|
||||
ui->lineOriginal->setEnabled(false);
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); i++)
|
||||
{
|
||||
if ((*i) != NULL)
|
||||
ui->listFeatures->addItem(QString::fromAscii((*i)->getNameInDocument()));
|
||||
if ((*i) != NULL) { // find the first valid original
|
||||
ui->lineOriginal->setText(QString::fromAscii((*i)->getNameInDocument()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
QMetaObject::invokeMethod(ui->listFeatures, "setFocus", Qt::QueuedConnection);
|
||||
// ---------------------
|
||||
|
||||
ui->buttonXY->setEnabled(true);
|
||||
|
@ -130,22 +124,22 @@ void TaskMirroredParameters::setupUI()
|
|||
ui->buttonYZ->setEnabled(true);
|
||||
ui->buttonReference->setEnabled(true);
|
||||
ui->lineReference->setEnabled(false); // This is never enabled since it is for optical feed-back only
|
||||
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskMirroredParameters::updateUI()
|
||||
{
|
||||
if (updateUIinProgress) return;
|
||||
updateUIinProgress = true;
|
||||
if (blockUpdate)
|
||||
return;
|
||||
blockUpdate = true;
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
App::DocumentObject* mirrorPlaneFeature = pcMirrored->MirrorPlane.getValue();
|
||||
std::vector<std::string> mirrorPlanes = pcMirrored->MirrorPlane.getSubValues();
|
||||
std::string stdMirrorPlane = pcMirrored->StdMirrorPlane.getValue();
|
||||
|
||||
if ((featureSelectionMode || insideMultiTransform) && !stdMirrorPlane.empty())
|
||||
ui->buttonReference->setChecked(referenceSelectionMode);
|
||||
if (!stdMirrorPlane.empty())
|
||||
{
|
||||
ui->buttonReference->setDown(false);
|
||||
ui->buttonXY->setAutoExclusive(true);
|
||||
ui->buttonXZ->setAutoExclusive(true);
|
||||
ui->buttonYZ->setAutoExclusive(true);
|
||||
|
@ -153,81 +147,67 @@ void TaskMirroredParameters::updateUI()
|
|||
ui->buttonXZ->setChecked(stdMirrorPlane == "XZ");
|
||||
ui->buttonYZ->setChecked(stdMirrorPlane == "YZ");
|
||||
ui->lineReference->setText(tr(""));
|
||||
} else if ((mirrorPlaneFeature != NULL) && !mirrorPlanes.empty()) {
|
||||
} else if (mirrorPlaneFeature != NULL && !mirrorPlanes.empty()) {
|
||||
ui->buttonXY->setAutoExclusive(false);
|
||||
ui->buttonXZ->setAutoExclusive(false);
|
||||
ui->buttonYZ->setAutoExclusive(false);
|
||||
ui->buttonXY->setChecked(false);
|
||||
ui->buttonXZ->setChecked(false);
|
||||
ui->buttonYZ->setChecked(false);
|
||||
ui->buttonReference->setDown(!featureSelectionMode);
|
||||
ui->lineReference->setText(QString::fromAscii(mirrorPlanes.front().c_str()));
|
||||
} else {
|
||||
// Error message?
|
||||
ui->lineReference->setText(tr(""));
|
||||
}
|
||||
if (referenceSelectionMode)
|
||||
ui->lineReference->setText(tr("Select a plane"));
|
||||
|
||||
updateUIinProgress = false;
|
||||
blockUpdate = false;
|
||||
}
|
||||
|
||||
void TaskMirroredParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
App::DocumentObject* selectedObject = pcMirrored->getDocument()->getActiveObject();
|
||||
if ((selectedObject == NULL) || !selectedObject->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return;
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
|
||||
if (featureSelectionMode) {
|
||||
if (originalSelected(msg))
|
||||
ui->listFeatures->addItem(QString::fromAscii(selectedObject->getNameInDocument()));
|
||||
} else {
|
||||
if (!msg.pSubName || msg.pSubName[0] == '\0')
|
||||
if (strcmp(msg.pDocName, getObject()->getDocument()->getName()) != 0)
|
||||
return;
|
||||
|
||||
std::string element(msg.pSubName);
|
||||
std::string subName(msg.pSubName);
|
||||
if (originalSelected(msg)) {
|
||||
ui->lineOriginal->setText(QString::fromAscii(msg.pObjectName));
|
||||
} else if (referenceSelectionMode &&
|
||||
(subName.size() > 4 && subName.substr(0,4) == "Face")) {
|
||||
|
||||
if (strcmp(msg.pObjectName, getSupportObject()->getNameInDocument()) != 0)
|
||||
return;
|
||||
|
||||
if (element.substr(0,4) != "Face")
|
||||
return;
|
||||
exitSelectionMode();
|
||||
if (!blockUpdate) {
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
std::vector<std::string> mirrorPlanes(1,subName);
|
||||
pcMirrored->MirrorPlane.setValue(getSupportObject(), mirrorPlanes);
|
||||
pcMirrored->StdMirrorPlane.setValue("");
|
||||
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
std::vector<std::string> mirrorPlanes;
|
||||
mirrorPlanes.push_back(element.c_str());
|
||||
pcMirrored->MirrorPlane.setValue(getOriginalObject(), mirrorPlanes);
|
||||
|
||||
if (insideMultiTransform) {
|
||||
if (parentTask->updateView())
|
||||
recomputeFeature();
|
||||
} else
|
||||
if (ui->checkBoxUpdateView->isChecked())
|
||||
recomputeFeature();
|
||||
|
||||
if (!insideMultiTransform)
|
||||
featureSelectionMode = true; // Jump back to selection of originals
|
||||
|
||||
showObject();
|
||||
hideOriginals();
|
||||
updateUI();
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
else {
|
||||
ui->buttonReference->setChecked(referenceSelectionMode);
|
||||
ui->lineReference->setText(QString::fromAscii(subName.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskMirroredParameters::onOriginalDeleted()
|
||||
{
|
||||
int row = ui->listFeatures->currentIndex().row();
|
||||
TaskTransformedParameters::onOriginalDeleted(row);
|
||||
ui->listFeatures->model()->removeRow(row);
|
||||
}
|
||||
|
||||
void TaskMirroredParameters::onStdMirrorPlane(const std::string &plane) {
|
||||
if (updateUIinProgress) return;
|
||||
if (blockUpdate)
|
||||
return;
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
pcMirrored->StdMirrorPlane.setValue(plane.c_str());
|
||||
pcMirrored->MirrorPlane.setValue(NULL);
|
||||
if (!insideMultiTransform)
|
||||
featureSelectionMode = true;
|
||||
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
|
@ -243,61 +223,61 @@ void TaskMirroredParameters::onButtonYZ() {
|
|||
onStdMirrorPlane("YZ");
|
||||
}
|
||||
|
||||
void TaskMirroredParameters::onButtonReference()
|
||||
void TaskMirroredParameters::onButtonReference(bool checked)
|
||||
{
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
pcMirrored->StdMirrorPlane.setValue("");
|
||||
featureSelectionMode = false;
|
||||
hideObject();
|
||||
showOriginals();
|
||||
if (checked ) {
|
||||
hideObject();
|
||||
showOriginals();
|
||||
referenceSelectionMode = true;
|
||||
Gui::Selection().clearSelection();
|
||||
addReferenceSelectionGate(false, true);
|
||||
} else {
|
||||
exitSelectionMode();
|
||||
}
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskMirroredParameters::onUpdateView(bool on)
|
||||
{
|
||||
ui->buttonXY->blockSignals(!on);
|
||||
ui->buttonYZ->blockSignals(!on);
|
||||
ui->buttonXZ->blockSignals(!on);
|
||||
ui->listFeatures->blockSignals(!on);
|
||||
blockUpdate = !on;
|
||||
if (on) {
|
||||
// Do the same like in TaskDlgMirroredParameters::accept() but without doCommand
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
|
||||
std::string mirrorPlane = getMirrorPlane();
|
||||
if (!mirrorPlane.empty()) {
|
||||
std::vector<std::string> planes(1,mirrorPlane);
|
||||
pcMirrored->MirrorPlane.setValue(getSupportObject(),planes);
|
||||
} else
|
||||
pcMirrored->MirrorPlane.setValue(NULL);
|
||||
|
||||
std::string stdMirrorPlane = getStdMirrorPlane();
|
||||
if (!stdMirrorPlane.empty())
|
||||
pcMirrored->StdMirrorPlane.setValue(stdMirrorPlane.c_str());
|
||||
else
|
||||
pcMirrored->StdMirrorPlane.setValue(NULL);
|
||||
|
||||
recomputeFeature();
|
||||
}
|
||||
}
|
||||
|
||||
const std::string TaskMirroredParameters::getStdMirrorPlane(void) const
|
||||
{
|
||||
std::string stdMirrorPlane;
|
||||
|
||||
if (ui->buttonXY->isChecked())
|
||||
stdMirrorPlane = "XY";
|
||||
return std::string("XY");
|
||||
else if (ui->buttonYZ->isChecked())
|
||||
stdMirrorPlane = "YZ";
|
||||
return std::string("YZ");
|
||||
else if (ui->buttonXZ->isChecked())
|
||||
stdMirrorPlane = "XZ";
|
||||
|
||||
if (!stdMirrorPlane.empty())
|
||||
return std::string("\"") + stdMirrorPlane + "\"";
|
||||
else
|
||||
return std::string("");
|
||||
return std::string("XZ");
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
const QString TaskMirroredParameters::getMirrorPlane(void) const
|
||||
const std::string TaskMirroredParameters::getMirrorPlane(void) const
|
||||
{
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
App::DocumentObject* feature = pcMirrored->MirrorPlane.getValue();
|
||||
if (feature == NULL)
|
||||
return QString::fromUtf8("");
|
||||
std::vector<std::string> mirrorPlanes = pcMirrored->MirrorPlane.getSubValues();
|
||||
QString buf;
|
||||
|
||||
if ((feature != NULL) && !mirrorPlanes.empty()) {
|
||||
buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
||||
buf = buf.arg(QString::fromUtf8(feature->getNameInDocument()));
|
||||
buf = buf.arg(QString::fromUtf8(mirrorPlanes.front().c_str()));
|
||||
}
|
||||
else
|
||||
buf = QString::fromUtf8("");
|
||||
|
||||
return buf;
|
||||
return ui->lineReference->text().toStdString();
|
||||
}
|
||||
|
||||
|
||||
TaskMirroredParameters::~TaskMirroredParameters()
|
||||
{
|
||||
delete ui;
|
||||
|
@ -338,12 +318,16 @@ bool TaskDlgMirroredParameters::accept()
|
|||
return false;
|
||||
|
||||
TaskMirroredParameters* mirrorParameter = static_cast<TaskMirroredParameters*>(parameter);
|
||||
std::string mirrorPlane = mirrorParameter->getMirrorPlane().toStdString();
|
||||
if (!mirrorPlane.empty())
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = %s", name.c_str(), mirrorPlane.c_str());
|
||||
std::string mirrorPlane = mirrorParameter->getMirrorPlane();
|
||||
if (!mirrorPlane.empty()) {
|
||||
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
||||
buf = buf.arg(QString::fromUtf8(mirrorParameter->getSupportObject()->getNameInDocument()));
|
||||
buf = buf.arg(QString::fromUtf8(mirrorPlane.c_str()));
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = %s", name.c_str(), buf.toStdString().c_str());
|
||||
} else
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = None", name.c_str());
|
||||
std::string stdMirrorPlane = mirrorParameter->getStdMirrorPlane();
|
||||
if (!stdMirrorPlane.empty())
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.StdMirrorPlane = %s",name.c_str(),stdMirrorPlane.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.StdMirrorPlane = \"%s\"",name.c_str(),stdMirrorPlane.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
|
||||
if (!TransformedView->getObject()->isValid())
|
||||
throw Base::Exception(TransformedView->getObject()->getStatusString());
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace Gui {
|
|||
class ViewProvider;
|
||||
}
|
||||
|
||||
namespace PartDesignGui {
|
||||
namespace PartDesignGui {
|
||||
|
||||
class TaskMultiTransformParameters;
|
||||
|
||||
|
@ -57,18 +57,17 @@ public:
|
|||
|
||||
virtual ~TaskMirroredParameters();
|
||||
|
||||
const QString getMirrorPlane(void) const;
|
||||
const std::string getStdMirrorPlane(void) const;
|
||||
const std::string getMirrorPlane(void) const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onButtonXY();
|
||||
void onButtonXZ();
|
||||
void onButtonYZ();
|
||||
virtual void onButtonReference();
|
||||
virtual void onOriginalDeleted();
|
||||
void onButtonReference(const bool checked);
|
||||
virtual void onUpdateView(bool);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *e);
|
||||
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
|
||||
|
|
|
@ -15,7 +15,18 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="listFeatures"/>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutOriginal">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelOriginal">
|
||||
<property name="text">
|
||||
<string>Original feature</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineOriginal"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
|
@ -52,6 +63,9 @@
|
|||
<property name="text">
|
||||
<string>Plane</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -80,6 +94,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
@ -68,35 +68,35 @@ TaskMultiTransformParameters::TaskMultiTransformParameters(ViewProviderTransform
|
|||
this->groupLayout()->addWidget(proxy);
|
||||
|
||||
// Create a context menu for the listview of transformation features
|
||||
QAction* action = new QAction(tr("Edit"), ui->listFeatures);
|
||||
QAction* action = new QAction(tr("Edit"), ui->listTransformFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onTransformEdit()));
|
||||
ui->listTransformFeatures->addAction(action);
|
||||
action = new QAction(tr("Delete"), ui->listFeatures);
|
||||
action = new QAction(tr("Delete"), ui->listTransformFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onTransformDelete()));
|
||||
ui->listTransformFeatures->addAction(action);
|
||||
action = new QAction(tr("Add mirrored transformation"), ui->listFeatures);
|
||||
action = new QAction(tr("Add mirrored transformation"), ui->listTransformFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onTransformAddMirrored()));
|
||||
ui->listTransformFeatures->addAction(action);
|
||||
action = new QAction(tr("Add linear pattern"), ui->listFeatures);
|
||||
action = new QAction(tr("Add linear pattern"), ui->listTransformFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onTransformAddLinearPattern()));
|
||||
ui->listTransformFeatures->addAction(action);
|
||||
action = new QAction(tr("Add polar pattern"), ui->listFeatures);
|
||||
action = new QAction(tr("Add polar pattern"), ui->listTransformFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onTransformAddPolarPattern()));
|
||||
ui->listTransformFeatures->addAction(action);
|
||||
action = new QAction(tr("Add scaled transformation"), ui->listFeatures);
|
||||
action = new QAction(tr("Add scaled transformation"), ui->listTransformFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onTransformAddScaled()));
|
||||
ui->listTransformFeatures->addAction(action);
|
||||
action = new QAction(tr("Move up"), ui->listFeatures);
|
||||
action = new QAction(tr("Move up"), ui->listTransformFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onMoveUp()));
|
||||
ui->listTransformFeatures->addAction(action);
|
||||
action = new QAction(tr("Move down"), ui->listFeatures);
|
||||
action = new QAction(tr("Move down"), ui->listTransformFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onMoveDown()));
|
||||
ui->listTransformFeatures->addAction(action);
|
||||
|
@ -127,51 +127,34 @@ TaskMultiTransformParameters::TaskMultiTransformParameters(ViewProviderTransform
|
|||
editHint = true;
|
||||
}
|
||||
|
||||
// TODO: The following code could be generic in TaskTransformedParameters
|
||||
// if it were possible to make ui_TaskMultiTransformParameters a subclass of
|
||||
// ui_TaskTransformedParameters
|
||||
// ---------------------
|
||||
// Add a context menu to the listview of the originals to delete items
|
||||
action = new QAction(tr("Delete"), ui->listFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onOriginalDeleted()));
|
||||
ui->listFeatures->addAction(action);
|
||||
ui->listFeatures->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
// Get the Originals data
|
||||
std::vector<App::DocumentObject*> originals = pcMultiTransform->Originals.getValues();
|
||||
|
||||
// Fill data into dialog elements
|
||||
ui->listFeatures->setEnabled(true);
|
||||
ui->listFeatures->clear();
|
||||
ui->lineOriginal->setEnabled(false); // This is never enabled since it is for optical feed-back only
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); i++)
|
||||
{
|
||||
if ((*i) != NULL)
|
||||
ui->listFeatures->addItem(QString::fromAscii((*i)->getNameInDocument()));
|
||||
if ((*i) != NULL) { // find the first valid original
|
||||
ui->lineOriginal->setText(QString::fromAscii((*i)->getNameInDocument()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
QMetaObject::invokeMethod(ui->listFeatures, "setFocus", Qt::QueuedConnection);
|
||||
// ---------------------
|
||||
}
|
||||
|
||||
void TaskMultiTransformParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(TransformedView->getObject());
|
||||
App::DocumentObject* selectedObject = pcMultiTransform->getDocument()->getActiveObject();
|
||||
if ((selectedObject == NULL) || !selectedObject->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return;
|
||||
|
||||
if (featureSelectionMode) {
|
||||
if (originalSelected(msg))
|
||||
ui->listFeatures->addItem(QString::fromAscii(selectedObject->getNameInDocument()));
|
||||
} else {
|
||||
// There is no reference that could be selected... must be an error to arrive here at all!
|
||||
featureSelectionMode = true;
|
||||
if (originalSelected(msg)) {
|
||||
App::DocumentObject* selectedObject = TransformedView->getObject()->getDocument()->getActiveObject();
|
||||
ui->lineOriginal->setText(QString::fromAscii(selectedObject->getNameInDocument()));
|
||||
}
|
||||
}
|
||||
|
||||
void TaskMultiTransformParameters::closeSubTask()
|
||||
{
|
||||
if (subTask) {
|
||||
exitSelectionMode();
|
||||
disconnect(ui->checkBoxUpdateView, 0, subTask, 0);
|
||||
delete subTask;
|
||||
subTask = NULL;
|
||||
}
|
||||
|
@ -184,14 +167,15 @@ void TaskMultiTransformParameters::onTransformDelete()
|
|||
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(TransformedView->getObject());
|
||||
std::vector<App::DocumentObject*> transformFeatures = pcMultiTransform->Transformations.getValues();
|
||||
|
||||
App::DocumentObject* feature = *(transformFeatures.begin() + row);
|
||||
App::DocumentObject* feature = transformFeatures[row];
|
||||
pcMultiTransform->getDocument()->remObject(feature->getNameInDocument());
|
||||
closeSubTask();
|
||||
|
||||
transformFeatures.erase(transformFeatures.begin() + row);
|
||||
pcMultiTransform->Transformations.setValues(transformFeatures);
|
||||
if (ui->checkBoxUpdateView->isChecked())
|
||||
pcMultiTransform->getDocument()->recomputeFeature(pcMultiTransform);
|
||||
pcMultiTransform->Transformations.setValues(transformFeatures);
|
||||
// Note: When the last transformation is deleted, recomputeFeature does nothing, because Transformed::execute()
|
||||
// says: "No transformations defined, exit silently"
|
||||
recomputeFeature();
|
||||
|
||||
ui->listTransformFeatures->model()->removeRow(row);
|
||||
ui->listTransformFeatures->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
|
||||
|
@ -217,6 +201,9 @@ void TaskMultiTransformParameters::onTransformEdit()
|
|||
subTask = new TaskScaledParameters(this, ui->verticalLayout);
|
||||
else
|
||||
return; // TODO: Show an error?
|
||||
|
||||
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
|
||||
subTask, SLOT(onUpdateView(bool)));
|
||||
}
|
||||
|
||||
void TaskMultiTransformParameters::onTransformActivated(const QModelIndex& index) {
|
||||
|
@ -230,7 +217,7 @@ void TaskMultiTransformParameters::onTransformAddMirrored()
|
|||
|
||||
Gui::Command::openCommand("Mirrored");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\"PartDesign::Mirrored\",\"%s\")",newFeatName.c_str());
|
||||
Gui::Command::updateActive();
|
||||
//Gui::Command::updateActive();
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.StdMirrorPlane = \"XY\"", newFeatName.c_str());
|
||||
|
||||
finishAdd(newFeatName);
|
||||
|
@ -243,7 +230,7 @@ void TaskMultiTransformParameters::onTransformAddLinearPattern()
|
|||
|
||||
Gui::Command::openCommand("LinearPattern");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\"PartDesign::LinearPattern\",\"%s\")",newFeatName.c_str());
|
||||
Gui::Command::updateActive();
|
||||
//Gui::Command::updateActive();
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.StdDirection = \"X\"", newFeatName.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Length = 100", newFeatName.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Occurrences = 2", newFeatName.c_str());
|
||||
|
@ -258,7 +245,7 @@ void TaskMultiTransformParameters::onTransformAddPolarPattern()
|
|||
|
||||
Gui::Command::openCommand("PolarPattern");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\"PartDesign::PolarPattern\",\"%s\")",newFeatName.c_str());
|
||||
Gui::Command::updateActive();
|
||||
//Gui::Command::updateActive();
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.StdAxis = \"X\"", newFeatName.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Angle = 360", newFeatName.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Occurrences = 2", newFeatName.c_str());
|
||||
|
@ -273,7 +260,7 @@ void TaskMultiTransformParameters::onTransformAddScaled()
|
|||
|
||||
Gui::Command::openCommand("Scaled");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\"PartDesign::Scaled\",\"%s\")",newFeatName.c_str());
|
||||
Gui::Command::updateActive();
|
||||
//Gui::Command::updateActive();
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Factor = 2", newFeatName.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Occurrences = 2", newFeatName.c_str());
|
||||
|
||||
|
@ -294,11 +281,12 @@ void TaskMultiTransformParameters::finishAdd(std::string &newFeatName)
|
|||
int row = ui->listTransformFeatures->currentIndex().row();
|
||||
if (row < 0) {
|
||||
// Happens when first row (first transformation) is created
|
||||
row = 0;
|
||||
// Hide all the originals now (hiding them in Command.cpp presents the user with an empty screen!)
|
||||
hideOriginals();
|
||||
}
|
||||
|
||||
// Insert new transformation after the selected row
|
||||
// This means that in order to insert at the beginning, the user has to use "Move Up" in the menu
|
||||
App::DocumentObject* newFeature = pcMultiTransform->getDocument()->getObject(newFeatName.c_str());
|
||||
std::vector<App::DocumentObject*> transformFeatures = pcMultiTransform->Transformations.getValues();
|
||||
if (row == ui->listTransformFeatures->model()->rowCount() - 1) {
|
||||
|
@ -308,14 +296,14 @@ void TaskMultiTransformParameters::finishAdd(std::string &newFeatName)
|
|||
ui->listTransformFeatures->addItem(QString::fromAscii(newFeature->Label.getValue()));
|
||||
ui->listTransformFeatures->setCurrentRow(row+1, QItemSelectionModel::ClearAndSelect);
|
||||
} else {
|
||||
transformFeatures.insert(transformFeatures.begin() + row, newFeature);
|
||||
ui->listTransformFeatures->insertItem(row, QString::fromAscii(newFeature->Label.getValue()));
|
||||
ui->listTransformFeatures->setCurrentRow(row, QItemSelectionModel::ClearAndSelect);
|
||||
// Note: The feature tree always seems to append to the end, no matter what we say here
|
||||
transformFeatures.insert(transformFeatures.begin() + row + 1, newFeature);
|
||||
ui->listTransformFeatures->insertItem(row + 1, QString::fromAscii(newFeature->Label.getValue()));
|
||||
ui->listTransformFeatures->setCurrentRow(row + 1, QItemSelectionModel::ClearAndSelect);
|
||||
}
|
||||
pcMultiTransform->Transformations.setValues(transformFeatures);
|
||||
|
||||
if (ui->checkBoxUpdateView->isChecked())
|
||||
pcMultiTransform->getDocument()->recomputeFeature(pcMultiTransform);
|
||||
recomputeFeature();
|
||||
|
||||
// Set state to hidden - only the MultiTransform should be visible
|
||||
Gui::Command::doCommand(
|
||||
|
@ -331,7 +319,7 @@ void TaskMultiTransformParameters::moveTransformFeature(const int increment)
|
|||
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(TransformedView->getObject());
|
||||
std::vector<App::DocumentObject*> transformFeatures = pcMultiTransform->Transformations.getValues();
|
||||
|
||||
App::DocumentObject* feature = *(transformFeatures.begin() + row);
|
||||
App::DocumentObject* feature = transformFeatures[row];
|
||||
transformFeatures.erase(transformFeatures.begin() + row);
|
||||
QListWidgetItem* item = new QListWidgetItem(*(ui->listTransformFeatures->item(row)));
|
||||
ui->listTransformFeatures->model()->removeRow(row);
|
||||
|
@ -355,8 +343,7 @@ void TaskMultiTransformParameters::moveTransformFeature(const int increment)
|
|||
}
|
||||
|
||||
pcMultiTransform->Transformations.setValues(transformFeatures);
|
||||
if (ui->checkBoxUpdateView->isChecked())
|
||||
pcMultiTransform->getDocument()->recomputeFeature(pcMultiTransform);
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskMultiTransformParameters::onMoveUp()
|
||||
|
@ -373,19 +360,13 @@ void TaskMultiTransformParameters::onSubTaskButtonOK() {
|
|||
closeSubTask();
|
||||
}
|
||||
|
||||
void TaskMultiTransformParameters::onOriginalDeleted()
|
||||
{
|
||||
int row = ui->listFeatures->currentIndex().row();
|
||||
TaskTransformedParameters::onOriginalDeleted(row);
|
||||
ui->listFeatures->model()->removeRow(row);
|
||||
}
|
||||
|
||||
void TaskMultiTransformParameters::onUpdateView(bool on)
|
||||
{
|
||||
ui->listFeatures->blockSignals(!on);
|
||||
blockUpdate = !on;
|
||||
if (on)
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
|
||||
const std::vector<App::DocumentObject*> TaskMultiTransformParameters::getTransformFeatures(void) const
|
||||
{
|
||||
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(TransformedView->getObject());
|
||||
|
@ -408,16 +389,6 @@ void TaskMultiTransformParameters::changeEvent(QEvent *e)
|
|||
}
|
||||
}
|
||||
|
||||
void TaskMultiTransformParameters::recomputeFeature() {
|
||||
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(TransformedView->getObject());
|
||||
pcMultiTransform->getDocument()->recomputeFeature(pcMultiTransform);
|
||||
}
|
||||
|
||||
const bool TaskMultiTransformParameters::updateView() const
|
||||
{
|
||||
return ui->checkBoxUpdateView->isChecked();
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
//**************************************************************************
|
||||
// TaskDialog
|
||||
|
|
|
@ -62,11 +62,6 @@ public:
|
|||
/// Return the currently active subFeature
|
||||
PartDesign::Transformed* getSubFeature(void) { return subFeature; }
|
||||
|
||||
/// Recompute the feature associated with this task
|
||||
void recomputeFeature();
|
||||
/// Tell the subtask whether the view should be updated
|
||||
const bool updateView() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onTransformDelete();
|
||||
void onTransformEdit();
|
||||
|
@ -77,13 +72,11 @@ private Q_SLOTS:
|
|||
void onTransformAddScaled();
|
||||
void onMoveUp();
|
||||
void onMoveDown();
|
||||
virtual void onButtonReference() {}
|
||||
virtual void onOriginalDeleted();
|
||||
virtual void onUpdateView(bool);
|
||||
/// User finished editing a subFeature
|
||||
virtual void onSubTaskButtonOK();
|
||||
// Note: There is no Cancel button because I couldn't work out how to save the state of
|
||||
// a subFeature so as to revert the changes of an edit operation
|
||||
virtual void onUpdateView(bool);
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *e);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>225</width>
|
||||
<height>559</height>
|
||||
<height>182</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -15,14 +15,18 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Originals</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listFeatures"/>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutOriginal">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelOriginal">
|
||||
<property name="text">
|
||||
<string>Original feature</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineOriginal"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
|
@ -32,7 +36,14 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listTransformFeatures"/>
|
||||
<widget class="QListWidget" name="listTransformFeatures">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxUpdateView">
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "ui_TaskPolarPatternParameters.h"
|
||||
#include "TaskPolarPatternParameters.h"
|
||||
#include "TaskMultiTransformParameters.h"
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <Gui/Application.h>
|
||||
|
@ -41,7 +42,6 @@
|
|||
#include <Gui/Command.h>
|
||||
#include <Mod/PartDesign/App/FeaturePolarPattern.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
#include "TaskMultiTransformParameters.h"
|
||||
|
||||
using namespace PartDesignGui;
|
||||
using namespace Gui;
|
||||
|
@ -62,7 +62,9 @@ TaskPolarPatternParameters::TaskPolarPatternParameters(ViewProviderTransformed *
|
|||
ui->buttonOK->hide();
|
||||
ui->checkBoxUpdateView->setEnabled(true);
|
||||
|
||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
referenceSelectionMode = false;
|
||||
|
||||
blockUpdate = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
setupUI();
|
||||
}
|
||||
|
||||
|
@ -79,10 +81,13 @@ TaskPolarPatternParameters::TaskPolarPatternParameters(TaskMultiTransformParamet
|
|||
layout->addWidget(proxy);
|
||||
|
||||
ui->buttonOK->setEnabled(true);
|
||||
ui->listFeatures->hide();
|
||||
ui->labelOriginal->hide();
|
||||
ui->lineOriginal->hide();
|
||||
ui->checkBoxUpdateView->hide();
|
||||
|
||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
referenceSelectionMode = false;
|
||||
|
||||
blockUpdate = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
setupUI();
|
||||
}
|
||||
|
||||
|
@ -100,35 +105,24 @@ void TaskPolarPatternParameters::setupUI()
|
|||
this, SLOT(onAngle(double)));
|
||||
connect(ui->spinOccurrences, SIGNAL(valueChanged(int)),
|
||||
this, SLOT(onOccurrences(int)));
|
||||
connect(ui->buttonReference, SIGNAL(pressed()),
|
||||
this, SLOT(onButtonReference()));
|
||||
connect(ui->buttonReference, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onButtonReference(bool)));
|
||||
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onUpdateView(bool)));
|
||||
|
||||
// TODO: The following code could be generic in TaskTransformedParameters
|
||||
// if it were possible to make ui_TaskPolarPatternParameters a subclass of
|
||||
// ui_TaskTransformedParameters
|
||||
// ---------------------
|
||||
// Add a context menu to the listview of the originals to delete items
|
||||
QAction* action = new QAction(tr("Delete"), ui->listFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onOriginalDeleted()));
|
||||
ui->listFeatures->addAction(action);
|
||||
ui->listFeatures->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
// Get the feature data
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
std::vector<App::DocumentObject*> originals = pcPolarPattern->Originals.getValues();
|
||||
|
||||
// Fill data into dialog elements
|
||||
ui->listFeatures->setEnabled(true);
|
||||
ui->listFeatures->clear();
|
||||
ui->lineOriginal->setEnabled(false);
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); i++)
|
||||
{
|
||||
if ((*i) != NULL)
|
||||
ui->listFeatures->addItem(QString::fromAscii((*i)->getNameInDocument()));
|
||||
if ((*i) != NULL) { // find the first valid original
|
||||
ui->lineOriginal->setText(QString::fromAscii((*i)->getNameInDocument()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
QMetaObject::invokeMethod(ui->listFeatures, "setFocus", Qt::QueuedConnection);
|
||||
// ---------------------
|
||||
|
||||
ui->buttonX->setEnabled(true);
|
||||
|
@ -144,8 +138,9 @@ void TaskPolarPatternParameters::setupUI()
|
|||
|
||||
void TaskPolarPatternParameters::updateUI()
|
||||
{
|
||||
if (updateUIinProgress) return;
|
||||
updateUIinProgress = true;
|
||||
if (blockUpdate)
|
||||
return;
|
||||
blockUpdate = true;
|
||||
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
|
||||
|
@ -156,9 +151,9 @@ void TaskPolarPatternParameters::updateUI()
|
|||
double angle = pcPolarPattern->Angle.getValue();
|
||||
unsigned occurrences = pcPolarPattern->Occurrences.getValue();
|
||||
|
||||
if ((featureSelectionMode || insideMultiTransform) && !stdAxis.empty())
|
||||
ui->buttonReference->setChecked(referenceSelectionMode);
|
||||
if (!stdAxis.empty())
|
||||
{
|
||||
ui->buttonReference->setDown(false);
|
||||
ui->buttonX->setAutoExclusive(true);
|
||||
ui->buttonY->setAutoExclusive(true);
|
||||
ui->buttonZ->setAutoExclusive(true);
|
||||
|
@ -166,82 +161,62 @@ void TaskPolarPatternParameters::updateUI()
|
|||
ui->buttonY->setChecked(stdAxis == "Y");
|
||||
ui->buttonZ->setChecked(stdAxis == "Z");
|
||||
ui->lineReference->setText(tr(""));
|
||||
} else if ((axisFeature != NULL) && !axes.empty()) {
|
||||
} else if (axisFeature != NULL && !axes.empty()) {
|
||||
ui->buttonX->setAutoExclusive(false);
|
||||
ui->buttonY->setAutoExclusive(false);
|
||||
ui->buttonZ->setAutoExclusive(false);
|
||||
ui->buttonX->setChecked(false);
|
||||
ui->buttonY->setChecked(false);
|
||||
ui->buttonZ->setChecked(false);
|
||||
ui->buttonReference->setDown(!featureSelectionMode);
|
||||
ui->lineReference->setText(QString::fromAscii(axes.front().c_str()));
|
||||
} else {
|
||||
// Error message?
|
||||
ui->lineReference->setText(tr(""));
|
||||
}
|
||||
if (referenceSelectionMode)
|
||||
ui->lineReference->setText(tr("Select an edge"));
|
||||
|
||||
ui->checkReverse->setChecked(reverse);
|
||||
ui->spinAngle->setValue(angle);
|
||||
ui->spinOccurrences->setValue(occurrences);
|
||||
|
||||
updateUIinProgress = false;
|
||||
blockUpdate = false;
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
App::DocumentObject* selectedObject = pcPolarPattern->getDocument()->getActiveObject();
|
||||
if ((selectedObject == NULL) || !selectedObject->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return;
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
|
||||
if (featureSelectionMode) {
|
||||
if (originalSelected(msg))
|
||||
ui->listFeatures->addItem(QString::fromAscii(selectedObject->getNameInDocument()));
|
||||
} else {
|
||||
if (!msg.pSubName || msg.pSubName[0] == '\0')
|
||||
if (strcmp(msg.pDocName, getObject()->getDocument()->getName()) != 0)
|
||||
return;
|
||||
|
||||
std::string element(msg.pSubName);
|
||||
std::string subName(msg.pSubName);
|
||||
if (originalSelected(msg)) {
|
||||
ui->lineOriginal->setText(QString::fromAscii(msg.pObjectName));
|
||||
} else if (referenceSelectionMode &&
|
||||
(subName.size() > 4 && subName.substr(0,4) == "Edge")) {
|
||||
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
|
||||
if (element.substr(0,4) != "Edge")
|
||||
if (strcmp(msg.pObjectName, getSupportObject()->getNameInDocument()) != 0)
|
||||
return;
|
||||
|
||||
// TODO
|
||||
// if (originalElementName == "") {
|
||||
// Base::Console().Error("Element created by this pattern cannot be used for axis\n");
|
||||
// return;
|
||||
// }
|
||||
exitSelectionMode();
|
||||
if (!blockUpdate) {
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
std::vector<std::string> axes(1,subName);
|
||||
pcPolarPattern->Axis.setValue(getSupportObject(), axes);
|
||||
pcPolarPattern->StdAxis.setValue("");
|
||||
|
||||
std::vector<std::string> axes;
|
||||
axes.push_back(element.c_str());
|
||||
pcPolarPattern->Axis.setValue(getOriginalObject(), axes);
|
||||
|
||||
if (insideMultiTransform) {
|
||||
if (parentTask->updateView())
|
||||
recomputeFeature();
|
||||
} else
|
||||
if (ui->checkBoxUpdateView->isChecked())
|
||||
recomputeFeature();
|
||||
|
||||
if (!insideMultiTransform)
|
||||
featureSelectionMode = true; // Jump back to selection of originals
|
||||
|
||||
showObject();
|
||||
hideOriginals();
|
||||
updateUI();
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
else {
|
||||
ui->buttonReference->setChecked(referenceSelectionMode);
|
||||
ui->lineReference->setText(QString::fromAscii(subName.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::onOriginalDeleted()
|
||||
{
|
||||
int row = ui->listFeatures->currentIndex().row();
|
||||
TaskTransformedParameters::onOriginalDeleted(row);
|
||||
ui->listFeatures->model()->removeRow(row);
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::onButtonX() {
|
||||
onStdAxis("X");
|
||||
}
|
||||
|
@ -255,106 +230,108 @@ void TaskPolarPatternParameters::onButtonZ() {
|
|||
}
|
||||
|
||||
void TaskPolarPatternParameters::onCheckReverse(const bool on) {
|
||||
if (updateUIinProgress) return;
|
||||
if (blockUpdate)
|
||||
return;
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
pcPolarPattern->Reversed.setValue(on);
|
||||
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::onAngle(const double a) {
|
||||
if (updateUIinProgress) return;
|
||||
if (blockUpdate)
|
||||
return;
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
pcPolarPattern->Angle.setValue(a);
|
||||
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::onOccurrences(const int n) {
|
||||
if (updateUIinProgress) return;
|
||||
if (blockUpdate)
|
||||
return;
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
pcPolarPattern->Occurrences.setValue(n);
|
||||
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::onStdAxis(const std::string& axis) {
|
||||
if (updateUIinProgress) return;
|
||||
if (blockUpdate)
|
||||
return;
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
pcPolarPattern->StdAxis.setValue(axis.c_str());
|
||||
pcPolarPattern->Axis.setValue(NULL);
|
||||
if (!insideMultiTransform)
|
||||
featureSelectionMode = true;
|
||||
|
||||
exitSelectionMode();
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::onButtonReference()
|
||||
void TaskPolarPatternParameters::onButtonReference(bool checked)
|
||||
{
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
pcPolarPattern->StdAxis.setValue("");
|
||||
featureSelectionMode = false;
|
||||
hideObject();
|
||||
showOriginals();
|
||||
if (checked ) {
|
||||
hideObject();
|
||||
showOriginals();
|
||||
referenceSelectionMode = true;
|
||||
Gui::Selection().clearSelection();
|
||||
addReferenceSelectionGate(true, false);
|
||||
} else {
|
||||
exitSelectionMode();
|
||||
}
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::onUpdateView(bool on)
|
||||
{
|
||||
ui->buttonX->blockSignals(!on);
|
||||
ui->buttonY->blockSignals(!on);
|
||||
ui->buttonZ->blockSignals(!on);
|
||||
ui->listFeatures->blockSignals(!on);
|
||||
ui->checkReverse->blockSignals(!on);
|
||||
ui->spinAngle->blockSignals(!on);
|
||||
ui->spinOccurrences->blockSignals(!on);
|
||||
blockUpdate = !on;
|
||||
if (on) {
|
||||
// Do the same like in TaskDlgPolarPatternParameters::accept() but without doCommand
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
|
||||
std::string axis = getAxis();
|
||||
if (!axis.empty()) {
|
||||
std::vector<std::string> axes(1,axis);
|
||||
pcPolarPattern->Axis.setValue(getSupportObject(),axes);
|
||||
} else
|
||||
pcPolarPattern->Axis.setValue(NULL);
|
||||
|
||||
std::string stdAxis = getStdAxis();
|
||||
if (!stdAxis.empty())
|
||||
pcPolarPattern->StdAxis.setValue(stdAxis.c_str());
|
||||
else
|
||||
pcPolarPattern->StdAxis.setValue(NULL);
|
||||
|
||||
pcPolarPattern->Reversed.setValue(getReverse());
|
||||
pcPolarPattern->Angle.setValue(getAngle());
|
||||
pcPolarPattern->Occurrences.setValue(getOccurrences());
|
||||
|
||||
recomputeFeature();
|
||||
}
|
||||
}
|
||||
|
||||
const std::string TaskPolarPatternParameters::getStdAxis(void) const
|
||||
{
|
||||
std::string stdAxis;
|
||||
|
||||
if (ui->buttonX->isChecked())
|
||||
stdAxis = "X";
|
||||
return std::string("X");
|
||||
else if (ui->buttonY->isChecked())
|
||||
stdAxis = "Y";
|
||||
return std::string("Y");
|
||||
else if (ui->buttonZ->isChecked())
|
||||
stdAxis = "Z";
|
||||
|
||||
if (!stdAxis.empty())
|
||||
return std::string("\"") + stdAxis + "\"";
|
||||
else
|
||||
return std::string("");
|
||||
return std::string("Z");
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
const QString TaskPolarPatternParameters::getAxis(void) const
|
||||
const std::string TaskPolarPatternParameters::getAxis(void) const
|
||||
{
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
App::DocumentObject* feature = pcPolarPattern->Axis.getValue();
|
||||
if (feature == NULL)
|
||||
return QString::fromUtf8("");
|
||||
std::vector<std::string> axes = pcPolarPattern->Axis.getSubValues();
|
||||
QString buf;
|
||||
|
||||
if ((feature != NULL) && !axes.empty()) {
|
||||
buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
||||
buf = buf.arg(QString::fromUtf8(feature->getNameInDocument()));
|
||||
buf = buf.arg(QString::fromUtf8(axes.front().c_str()));
|
||||
}
|
||||
else
|
||||
buf = QString::fromUtf8("");
|
||||
|
||||
return buf;
|
||||
return ui->lineReference->text().toStdString();
|
||||
}
|
||||
|
||||
|
||||
const bool TaskPolarPatternParameters::getReverse(void) const
|
||||
{
|
||||
return ui->checkReverse->isChecked();
|
||||
|
@ -370,6 +347,7 @@ const unsigned TaskPolarPatternParameters::getOccurrences(void) const
|
|||
return ui->spinOccurrences->value();
|
||||
}
|
||||
|
||||
|
||||
TaskPolarPatternParameters::~TaskPolarPatternParameters()
|
||||
{
|
||||
delete ui;
|
||||
|
@ -410,12 +388,16 @@ bool TaskDlgPolarPatternParameters::accept()
|
|||
return false;
|
||||
|
||||
TaskPolarPatternParameters* polarpatternParameter = static_cast<TaskPolarPatternParameters*>(parameter);
|
||||
std::string axis = polarpatternParameter->getAxis().toStdString();
|
||||
if (!axis.empty())
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Axis = %s", name.c_str(), axis.c_str());
|
||||
std::string axis = polarpatternParameter->getAxis();
|
||||
if (!axis.empty()) {
|
||||
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
||||
buf = buf.arg(QString::fromUtf8(polarpatternParameter->getSupportObject()->getNameInDocument()));
|
||||
buf = buf.arg(QString::fromUtf8(axis.c_str()));
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Axis = %s", name.c_str(), buf.toStdString().c_str());
|
||||
} else
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Axis = None", name.c_str());
|
||||
std::string stdAxis = polarpatternParameter->getStdAxis();
|
||||
if (!stdAxis.empty())
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.StdAxis = %s",name.c_str(),stdAxis.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.StdAxis = \"%s\"",name.c_str(),stdAxis.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),polarpatternParameter->getReverse());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Angle = %f",name.c_str(),polarpatternParameter->getAngle());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Occurrences = %u",name.c_str(),polarpatternParameter->getOccurrences());
|
||||
|
|
|
@ -56,8 +56,8 @@ public:
|
|||
TaskPolarPatternParameters(TaskMultiTransformParameters *parentTask, QLayout *layout);
|
||||
virtual ~TaskPolarPatternParameters();
|
||||
|
||||
const QString getAxis(void) const;
|
||||
const std::string getStdAxis(void) const;
|
||||
const std::string getAxis(void) const;
|
||||
const bool getReverse(void) const;
|
||||
const double getAngle(void) const;
|
||||
const unsigned getOccurrences(void) const;
|
||||
|
@ -70,8 +70,7 @@ private Q_SLOTS:
|
|||
void onCheckReverse(const bool on);
|
||||
void onAngle(const double a);
|
||||
void onOccurrences(const int n);
|
||||
virtual void onButtonReference();
|
||||
virtual void onOriginalDeleted();
|
||||
void onButtonReference(const bool checked);
|
||||
virtual void onUpdateView(bool);
|
||||
|
||||
protected:
|
||||
|
@ -79,8 +78,8 @@ protected:
|
|||
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
|
||||
private:
|
||||
void updateUI();
|
||||
void setupUI();
|
||||
void updateUI();
|
||||
|
||||
private:
|
||||
Ui_TaskPolarPatternParameters* ui;
|
||||
|
|
|
@ -15,7 +15,18 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="listFeatures"/>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutOriginal">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelOriginal">
|
||||
<property name="text">
|
||||
<string>Original feature</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineOriginal"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
|
@ -52,6 +63,9 @@
|
|||
<property name="text">
|
||||
<string>Direction</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -132,6 +146,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "ui_TaskScaledParameters.h"
|
||||
#include "TaskScaledParameters.h"
|
||||
#include "TaskMultiTransformParameters.h"
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <Gui/Application.h>
|
||||
|
@ -41,7 +42,6 @@
|
|||
#include <Gui/Command.h>
|
||||
#include <Mod/PartDesign/App/FeatureScaled.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
#include "TaskMultiTransformParameters.h"
|
||||
|
||||
using namespace PartDesignGui;
|
||||
using namespace Gui;
|
||||
|
@ -62,7 +62,7 @@ TaskScaledParameters::TaskScaledParameters(ViewProviderTransformed *TransformedV
|
|||
ui->buttonOK->hide();
|
||||
ui->checkBoxUpdateView->setEnabled(true);
|
||||
|
||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
blockUpdate = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
setupUI();
|
||||
}
|
||||
|
||||
|
@ -79,10 +79,11 @@ TaskScaledParameters::TaskScaledParameters(TaskMultiTransformParameters *parentT
|
|||
layout->addWidget(proxy);
|
||||
|
||||
ui->buttonOK->setEnabled(true);
|
||||
ui->listFeatures->hide();
|
||||
ui->labelOriginal->hide();
|
||||
ui->lineOriginal->hide();
|
||||
ui->checkBoxUpdateView->hide();
|
||||
|
||||
updateUIinProgress = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
blockUpdate = false; // Hack, sometimes it is NOT false although set to false in Transformed::Transformed()!!
|
||||
setupUI();
|
||||
}
|
||||
|
||||
|
@ -95,30 +96,19 @@ void TaskScaledParameters::setupUI()
|
|||
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onUpdateView(bool)));
|
||||
|
||||
// TODO: The following code could be generic in TaskTransformedParameters
|
||||
// if it were possible to make ui_TaskScaledParameters a subclass of
|
||||
// ui_TaskTransformedParameters
|
||||
// ---------------------
|
||||
// Add a context menu to the listview of the originals to delete items
|
||||
QAction* action = new QAction(tr("Delete"), ui->listFeatures);
|
||||
action->connect(action, SIGNAL(triggered()),
|
||||
this, SLOT(onOriginalDeleted()));
|
||||
ui->listFeatures->addAction(action);
|
||||
ui->listFeatures->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
// Get the feature data
|
||||
PartDesign::Scaled* pcScaled = static_cast<PartDesign::Scaled*>(getObject());
|
||||
std::vector<App::DocumentObject*> originals = pcScaled->Originals.getValues();
|
||||
|
||||
// Fill data into dialog elements
|
||||
ui->listFeatures->setEnabled(true);
|
||||
ui->listFeatures->clear();
|
||||
ui->lineOriginal->setEnabled(false);
|
||||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); i++)
|
||||
{
|
||||
if ((*i) != NULL)
|
||||
ui->listFeatures->addItem(QString::fromAscii((*i)->getNameInDocument()));
|
||||
if ((*i) != NULL) { // find the first valid original
|
||||
ui->lineOriginal->setText(QString::fromAscii((*i)->getNameInDocument()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
QMetaObject::invokeMethod(ui->listFeatures, "setFocus", Qt::QueuedConnection);
|
||||
// ---------------------
|
||||
|
||||
ui->spinFactor->setEnabled(true);
|
||||
|
@ -129,8 +119,9 @@ void TaskScaledParameters::setupUI()
|
|||
|
||||
void TaskScaledParameters::updateUI()
|
||||
{
|
||||
if (updateUIinProgress) return;
|
||||
updateUIinProgress = true;
|
||||
if (blockUpdate)
|
||||
return;
|
||||
blockUpdate = true;
|
||||
|
||||
PartDesign::Scaled* pcScaled = static_cast<PartDesign::Scaled*>(getObject());
|
||||
|
||||
|
@ -140,56 +131,45 @@ void TaskScaledParameters::updateUI()
|
|||
ui->spinFactor->setValue(factor);
|
||||
ui->spinOccurrences->setValue(occurrences);
|
||||
|
||||
updateUIinProgress = false;
|
||||
blockUpdate = false;
|
||||
}
|
||||
|
||||
void TaskScaledParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
PartDesign::Scaled* pcScaled = static_cast<PartDesign::Scaled*>(getObject());
|
||||
App::DocumentObject* selectedObject = pcScaled->getDocument()->getActiveObject();
|
||||
if ((selectedObject == NULL) || !selectedObject->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return;
|
||||
|
||||
if (featureSelectionMode) {
|
||||
if (originalSelected(msg))
|
||||
ui->listFeatures->addItem(QString::fromAscii(selectedObject->getNameInDocument()));
|
||||
} else {
|
||||
return;
|
||||
if (originalSelected(msg)) {
|
||||
App::DocumentObject* selectedObject = TransformedView->getObject()->getDocument()->getActiveObject();
|
||||
ui->lineOriginal->setText(QString::fromAscii(selectedObject->getNameInDocument()));
|
||||
}
|
||||
}
|
||||
|
||||
void TaskScaledParameters::onOriginalDeleted()
|
||||
{
|
||||
int row = ui->listFeatures->currentIndex().row();
|
||||
TaskTransformedParameters::onOriginalDeleted(row);
|
||||
ui->listFeatures->model()->removeRow(row);
|
||||
}
|
||||
|
||||
void TaskScaledParameters::onFactor(const double f) {
|
||||
if (updateUIinProgress) return;
|
||||
if (blockUpdate)
|
||||
return;
|
||||
PartDesign::Scaled* pcScaled = static_cast<PartDesign::Scaled*>(getObject());
|
||||
pcScaled->Factor.setValue(f);
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskScaledParameters::onOccurrences(const int n) {
|
||||
if (updateUIinProgress) return;
|
||||
if (blockUpdate)
|
||||
return;
|
||||
PartDesign::Scaled* pcScaled = static_cast<PartDesign::Scaled*>(getObject());
|
||||
pcScaled->Occurrences.setValue(n);
|
||||
updateUI();
|
||||
if (insideMultiTransform && !parentTask->updateView())
|
||||
return;
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
void TaskScaledParameters::onUpdateView(bool on)
|
||||
{
|
||||
ui->listFeatures->blockSignals(!on);
|
||||
ui->spinFactor->blockSignals(!on);
|
||||
ui->spinOccurrences->blockSignals(!on);
|
||||
blockUpdate = !on;
|
||||
if (on) {
|
||||
// Do the same like in TaskDlgScaledParameters::accept() but without doCommand
|
||||
PartDesign::Scaled* pcScaled = static_cast<PartDesign::Scaled*>(getObject());
|
||||
pcScaled->Factor.setValue(getFactor());
|
||||
pcScaled->Occurrences.setValue(getOccurrences());
|
||||
recomputeFeature();
|
||||
}
|
||||
}
|
||||
|
||||
const double TaskScaledParameters::getFactor(void) const
|
||||
|
@ -202,6 +182,7 @@ const unsigned TaskScaledParameters::getOccurrences(void) const
|
|||
return ui->spinOccurrences->value();
|
||||
}
|
||||
|
||||
|
||||
TaskScaledParameters::~TaskScaledParameters()
|
||||
{
|
||||
delete ui;
|
||||
|
|
|
@ -62,8 +62,6 @@ public:
|
|||
private Q_SLOTS:
|
||||
void onFactor(const double f);
|
||||
void onOccurrences(const int n);
|
||||
virtual void onButtonReference() {}
|
||||
virtual void onOriginalDeleted();
|
||||
virtual void onUpdateView(bool);
|
||||
|
||||
protected:
|
||||
|
@ -71,8 +69,8 @@ protected:
|
|||
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
|
||||
private:
|
||||
void updateUI();
|
||||
void setupUI();
|
||||
void updateUI();
|
||||
|
||||
private:
|
||||
Ui_TaskScaledParameters* ui;
|
||||
|
|
|
@ -15,7 +15,18 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="listFeatures"/>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutOriginal">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelOriginal">
|
||||
<property name="text">
|
||||
<string>Original feature</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineOriginal"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
|
@ -86,6 +97,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
68
src/Mod/PartDesign/Gui/TaskTransformedMessages.cpp
Normal file
68
src/Mod/PartDesign/Gui/TaskTransformedMessages.cpp
Normal file
|
@ -0,0 +1,68 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2012 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* *
|
||||
* 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 "ui_TaskTransformedMessages.h"
|
||||
#include "TaskTransformedMessages.h"
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include "ViewProviderTransformed.h"
|
||||
|
||||
using namespace PartDesignGui;
|
||||
using namespace Gui::TaskView;
|
||||
|
||||
TaskTransformedMessages::TaskTransformedMessages(ViewProviderTransformed *transformedView_)
|
||||
: TaskBox(Gui::BitmapFactory().pixmap("document-new"),tr("Transformed feature messages"),true, 0),
|
||||
transformedView(transformedView_)
|
||||
{
|
||||
// we need a separate container widget to add all controls to
|
||||
proxy = new QWidget(this);
|
||||
ui = new Ui_TaskTransformedMessages();
|
||||
ui->setupUi(proxy);
|
||||
QMetaObject::connectSlotsByName(this);
|
||||
|
||||
this->groupLayout()->addWidget(proxy);
|
||||
|
||||
connectionDiagnosis = transformedView->signalDiagnosis.connect(boost::bind(&PartDesignGui::TaskTransformedMessages::slotDiagnosis, this,_1));
|
||||
}
|
||||
|
||||
TaskTransformedMessages::~TaskTransformedMessages()
|
||||
{
|
||||
connectionDiagnosis.disconnect();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TaskTransformedMessages::slotDiagnosis(QString msg)
|
||||
{
|
||||
ui->labelTransformationStatus->setText(msg);
|
||||
}
|
||||
|
||||
#include "moc_TaskTransformedMessages.cpp"
|
64
src/Mod/PartDesign/Gui/TaskTransformedMessages.h
Normal file
64
src/Mod/PartDesign/Gui/TaskTransformedMessages.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2012 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* *
|
||||
* 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_TaskTransformedMessages_H
|
||||
#define GUI_TASKVIEW_TaskTransformedMessages_H
|
||||
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <boost/signals.hpp>
|
||||
|
||||
class Ui_TaskTransformedMessages;
|
||||
typedef boost::signals::connection Connection;
|
||||
|
||||
namespace App {
|
||||
class Property;
|
||||
}
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
class ViewProviderTransformed;
|
||||
|
||||
class TaskTransformedMessages : public Gui::TaskView::TaskBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskTransformedMessages(ViewProviderTransformed *transformedView);
|
||||
~TaskTransformedMessages();
|
||||
|
||||
void slotDiagnosis(QString msg);
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
protected:
|
||||
ViewProviderTransformed *transformedView;
|
||||
Connection connectionDiagnosis;
|
||||
|
||||
private:
|
||||
QWidget* proxy;
|
||||
Ui_TaskTransformedMessages* ui;
|
||||
};
|
||||
|
||||
} //namespace PartDesignGui
|
||||
|
||||
#endif // GUI_TASKVIEW_TaskTransformedMessages_H
|
37
src/Mod/PartDesign/Gui/TaskTransformedMessages.ui
Normal file
37
src/Mod/PartDesign/Gui/TaskTransformedMessages.ui
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TaskTransformedMessages</class>
|
||||
<widget class="QWidget" name="TaskTransformedMessages">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>228</width>
|
||||
<height>89</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelTransformationStatus">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Bitstream Charter</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>No message</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -24,6 +24,10 @@
|
|||
|
||||
#ifndef _PreComp_
|
||||
# include <QMessageBox>
|
||||
# include <TopoDS_Shape.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <BRepAdaptor_Surface.hxx>
|
||||
#endif
|
||||
|
||||
#include "TaskTransformedParameters.h"
|
||||
|
@ -55,10 +59,9 @@ TaskTransformedParameters::TaskTransformedParameters(ViewProviderTransformed *Tr
|
|||
TransformedView(TransformedView),
|
||||
parentTask(NULL),
|
||||
insideMultiTransform(false),
|
||||
updateUIinProgress(false)
|
||||
blockUpdate(false)
|
||||
{
|
||||
// Start in feature selection mode
|
||||
featureSelectionMode = true;
|
||||
originalSelectionMode = false;
|
||||
}
|
||||
|
||||
TaskTransformedParameters::TaskTransformedParameters(TaskMultiTransformParameters *parentTask)
|
||||
|
@ -66,30 +69,30 @@ TaskTransformedParameters::TaskTransformedParameters(TaskMultiTransformParameter
|
|||
TransformedView(NULL),
|
||||
parentTask(parentTask),
|
||||
insideMultiTransform(true),
|
||||
updateUIinProgress(false)
|
||||
blockUpdate(false)
|
||||
{
|
||||
// Start in reference selection mode and stay there! Feature selection makes
|
||||
// no sense inside a MultiTransform
|
||||
featureSelectionMode = false;
|
||||
// Original feature selection makes no sense inside a MultiTransform
|
||||
originalSelectionMode = false;
|
||||
}
|
||||
|
||||
const bool TaskTransformedParameters::originalSelected(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
if (featureSelectionMode && (msg.Type == Gui::SelectionChanges::AddSelection)) {
|
||||
PartDesign::Transformed* pcTransformed = static_cast<PartDesign::Transformed*>(TransformedView->getObject());
|
||||
App::DocumentObject* selectedObject = pcTransformed->getDocument()->getActiveObject();
|
||||
if (!selectedObject->isDerivedFrom(PartDesign::Additive::getClassTypeId()) &&
|
||||
!selectedObject->isDerivedFrom(PartDesign::Subtractive::getClassTypeId()))
|
||||
return false;
|
||||
if (TransformedView->getObject() == pcTransformed)
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection && originalSelectionMode) {
|
||||
|
||||
if (strcmp(msg.pDocName, getObject()->getDocument()->getName()) != 0)
|
||||
return false;
|
||||
|
||||
std::vector<App::DocumentObject*> originals = pcTransformed->Originals.getValues();
|
||||
PartDesign::Transformed* pcTransformed = getObject();
|
||||
App::DocumentObject* selectedObject = pcTransformed->getDocument()->getObject(msg.pObjectName);
|
||||
if (selectedObject->isDerivedFrom(PartDesign::Additive::getClassTypeId()) ||
|
||||
selectedObject->isDerivedFrom(PartDesign::Subtractive::getClassTypeId())) {
|
||||
|
||||
if (std::find(originals.begin(), originals.end(), selectedObject) == originals.end()) {
|
||||
originals.push_back(selectedObject);
|
||||
// Do the same like in TaskDlgTransformedParameters::accept() but without doCommand
|
||||
std::vector<App::DocumentObject*> originals(1,selectedObject);
|
||||
pcTransformed->Originals.setValues(originals);
|
||||
pcTransformed->getDocument()->recomputeFeature(pcTransformed);
|
||||
recomputeFeature();
|
||||
|
||||
originalSelectionMode = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -97,15 +100,6 @@ const bool TaskTransformedParameters::originalSelected(const Gui::SelectionChang
|
|||
return false;
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::onOriginalDeleted(const int row)
|
||||
{
|
||||
PartDesign::Transformed* pcTransformed = static_cast<PartDesign::Transformed*>(TransformedView->getObject());
|
||||
std::vector<App::DocumentObject*> originals = pcTransformed->Originals.getValues();
|
||||
originals.erase(originals.begin() + row);
|
||||
pcTransformed->Originals.setValues(originals);
|
||||
pcTransformed->getDocument()->recomputeFeature(pcTransformed);
|
||||
}
|
||||
|
||||
PartDesign::Transformed *TaskTransformedParameters::getObject() const
|
||||
{
|
||||
|
||||
|
@ -118,10 +112,10 @@ PartDesign::Transformed *TaskTransformedParameters::getObject() const
|
|||
void TaskTransformedParameters::recomputeFeature()
|
||||
{
|
||||
if (insideMultiTransform) {
|
||||
// redirect recompute and let the parent decide if recompute has to be blocked
|
||||
parentTask->recomputeFeature();
|
||||
} else {
|
||||
PartDesign::Transformed* pcTransformed = static_cast<PartDesign::Transformed*>(TransformedView->getObject());
|
||||
pcTransformed->getDocument()->recomputeFeature(pcTransformed);
|
||||
} else if (!blockUpdate) {
|
||||
TransformedView->recomputeFeature();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,13 +131,13 @@ const std::vector<App::DocumentObject*> TaskTransformedParameters::getOriginals(
|
|||
}
|
||||
}
|
||||
|
||||
App::DocumentObject* TaskTransformedParameters::getOriginalObject() const
|
||||
App::DocumentObject* TaskTransformedParameters::getSupportObject() const
|
||||
{
|
||||
if (insideMultiTransform) {
|
||||
return parentTask->getOriginalObject();
|
||||
return parentTask->getSupportObject();
|
||||
} else {
|
||||
PartDesign::Transformed* pcTransformed = static_cast<PartDesign::Transformed*>(TransformedView->getObject());
|
||||
return pcTransformed->getOriginalObject();
|
||||
return pcTransformed->getSupportObject();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,16 +183,66 @@ void TaskTransformedParameters::showOriginals()
|
|||
}
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::exitSelectionMode()
|
||||
{
|
||||
originalSelectionMode = false;
|
||||
referenceSelectionMode = false;
|
||||
Gui::Selection().rmvSelectionGate();
|
||||
showObject();
|
||||
hideOriginals();
|
||||
}
|
||||
|
||||
class ReferenceSelection : public Gui::SelectionFilterGate
|
||||
{
|
||||
const App::DocumentObject* support;
|
||||
bool edge, plane;
|
||||
public:
|
||||
ReferenceSelection(const App::DocumentObject* support_, bool edge_, bool plane_)
|
||||
: Gui::SelectionFilterGate((Gui::SelectionFilter*)0),
|
||||
support(support_), edge(edge_), plane(plane_)
|
||||
{
|
||||
}
|
||||
bool allow(App::Document* pDoc, App::DocumentObject* pObj, const char* sSubName)
|
||||
{
|
||||
if (!sSubName || sSubName[0] == '\0')
|
||||
return false;
|
||||
if (pObj != support)
|
||||
return false;
|
||||
std::string subName(sSubName);
|
||||
if (edge && subName.size() > 4 && subName.substr(0,4) == "Edge")
|
||||
return true;
|
||||
if (plane && subName.size() > 4 && subName.substr(0,4) == "Face") {
|
||||
const Part::TopoShape &shape = static_cast<const Part::Feature*>(support)->Shape.getValue();
|
||||
TopoDS_Shape sh = shape.getSubShape(subName.c_str());
|
||||
const TopoDS_Face& face = TopoDS::Face(sh);
|
||||
if (!face.IsNull()) {
|
||||
BRepAdaptor_Surface adapt(face);
|
||||
if (adapt.GetType() == GeomAbs_Plane)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
void TaskTransformedParameters::addReferenceSelectionGate(bool edge, bool face)
|
||||
{
|
||||
Gui::Selection().addSelectionGate(new ReferenceSelection(getSupportObject(), edge, face));
|
||||
}
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
//**************************************************************************
|
||||
// TaskDialog
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
TaskDlgTransformedParameters::TaskDlgTransformedParameters(ViewProviderTransformed *TransformedView)
|
||||
: TaskDialog(),TransformedView(TransformedView)
|
||||
TaskDlgTransformedParameters::TaskDlgTransformedParameters(ViewProviderTransformed *TransformedView_)
|
||||
: TaskDialog(), TransformedView(TransformedView_)
|
||||
{
|
||||
assert(TransformedView);
|
||||
message = new TaskTransformedMessages(TransformedView);
|
||||
|
||||
Content.push_back(message);
|
||||
}
|
||||
|
||||
//==== calls from the TaskView ===============================================================
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <Gui/Selection.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
#include "TaskTransformedMessages.h"
|
||||
#include "ViewProviderTransformed.h"
|
||||
|
||||
namespace PartDesign {
|
||||
|
@ -59,18 +60,15 @@ public:
|
|||
{}
|
||||
|
||||
const std::vector<App::DocumentObject*> getOriginals(void) const;
|
||||
/// Get the support object either of the object associated with this feature or with the parent feature (MultiTransform mode)
|
||||
App::DocumentObject* getSupportObject() const;
|
||||
|
||||
|
||||
protected Q_SLOTS:
|
||||
virtual void onButtonReference() = 0;
|
||||
virtual void onOriginalDeleted() = 0;
|
||||
virtual void onUpdateView(bool) = 0;
|
||||
|
||||
/// Connect the subTask OK button to the MultiTransform task
|
||||
virtual void onSubTaskButtonOK() {}
|
||||
|
||||
protected:
|
||||
void onOriginalDeleted(const int row);
|
||||
const bool originalSelected(const Gui::SelectionChanges& msg);
|
||||
|
||||
/// Get the TransformedFeature object associated with this task
|
||||
|
@ -78,14 +76,14 @@ protected:
|
|||
PartDesign::Transformed *getObject() const;
|
||||
/// Recompute either this feature or the parent feature (MultiTransform mode)
|
||||
void recomputeFeature();
|
||||
/// Get the original object either of the object associated with this feature or with the parent feature (MultiTransform mode)
|
||||
App::DocumentObject* getOriginalObject() const;
|
||||
|
||||
void hideObject();
|
||||
void showObject();
|
||||
void hideOriginals();
|
||||
void showOriginals();
|
||||
void exitSelectionMode();
|
||||
|
||||
void addReferenceSelectionGate(bool edge, bool face);
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *e) = 0;
|
||||
virtual void onSelectionChanged(const Gui::SelectionChanges& msg) = 0;
|
||||
|
@ -93,14 +91,16 @@ protected:
|
|||
protected:
|
||||
QWidget* proxy;
|
||||
ViewProviderTransformed *TransformedView;
|
||||
bool featureSelectionMode;
|
||||
|
||||
bool originalSelectionMode;
|
||||
bool referenceSelectionMode;
|
||||
|
||||
/// The MultiTransform parent task of this task
|
||||
TaskMultiTransformParameters* parentTask;
|
||||
/// Flag indicating whether this object is a container for MultiTransform
|
||||
bool insideMultiTransform;
|
||||
/// Lock updateUI() so that no unnecessary recomputeFeatures() are triggered
|
||||
bool updateUIinProgress;
|
||||
/// Lock updateUI(), applying changes to the underlying feature and calling recomputeFeature()
|
||||
bool blockUpdate;
|
||||
};
|
||||
|
||||
/// simulation dialog for the TaskView
|
||||
|
@ -138,6 +138,7 @@ protected:
|
|||
ViewProviderTransformed *TransformedView;
|
||||
|
||||
TaskTransformedParameters *parameter;
|
||||
TaskTransformedMessages *message;
|
||||
};
|
||||
|
||||
} //namespace PartDesignGui
|
||||
|
|
|
@ -112,3 +112,30 @@ const bool ViewProviderTransformed::checkDlgOpen(TaskDlgTransformedParameters* t
|
|||
// Continue (usually in virtual method setEdit())
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViewProviderTransformed::recomputeFeature(void)
|
||||
{
|
||||
PartDesign::Transformed* pcTransformed = static_cast<PartDesign::Transformed*>(getObject());
|
||||
pcTransformed->getDocument()->recomputeFeature(pcTransformed);
|
||||
const std::vector<App::DocumentObjectExecReturn*> log = pcTransformed->getDocument()->getRecomputeLog();
|
||||
unsigned rejected = pcTransformed->getRejectedTransformations().size();
|
||||
QString msg = QString::fromAscii("%1");
|
||||
if (rejected > 0) {
|
||||
msg = QString::fromLatin1("<font color='orange'>%1<br/></font>\r\n%2");
|
||||
if (rejected == 1)
|
||||
msg = msg.arg(QObject::tr("One transformed shape does not intersect support"));
|
||||
else {
|
||||
msg = msg.arg(QObject::tr("%1 transformed shapes do not intersect support"));
|
||||
msg = msg.arg(rejected);
|
||||
}
|
||||
}
|
||||
if (log.size() > 0) {
|
||||
msg = msg.arg(QString::fromLatin1("<font color='red'>%1<br/></font>"));
|
||||
msg = msg.arg(QString::fromStdString(log.back()->Why));
|
||||
} else {
|
||||
msg = msg.arg(QString::fromLatin1("<font color='green'>%1<br/></font>"));
|
||||
msg = msg.arg(QObject::tr("Transformation succeeded"));
|
||||
}
|
||||
signalDiagnosis(msg);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,9 @@ public:
|
|||
|
||||
virtual bool onDelete(const std::vector<std::string> &);
|
||||
|
||||
/// signals if the transformation contains errors
|
||||
boost::signal<void (QString msg)> signalDiagnosis;
|
||||
|
||||
// The feature name of the subclass
|
||||
std::string featureName;
|
||||
|
||||
|
@ -56,6 +59,8 @@ protected:
|
|||
virtual void unsetEdit(int ModNum);
|
||||
|
||||
const bool checkDlgOpen(TaskDlgTransformedParameters* transformedDlg);
|
||||
public:
|
||||
void recomputeFeature();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -125,10 +125,10 @@ void Workbench::activated()
|
|||
"PartDesign_MultiTransform",
|
||||
0};
|
||||
Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
|
||||
"SELECT Part::Feature",
|
||||
"SELECT PartDesign::SketchBased",
|
||||
Transformed,
|
||||
"Transformation tools",
|
||||
"PartDesign_Mirrored"
|
||||
"PartDesign_MultiTransform"
|
||||
));
|
||||
|
||||
const char* Empty[] = {
|
||||
|
|
Loading…
Reference in New Issue
Block a user