PartDesign: make transform parameter dialogs use common base code with other dialogs
subj; Make PasrtDesign::Transformed provide common for all features classes interface getBaseObject() instead of specific getSupportObject (); Refactor some TransformedParameters methods.
This commit is contained in:
parent
e6a99ce96f
commit
113c10a2b7
|
@ -67,21 +67,37 @@ Transformed::Transformed()
|
|||
|
||||
void Transformed::positionBySupport(void)
|
||||
{
|
||||
Part::Feature *support = static_cast<Part::Feature*>(getSupportObject());
|
||||
if ((support != NULL) && support->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
// TODO May be here better to throw exception (silent=false) (2015-07-27, Fat-Zer)
|
||||
Part::Feature *support = getBaseObject(/* silent =*/ true);
|
||||
if (support)
|
||||
this->Placement.setValue(support->Placement.getValue());
|
||||
}
|
||||
|
||||
App::DocumentObject* Transformed::getSupportObject() const
|
||||
{
|
||||
if (BaseFeature.getValue() != NULL)
|
||||
return BaseFeature.getValue();
|
||||
else {
|
||||
if (!Originals.getValues().empty())
|
||||
return Originals.getValues().front(); // For legacy features
|
||||
else
|
||||
return NULL;
|
||||
Part::Feature* Transformed::getBaseObject(bool silent) const {
|
||||
Part::Feature *rv = Feature::getBaseObject(/* silent = */ true);
|
||||
if (rv) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
const char* err = nullptr;
|
||||
const std::vector<App::DocumentObject*> & originals = Originals.getValues();
|
||||
// NOTE: may be here supposed to be last origin but in order to keep the old behaviour keep here first
|
||||
App::DocumentObject* firstOriginal = originals.empty() ? NULL : originals.front();
|
||||
if (firstOriginal) {
|
||||
if(firstOriginal->isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
rv = static_cast<Part::Feature*>(firstOriginal);
|
||||
} else {
|
||||
err = "Transformation feature Linked object is not a Part object";
|
||||
}
|
||||
} else {
|
||||
err = "No originals linked to the transformed feature.";
|
||||
}
|
||||
|
||||
if (!silent && err) {
|
||||
throw Base::Exception(err);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
App::DocumentObject* Transformed::getSketchObject() const
|
||||
|
@ -195,9 +211,14 @@ App::DocumentObjectExecReturn *Transformed::execute(void)
|
|||
return App::DocumentObject::StdReturn; // No transformations defined, exit silently
|
||||
|
||||
// Get the support
|
||||
Part::Feature* supportFeature = static_cast<Part::Feature*>(getSupportObject());
|
||||
if (supportFeature == NULL)
|
||||
return new App::DocumentObjectExecReturn("No support for transformation feature");
|
||||
Part::Feature* supportFeature = getBaseObject();
|
||||
|
||||
try {
|
||||
supportFeature = getBaseObject();
|
||||
} catch (Base::Exception& e) {
|
||||
return new App::DocumentObjectExecReturn(e.what());
|
||||
}
|
||||
|
||||
const Part::TopoShape& supportTopShape = supportFeature->Shape.getShape();
|
||||
if (supportTopShape._Shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Cannot transform invalid support shape");
|
||||
|
|
|
@ -49,8 +49,14 @@ public:
|
|||
*/
|
||||
App::PropertyLinkList Originals;
|
||||
|
||||
/// Return first original, which serves as "Support" until Body feature becomes functional
|
||||
App::DocumentObject* getSupportObject() const;
|
||||
/**
|
||||
* Returns the BaseFeature property's object(if any) otherwise return first original,
|
||||
* which serves as "Support" for old style workflows
|
||||
* @param silent if couldn't determine the base feature and silent == true,
|
||||
* silently return a nullptr, otherwise throw Base::Exception.
|
||||
* Default is false.
|
||||
*/
|
||||
virtual Part::Feature* getBaseObject(bool silent=false) const;
|
||||
|
||||
/// Return the sketch of the first original
|
||||
App::DocumentObject* getSketchObject() const;
|
||||
|
|
|
@ -427,19 +427,10 @@ TaskDlgLinearPatternParameters::TaskDlgLinearPatternParameters(ViewProviderLinea
|
|||
|
||||
bool TaskDlgLinearPatternParameters::accept()
|
||||
{
|
||||
try {
|
||||
// Handle Originals
|
||||
if (!TaskDlgTransformedParameters::accept())
|
||||
return false;
|
||||
|
||||
parameter->apply();
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what()));
|
||||
return false;
|
||||
}
|
||||
parameter->apply();
|
||||
|
||||
return true;
|
||||
return TaskDlgTransformedParameters::accept();
|
||||
}
|
||||
|
||||
#include "moc_TaskLinearPatternParameters.cpp"
|
||||
|
|
|
@ -192,51 +192,6 @@ void TaskLinearPatternParameters::updateUI()
|
|||
dirLinks.setCurrentLink(pcLinearPattern->Direction);
|
||||
}
|
||||
|
||||
<<<<<<< 05d084614fa15ead10b7283f4f36e3e587279953
|
||||
for (int i=ui->comboDirection->count()-1; i >= maxcount; i--)
|
||||
ui->comboDirection->removeItem(i);
|
||||
for (int i=ui->comboDirection->count(); i < maxcount; i++)
|
||||
ui->comboDirection->addItem(QString::fromLatin1("Sketch axis %1").arg(i-5));
|
||||
|
||||
bool undefined = false;
|
||||
if (directionFeature != NULL && !directions.empty()) {
|
||||
bool is_base_line = directionFeature->isDerivedFrom(App::Line::getClassTypeId());
|
||||
|
||||
if (directions.front() == "H_Axis")
|
||||
ui->comboDirection->setCurrentIndex(0);
|
||||
else if (directions.front() == "V_Axis")
|
||||
ui->comboDirection->setCurrentIndex(1);
|
||||
else if (is_base_line && strcmp(static_cast<App::Line*>(directionFeature)->LineType.getValue(), App::Part::BaselineTypes[0]) == 0)
|
||||
ui->comboDirection->setCurrentIndex( sketch ? 2 : 0);
|
||||
else if (is_base_line && strcmp(static_cast<App::Line*>(directionFeature)->LineType.getValue(), App::Part::BaselineTypes[1]) == 0)
|
||||
ui->comboDirection->setCurrentIndex(sketch ? 3 : 1);
|
||||
else if (is_base_line && strcmp(static_cast<App::Line*>(directionFeature)->LineType.getValue(), App::Part::BaselineTypes[2]) == 0)
|
||||
ui->comboDirection->setCurrentIndex(sketch ? 4 : 2);
|
||||
else if (directions.front().size() > (sketch ? 4 : 2) && directions.front().substr(0,4) == "Axis") {
|
||||
int pos = (sketch ? 5 : 3) + std::atoi(directions.front().substr(4,4000).c_str());
|
||||
if (pos <= maxcount)
|
||||
ui->comboDirection->setCurrentIndex(pos);
|
||||
else
|
||||
undefined = true;
|
||||
} else {
|
||||
ui->comboDirection->addItem(getRefStr(directionFeature, directions));
|
||||
ui->comboDirection->setCurrentIndex(maxcount);
|
||||
}
|
||||
} else {
|
||||
undefined = true;
|
||||
}
|
||||
|
||||
if (selectionMode == reference) {
|
||||
ui->comboDirection->addItem(tr("Select an edge/face or datum line/plane"));
|
||||
ui->comboDirection->setCurrentIndex(ui->comboDirection->count() - 1);
|
||||
} else if (undefined) {
|
||||
ui->comboDirection->addItem(tr("Undefined"));
|
||||
ui->comboDirection->setCurrentIndex(ui->comboDirection->count() - 1);
|
||||
} else
|
||||
ui->comboDirection->addItem(tr("Select reference..."));
|
||||
|
||||
=======
|
||||
>>>>>>> PartDesign: rework axis and plane comboboxes and make it work without part.
|
||||
// Note: These three lines would trigger onLength(), on Occurrences() and another updateUI() if we
|
||||
// didn't check for blockUpdate
|
||||
ui->checkReverse->setChecked(reverse);
|
||||
|
@ -472,19 +427,19 @@ TaskDlgLinearPatternParameters::TaskDlgLinearPatternParameters(ViewProviderLinea
|
|||
|
||||
bool TaskDlgLinearPatternParameters::accept()
|
||||
{
|
||||
try {
|
||||
// Handle Originals
|
||||
if (!TaskDlgTransformedParameters::accept())
|
||||
return false;
|
||||
|
||||
<<<<<<< a6aea83ec9ef83d52a06178b32175b3e79f73c65
|
||||
parameter->apply();
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what()));
|
||||
return false;
|
||||
}
|
||||
=======
|
||||
parameter->apply();
|
||||
>>>>>>> PartDesign: make transform parameter dialogs use common base code with other dialogs
|
||||
|
||||
return true;
|
||||
return TaskDlgTransformedParameters::accept();
|
||||
}
|
||||
|
||||
#include "moc_TaskLinearPatternParameters.cpp"
|
||||
|
|
|
@ -313,35 +313,20 @@ TaskDlgMirroredParameters::TaskDlgMirroredParameters(ViewProviderMirrored *Mirro
|
|||
|
||||
bool TaskDlgMirroredParameters::accept()
|
||||
{
|
||||
std::string name = TransformedView->getObject()->getNameInDocument();
|
||||
std::string name = vp->getObject()->getNameInDocument();
|
||||
|
||||
try {
|
||||
// Handle Originals
|
||||
if (!TaskDlgTransformedParameters::accept())
|
||||
return false;
|
||||
|
||||
TaskMirroredParameters* mirrorParameter = static_cast<TaskMirroredParameters*>(parameter);
|
||||
std::vector<std::string> mirrorPlanes;
|
||||
App::DocumentObject* obj;
|
||||
mirrorParameter->getMirrorPlane(obj, mirrorPlanes);
|
||||
std::string mirrorPlane = getPythonStr(obj, mirrorPlanes);
|
||||
if (!mirrorPlane.empty() && obj) {
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = %s", name.c_str(), mirrorPlane.c_str());
|
||||
} else {
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = None", name.c_str());
|
||||
}
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
|
||||
if (!TransformedView->getObject()->isValid())
|
||||
throw Base::Exception(TransformedView->getObject()->getStatusString());
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
|
||||
Gui::Command::commitCommand();
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what()));
|
||||
return false;
|
||||
TaskMirroredParameters* mirrorParameter = static_cast<TaskMirroredParameters*>(parameter);
|
||||
std::vector<std::string> mirrorPlanes;
|
||||
App::DocumentObject* obj;
|
||||
mirrorParameter->getMirrorPlane(obj, mirrorPlanes);
|
||||
std::string mirrorPlane = getPythonStr(obj, mirrorPlanes);
|
||||
if (!mirrorPlane.empty() && obj) {
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = %s", name.c_str(), mirrorPlane.c_str());
|
||||
} else {
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = None", name.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
return TaskDlgTransformedParameters::accept();
|
||||
}
|
||||
|
||||
#include "moc_TaskMirroredParameters.cpp"
|
||||
|
|
|
@ -157,55 +157,10 @@ void TaskMirroredParameters::updateUI()
|
|||
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
|
||||
<<<<<<< 05d084614fa15ead10b7283f4f36e3e587279953
|
||||
App::DocumentObject* mirrorPlaneFeature = pcMirrored->MirrorPlane.getValue();
|
||||
std::vector<std::string> mirrorPlanes = pcMirrored->MirrorPlane.getSubValues();
|
||||
|
||||
// Add user-defined sketch axes to the reference selection combo box
|
||||
App::DocumentObject* sketch = getSketchObject();
|
||||
int maxcount=3;
|
||||
if (sketch) {
|
||||
maxcount = 5;
|
||||
maxcount += static_cast<Part::Part2DObject*>(sketch)->getAxisCount();
|
||||
}
|
||||
|
||||
for (int i=ui->comboPlane->count()-1; i >= (sketch ? 5 : 3); i--)
|
||||
ui->comboPlane->removeItem(i);
|
||||
for (int i=ui->comboPlane->count(); i < maxcount; i++)
|
||||
ui->comboPlane->addItem(QString::fromLatin1("Sketch axis %1").arg(i-5));
|
||||
|
||||
bool undefined = false;
|
||||
if (mirrorPlaneFeature != NULL && !mirrorPlanes.empty()) {
|
||||
bool is_base_plane = mirrorPlaneFeature->isDerivedFrom(App::Plane::getClassTypeId());
|
||||
|
||||
if (mirrorPlanes.front() == "H_Axis")
|
||||
ui->comboPlane->setCurrentIndex(0);
|
||||
else if (mirrorPlanes.front() == "V_Axis")
|
||||
ui->comboPlane->setCurrentIndex(1);
|
||||
else if (is_base_plane && strcmp(static_cast<App::Plane*>(mirrorPlaneFeature)->PlaneType.getValue(), App::Part::BaseplaneTypes[0]) == 0)
|
||||
ui->comboPlane->setCurrentIndex((sketch ? 2 : 0));
|
||||
else if (is_base_plane && strcmp(static_cast<App::Plane*>(mirrorPlaneFeature)->PlaneType.getValue(), App::Part::BaseplaneTypes[1]) == 0)
|
||||
ui->comboPlane->setCurrentIndex((sketch ? 3 : 1));
|
||||
else if (is_base_plane && strcmp(static_cast<App::Plane*>(mirrorPlaneFeature)->PlaneType.getValue(), App::Part::BaseplaneTypes[2]) == 0)
|
||||
ui->comboPlane->setCurrentIndex((sketch ? 4 : 2));
|
||||
else if (mirrorPlanes.front().size() > (sketch ? 4 : 2) && mirrorPlanes.front().substr(0,4) == "Axis") {
|
||||
int pos = (sketch ? 5 : 3) + std::atoi(mirrorPlanes.front().substr(4,4000).c_str());
|
||||
if (pos <= maxcount)
|
||||
ui->comboPlane->setCurrentIndex(pos);
|
||||
else
|
||||
undefined = true;
|
||||
} else {
|
||||
ui->comboPlane->addItem(getRefStr(mirrorPlaneFeature, mirrorPlanes));
|
||||
ui->comboPlane->setCurrentIndex(maxcount);
|
||||
}
|
||||
} else {
|
||||
undefined = true;
|
||||
=======
|
||||
if (planeLinks.setCurrentLink(pcMirrored->MirrorPlane) == -1){
|
||||
//failed to set current, because the link isnt in the list yet
|
||||
planeLinks.addLink(pcMirrored->MirrorPlane, getRefStr(pcMirrored->MirrorPlane.getValue(),pcMirrored->MirrorPlane.getSubValues()));
|
||||
planeLinks.setCurrentLink(pcMirrored->MirrorPlane);
|
||||
>>>>>>> PartDesign: rework axis and plane comboboxes and make it work without part.
|
||||
}
|
||||
|
||||
blockUpdate = false;
|
||||
|
@ -358,6 +313,7 @@ TaskDlgMirroredParameters::TaskDlgMirroredParameters(ViewProviderMirrored *Mirro
|
|||
|
||||
bool TaskDlgMirroredParameters::accept()
|
||||
{
|
||||
<<<<<<< a6aea83ec9ef83d52a06178b32175b3e79f73c65
|
||||
std::string name = TransformedView->getObject()->getNameInDocument();
|
||||
|
||||
try {
|
||||
|
@ -384,9 +340,22 @@ bool TaskDlgMirroredParameters::accept()
|
|||
catch (const Base::Exception& e) {
|
||||
QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what()));
|
||||
return false;
|
||||
=======
|
||||
std::string name = vp->getObject()->getNameInDocument();
|
||||
|
||||
TaskMirroredParameters* mirrorParameter = static_cast<TaskMirroredParameters*>(parameter);
|
||||
std::vector<std::string> mirrorPlanes;
|
||||
App::DocumentObject* obj;
|
||||
mirrorParameter->getMirrorPlane(obj, mirrorPlanes);
|
||||
std::string mirrorPlane = getPythonStr(obj, mirrorPlanes);
|
||||
if (!mirrorPlane.empty() && obj) {
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = %s", name.c_str(), mirrorPlane.c_str());
|
||||
} else {
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = None", name.c_str());
|
||||
>>>>>>> PartDesign: make transform parameter dialogs use common base code with other dialogs
|
||||
}
|
||||
|
||||
return true;
|
||||
return TaskDlgTransformedParameters::accept();
|
||||
}
|
||||
|
||||
#include "moc_TaskMirroredParameters.cpp"
|
||||
|
|
|
@ -442,44 +442,29 @@ TaskDlgMultiTransformParameters::TaskDlgMultiTransformParameters(ViewProviderMul
|
|||
|
||||
bool TaskDlgMultiTransformParameters::accept()
|
||||
{
|
||||
std::string name = TransformedView->getObject()->getNameInDocument();
|
||||
std::string name = vp->getObject()->getNameInDocument();
|
||||
|
||||
try {
|
||||
//Gui::Command::openCommand("MultiTransform changed");
|
||||
// Handle Originals
|
||||
if (!TaskDlgTransformedParameters::accept())
|
||||
return false;
|
||||
|
||||
TaskMultiTransformParameters* mtParameter = static_cast<TaskMultiTransformParameters*>(parameter);
|
||||
std::vector<App::DocumentObject*> transformFeatures = mtParameter->getTransformFeatures();
|
||||
std::stringstream str;
|
||||
str << "App.ActiveDocument." << name.c_str() << ".Transformations = [";
|
||||
for (std::vector<App::DocumentObject*>::const_iterator it = transformFeatures.begin(); it != transformFeatures.end(); it++)
|
||||
{
|
||||
if ((*it) != NULL)
|
||||
str << "App.ActiveDocument." << (*it)->getNameInDocument() << ",";
|
||||
}
|
||||
str << "]";
|
||||
Gui::Command::runCommand(Gui::Command::Doc,str.str().c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
|
||||
if (!TransformedView->getObject()->isValid())
|
||||
throw Base::Exception(TransformedView->getObject()->getStatusString());
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
|
||||
Gui::Command::commitCommand();
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what()));
|
||||
return false;
|
||||
// Set up transformations
|
||||
TaskMultiTransformParameters* mtParameter = static_cast<TaskMultiTransformParameters*>(parameter);
|
||||
std::vector<App::DocumentObject*> transformFeatures = mtParameter->getTransformFeatures();
|
||||
std::stringstream str;
|
||||
str << "App.ActiveDocument." << name.c_str() << ".Transformations = [";
|
||||
for (std::vector<App::DocumentObject*>::const_iterator it = transformFeatures.begin(); it != transformFeatures.end(); it++)
|
||||
{
|
||||
if ((*it) != NULL)
|
||||
str << "App.ActiveDocument." << (*it)->getNameInDocument() << ",";
|
||||
}
|
||||
str << "]";
|
||||
Gui::Command::runCommand(Gui::Command::Doc,str.str().c_str());
|
||||
|
||||
return true;
|
||||
return TaskDlgFeatureParameters::accept ();
|
||||
}
|
||||
|
||||
bool TaskDlgMultiTransformParameters::reject()
|
||||
{
|
||||
// Get objects before view is invalidated
|
||||
// For the same reason we can't delegate showing the originals to TaskDlgTransformedParameters::reject()
|
||||
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(TransformedView->getObject());
|
||||
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(vp->getObject());
|
||||
std::vector<App::DocumentObject*> transformFeatures = pcMultiTransform->Transformations.getValues();
|
||||
|
||||
// Delete the transformation features - must happen before abortCommand()!
|
||||
|
|
|
@ -142,11 +142,7 @@ TaskMultiTransformParameters::TaskMultiTransformParameters(ViewProviderTransform
|
|||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); i++)
|
||||
{
|
||||
if ((*i) != NULL)
|
||||
<<<<<<< 9bd4990584bfddd638e710ece8d981c1d8e4cc5e
|
||||
ui->listWidgetFeatures->insertItem(0, QString::fromLatin1((*i)->getNameInDocument()));
|
||||
=======
|
||||
ui->listWidgetFeatures->addItem(QString::fromAscii((*i)->getNameInDocument()));
|
||||
>>>>>>> Fixed bugs in various features that reversed the list of selections
|
||||
ui->listWidgetFeatures->addItem(QString::fromLatin1((*i)->getNameInDocument()));
|
||||
}
|
||||
// ---------------------
|
||||
}
|
||||
|
@ -155,11 +151,7 @@ void TaskMultiTransformParameters::onSelectionChanged(const Gui::SelectionChange
|
|||
{
|
||||
if (originalSelected(msg)) {
|
||||
if (selectionMode == addFeature)
|
||||
<<<<<<< 9bd4990584bfddd638e710ece8d981c1d8e4cc5e
|
||||
ui->listWidgetFeatures->insertItem(0, QString::fromLatin1(msg.pObjectName));
|
||||
=======
|
||||
ui->listWidgetFeatures->addItem(QString::fromAscii(msg.pObjectName));
|
||||
>>>>>>> Fixed bugs in various features that reversed the list of selections
|
||||
ui->listWidgetFeatures->addItem(QString::fromLatin1(msg.pObjectName));
|
||||
else
|
||||
removeItemFromListWidget(ui->listWidgetFeatures, msg.pObjectName);
|
||||
exitSelectionMode();
|
||||
|
@ -450,6 +442,7 @@ TaskDlgMultiTransformParameters::TaskDlgMultiTransformParameters(ViewProviderMul
|
|||
|
||||
bool TaskDlgMultiTransformParameters::accept()
|
||||
{
|
||||
<<<<<<< a6aea83ec9ef83d52a06178b32175b3e79f73c65
|
||||
std::string name = TransformedView->getObject()->getNameInDocument();
|
||||
|
||||
try {
|
||||
|
@ -478,16 +471,31 @@ bool TaskDlgMultiTransformParameters::accept()
|
|||
catch (const Base::Exception& e) {
|
||||
QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what()));
|
||||
return false;
|
||||
}
|
||||
=======
|
||||
std::string name = vp->getObject()->getNameInDocument();
|
||||
|
||||
return true;
|
||||
// Set up transformations
|
||||
TaskMultiTransformParameters* mtParameter = static_cast<TaskMultiTransformParameters*>(parameter);
|
||||
std::vector<App::DocumentObject*> transformFeatures = mtParameter->getTransformFeatures();
|
||||
std::stringstream str;
|
||||
str << "App.ActiveDocument." << name.c_str() << ".Transformations = [";
|
||||
for (std::vector<App::DocumentObject*>::const_iterator it = transformFeatures.begin(); it != transformFeatures.end(); it++)
|
||||
{
|
||||
if ((*it) != NULL)
|
||||
str << "App.ActiveDocument." << (*it)->getNameInDocument() << ",";
|
||||
>>>>>>> PartDesign: make transform parameter dialogs use common base code with other dialogs
|
||||
}
|
||||
str << "]";
|
||||
Gui::Command::runCommand(Gui::Command::Doc,str.str().c_str());
|
||||
|
||||
return TaskDlgFeatureParameters::accept ();
|
||||
}
|
||||
|
||||
bool TaskDlgMultiTransformParameters::reject()
|
||||
{
|
||||
// Get objects before view is invalidated
|
||||
// For the same reason we can't delegate showing the originals to TaskDlgTransformedParameters::reject()
|
||||
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(TransformedView->getObject());
|
||||
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(vp->getObject());
|
||||
std::vector<App::DocumentObject*> transformFeatures = pcMultiTransform->Transformations.getValues();
|
||||
|
||||
// Delete the transformation features - must happen before abortCommand()!
|
||||
|
@ -498,10 +506,6 @@ bool TaskDlgMultiTransformParameters::reject()
|
|||
Gui::Command::Doc,"App.ActiveDocument.removeObject(\"%s\")", (*it)->getNameInDocument());
|
||||
}
|
||||
|
||||
// roll back the done things
|
||||
Gui::Command::abortCommand();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
|
||||
|
||||
return TaskDlgTransformedParameters::reject();
|
||||
}
|
||||
|
||||
|
|
|
@ -418,19 +418,10 @@ TaskDlgPolarPatternParameters::TaskDlgPolarPatternParameters(ViewProviderPolarPa
|
|||
|
||||
bool TaskDlgPolarPatternParameters::accept()
|
||||
{
|
||||
try {
|
||||
// Handle Originals
|
||||
if (!TaskDlgTransformedParameters::accept())
|
||||
return false;
|
||||
|
||||
parameter->apply();
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what()));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return TaskDlgTransformedParameters::accept();
|
||||
}
|
||||
|
||||
#include "moc_TaskPolarPatternParameters.cpp"
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#include <Base/UnitsApi.h>
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/Part.h>
|
||||
#include <App/Line.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
|
@ -44,6 +46,7 @@
|
|||
#include <Base/Console.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/ViewProviderOrigin.h>
|
||||
#include <Mod/PartDesign/App/FeaturePolarPattern.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
#include <Mod/PartDesign/App/DatumLine.h>
|
||||
|
@ -132,11 +135,7 @@ void TaskPolarPatternParameters::setupUI()
|
|||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); ++i)
|
||||
{
|
||||
if ((*i) != NULL)
|
||||
<<<<<<< 9bd4990584bfddd638e710ece8d981c1d8e4cc5e
|
||||
ui->listWidgetFeatures->insertItem(0, QString::fromLatin1((*i)->getNameInDocument()));
|
||||
=======
|
||||
ui->listWidgetFeatures->addItem(QString::fromAscii((*i)->getNameInDocument()));
|
||||
>>>>>>> Fixed bugs in various features that reversed the list of selections
|
||||
ui->listWidgetFeatures->addItem(QString::fromLatin1((*i)->getNameInDocument()));
|
||||
}
|
||||
// ---------------------
|
||||
|
||||
|
@ -148,7 +147,25 @@ void TaskPolarPatternParameters::setupUI()
|
|||
ui->checkReverse->setEnabled(true);
|
||||
ui->polarAngle->setEnabled(true);
|
||||
ui->spinOccurrences->setEnabled(true);
|
||||
|
||||
App::DocumentObject* sketch = getSketchObject();
|
||||
if (!(sketch->isDerivedFrom(Part::Part2DObject::getClassTypeId())))
|
||||
sketch = 0;
|
||||
this->axesLinks.setCombo(*(ui->comboAxis));
|
||||
this->fillAxisCombo(axesLinks, static_cast<Part::Part2DObject*>(sketch));
|
||||
updateUI();
|
||||
|
||||
//show the parts coordinate system axis for selection
|
||||
App::Part* part = getPartFor(getObject(), false);
|
||||
if(part) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
|
||||
origin->setTemporaryVisibilityAxis(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::updateUI()
|
||||
|
@ -159,32 +176,16 @@ void TaskPolarPatternParameters::updateUI()
|
|||
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
|
||||
App::DocumentObject* axisFeature = pcPolarPattern->Axis.getValue();
|
||||
std::vector<std::string> axes = pcPolarPattern->Axis.getSubValues();
|
||||
bool reverse = pcPolarPattern->Reversed.getValue();
|
||||
double angle = pcPolarPattern->Angle.getValue();
|
||||
unsigned occurrences = pcPolarPattern->Occurrences.getValue();
|
||||
|
||||
for (int i=ui->comboAxis->count()-1; i >= 1; i--)
|
||||
ui->comboAxis->removeItem(i);
|
||||
|
||||
if (axisFeature != NULL && !axes.empty()) {
|
||||
if (axes.front() == "N_Axis")
|
||||
ui->comboAxis->setCurrentIndex(0);
|
||||
else {
|
||||
ui->comboAxis->addItem(getRefStr(axisFeature, axes));
|
||||
ui->comboAxis->setCurrentIndex(1);
|
||||
}
|
||||
} else {
|
||||
// Error message?
|
||||
if (axesLinks.setCurrentLink(pcPolarPattern->Axis) == -1){
|
||||
//failed to set current, because the link isnt in the list yet
|
||||
axesLinks.addLink(pcPolarPattern->Axis, getRefStr(pcPolarPattern->Axis.getValue(),pcPolarPattern->Axis.getSubValues()));
|
||||
axesLinks.setCurrentLink(pcPolarPattern->Axis);
|
||||
}
|
||||
|
||||
if (selectionMode == reference) {
|
||||
ui->comboAxis->addItem(tr("Select an edge or datum line"));
|
||||
ui->comboAxis->setCurrentIndex(ui->comboAxis->count() - 1);
|
||||
} else
|
||||
ui->comboAxis->addItem(tr("Select reference..."));
|
||||
|
||||
// Note: These three lines would trigger onLength(), on Occurrences() and another updateUI() if we
|
||||
// didn't check for blockUpdate
|
||||
ui->checkReverse->setChecked(reverse);
|
||||
|
@ -210,39 +211,33 @@ void TaskPolarPatternParameters::onSelectionChanged(const Gui::SelectionChanges&
|
|||
|
||||
if (originalSelected(msg)) {
|
||||
if (selectionMode == addFeature)
|
||||
<<<<<<< 9bd4990584bfddd638e710ece8d981c1d8e4cc5e
|
||||
ui->listWidgetFeatures->insertItem(0, QString::fromLatin1(msg.pObjectName));
|
||||
=======
|
||||
ui->listWidgetFeatures->addItem(QString::fromAscii(msg.pObjectName));
|
||||
>>>>>>> Fixed bugs in various features that reversed the list of selections
|
||||
ui->listWidgetFeatures->addItem(QString::fromLatin1(msg.pObjectName));
|
||||
else
|
||||
removeItemFromListWidget(ui->listWidgetFeatures, msg.pObjectName);
|
||||
exitSelectionMode();
|
||||
} else if (selectionMode == reference) {
|
||||
// Note: ReferenceSelection has already checked the selection for validity
|
||||
exitSelectionMode();
|
||||
if (!blockUpdate) {
|
||||
std::vector<std::string> axes;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
getReferencedSelection(pcPolarPattern, msg, selObj, axes);
|
||||
pcPolarPattern->Axis.setValue(selObj, axes);
|
||||
std::vector<std::string> axes;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
getReferencedSelection(pcPolarPattern, msg, selObj, axes);
|
||||
pcPolarPattern->Axis.setValue(selObj, axes);
|
||||
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
else {
|
||||
for (int i=ui->comboAxis->count()-1; i >= 1; i--)
|
||||
ui->comboAxis->removeItem(i);
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
} else if( strstr(msg.pObjectName, App::Part::BaselineTypes[0]) == nullptr ||
|
||||
strstr(msg.pObjectName, App::Part::BaselineTypes[1]) == nullptr ||
|
||||
strstr(msg.pObjectName, App::Part::BaselineTypes[2]) == nullptr) {
|
||||
|
||||
std::vector<std::string> axes;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
getReferencedSelection(pcPolarPattern, msg, selObj, axes);
|
||||
pcPolarPattern->Axis.setValue(selObj, axes);
|
||||
|
||||
std::vector<std::string> axes;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
getReferencedSelection(pcPolarPattern, msg, selObj, axes);
|
||||
ui->comboAxis->addItem(getRefStr(selObj, axes));
|
||||
ui->comboAxis->setCurrentIndex(1);
|
||||
ui->comboAxis->addItem(tr("Select reference..."));
|
||||
}
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -288,20 +283,21 @@ void TaskPolarPatternParameters::onAxisChanged(int num) {
|
|||
return;
|
||||
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
|
||||
|
||||
if (num == 0) {
|
||||
pcPolarPattern->Axis.setValue(getSketchObject(), std::vector<std::string>(1,"N_Axis"));
|
||||
exitSelectionMode();
|
||||
try{
|
||||
if(axesLinks.getCurrentLink().getValue() == 0){
|
||||
// enter reference selection mode
|
||||
hideObject();
|
||||
showBase();
|
||||
selectionMode = reference;
|
||||
Gui::Selection().clearSelection();
|
||||
addReferenceSelectionGate(true, false);
|
||||
} else {
|
||||
exitSelectionMode();
|
||||
pcPolarPattern->Axis.Paste(axesLinks.getCurrentLink());
|
||||
}
|
||||
} catch (Base::Exception &e) {
|
||||
QMessageBox::warning(0,tr("Error"),QString::fromAscii(e.what()));
|
||||
}
|
||||
else if (num == ui->comboAxis->count() - 1) {
|
||||
// enter reference selection mode
|
||||
hideObject();
|
||||
showBase();
|
||||
selectionMode = reference;
|
||||
Gui::Selection().clearSelection();
|
||||
addReferenceSelectionGate(true, false);
|
||||
}
|
||||
else if (num == 1)
|
||||
exitSelectionMode();
|
||||
|
||||
kickUpdateViewTimer();
|
||||
}
|
||||
|
@ -337,19 +333,9 @@ void TaskPolarPatternParameters::onFeatureDeleted(void)
|
|||
|
||||
void TaskPolarPatternParameters::getAxis(App::DocumentObject*& obj, std::vector<std::string>& sub) const
|
||||
{
|
||||
obj = getSketchObject();
|
||||
sub = std::vector<std::string>(1,"");
|
||||
|
||||
if (ui->comboAxis->currentIndex() == 0) {
|
||||
sub[0] = "N_Axis";
|
||||
} else if (ui->comboAxis->count() > 2 && ui->comboAxis->currentIndex() == 1) {
|
||||
QStringList parts = ui->comboAxis->currentText().split(QChar::fromAscii(':'));
|
||||
obj = getObject()->getDocument()->getObject(parts[0].toStdString().c_str());
|
||||
if (parts.size() > 1)
|
||||
sub[0] = parts[1].toStdString();
|
||||
} else {
|
||||
obj = NULL;
|
||||
}
|
||||
const App::PropertyLinkSub &lnk = axesLinks.getCurrentLink();
|
||||
obj = lnk.getValue();
|
||||
sub = lnk.getSubValues();
|
||||
}
|
||||
|
||||
const bool TaskPolarPatternParameters::getReverse(void) const
|
||||
|
@ -370,6 +356,17 @@ const unsigned TaskPolarPatternParameters::getOccurrences(void) const
|
|||
|
||||
TaskPolarPatternParameters::~TaskPolarPatternParameters()
|
||||
{
|
||||
//hide the parts coordinate system axis for selection
|
||||
App::Part* part = getPartFor(getObject(), false);
|
||||
if(part) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(false);
|
||||
}
|
||||
}
|
||||
|
||||
delete ui;
|
||||
if (proxy)
|
||||
delete proxy;
|
||||
|
@ -390,10 +387,11 @@ void TaskPolarPatternParameters::apply()
|
|||
App::DocumentObject* obj;
|
||||
getAxis(obj, axes);
|
||||
std::string axis = getPythonStr(obj, axes);
|
||||
if (!axis.empty()) {
|
||||
if (!axis.empty() && obj) {
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Axis = %s", name.c_str(), axis.c_str());
|
||||
} else
|
||||
} else {
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Axis = None", name.c_str());
|
||||
}
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),getReverse());
|
||||
ui->polarAngle->apply();
|
||||
ui->spinOccurrences->apply();
|
||||
|
@ -420,19 +418,18 @@ TaskDlgPolarPatternParameters::TaskDlgPolarPatternParameters(ViewProviderPolarPa
|
|||
|
||||
bool TaskDlgPolarPatternParameters::accept()
|
||||
{
|
||||
try {
|
||||
// Handle Originals
|
||||
if (!TaskDlgTransformedParameters::accept())
|
||||
return false;
|
||||
|
||||
parameter->apply();
|
||||
<<<<<<< a6aea83ec9ef83d52a06178b32175b3e79f73c65
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what()));
|
||||
return false;
|
||||
}
|
||||
=======
|
||||
>>>>>>> PartDesign: make transform parameter dialogs use common base code with other dialogs
|
||||
|
||||
return true;
|
||||
return TaskDlgTransformedParameters::accept();
|
||||
}
|
||||
|
||||
#include "moc_TaskPolarPatternParameters.cpp"
|
||||
|
|
|
@ -256,20 +256,10 @@ TaskDlgScaledParameters::TaskDlgScaledParameters(ViewProviderScaled *ScaledView)
|
|||
|
||||
bool TaskDlgScaledParameters::accept()
|
||||
{
|
||||
try {
|
||||
//Gui::Command::openCommand("Scaled changed");
|
||||
// Handle Originals
|
||||
if (!TaskDlgTransformedParameters::accept())
|
||||
return false;
|
||||
|
||||
parameter->apply();
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what()));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return TaskDlgTransformedParameters::accept();
|
||||
}
|
||||
|
||||
#include "moc_TaskScaledParameters.cpp"
|
||||
|
|
|
@ -114,11 +114,7 @@ void TaskScaledParameters::setupUI()
|
|||
for (std::vector<App::DocumentObject*>::const_iterator i = originals.begin(); i != originals.end(); ++i)
|
||||
{
|
||||
if ((*i) != NULL)
|
||||
<<<<<<< 9bd4990584bfddd638e710ece8d981c1d8e4cc5e
|
||||
ui->listWidgetFeatures->insertItem(0, QString::fromLatin1((*i)->getNameInDocument()));
|
||||
=======
|
||||
ui->listWidgetFeatures->addItem(QString::fromAscii((*i)->getNameInDocument()));
|
||||
>>>>>>> Fixed bugs in various features that reversed the list of selections
|
||||
ui->listWidgetFeatures->addItem(QString::fromLatin1((*i)->getNameInDocument()));
|
||||
}
|
||||
// ---------------------
|
||||
|
||||
|
@ -153,11 +149,7 @@ void TaskScaledParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
|||
{
|
||||
if (originalSelected(msg)) {
|
||||
if (selectionMode == addFeature)
|
||||
<<<<<<< 9bd4990584bfddd638e710ece8d981c1d8e4cc5e
|
||||
ui->listWidgetFeatures->insertItem(0, QString::fromLatin1(msg.pObjectName));
|
||||
=======
|
||||
ui->listWidgetFeatures->addItem(QString::fromAscii(msg.pObjectName));
|
||||
>>>>>>> Fixed bugs in various features that reversed the list of selections
|
||||
ui->listWidgetFeatures->addItem(QString::fromLatin1(msg.pObjectName));
|
||||
else
|
||||
removeItemFromListWidget(ui->listWidgetFeatures, msg.pObjectName);
|
||||
exitSelectionMode();
|
||||
|
@ -264,20 +256,18 @@ TaskDlgScaledParameters::TaskDlgScaledParameters(ViewProviderScaled *ScaledView)
|
|||
|
||||
bool TaskDlgScaledParameters::accept()
|
||||
{
|
||||
try {
|
||||
//Gui::Command::openCommand("Scaled changed");
|
||||
// Handle Originals
|
||||
if (!TaskDlgTransformedParameters::accept())
|
||||
return false;
|
||||
|
||||
parameter->apply();
|
||||
<<<<<<< a6aea83ec9ef83d52a06178b32175b3e79f73c65
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what()));
|
||||
return false;
|
||||
}
|
||||
=======
|
||||
>>>>>>> PartDesign: make transform parameter dialogs use common base code with other dialogs
|
||||
|
||||
return true;
|
||||
return TaskDlgTransformedParameters::accept();
|
||||
}
|
||||
|
||||
#include "moc_TaskScaledParameters.cpp"
|
||||
|
|
|
@ -169,17 +169,8 @@ void TaskTransformedParameters::removeItemFromListWidget(QListWidget* widget, co
|
|||
}
|
||||
}
|
||||
|
||||
PartDesign::Transformed *TaskTransformedParameters::getObject() const
|
||||
{
|
||||
|
||||
if (insideMultiTransform)
|
||||
return parentTask->getSubFeature();
|
||||
else
|
||||
return static_cast<PartDesign::Transformed*>(TransformedView->getObject());
|
||||
}
|
||||
|
||||
App::DocumentObject* TaskTransformedParameters::getPartPlanes(const char* str) const {
|
||||
|
||||
//TODO: Adjust to GRAPH handling when available
|
||||
App::DocumentObject* obj = getObject();
|
||||
App::Part* part = getPartFor(obj, false);
|
||||
|
@ -291,57 +282,56 @@ void TaskTransformedParameters::fillPlanesCombo(ComboLinks &combolinks,
|
|||
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::recomputeFeature()
|
||||
{
|
||||
if (insideMultiTransform) {
|
||||
// redirect recompute and let the parent decide if recompute has to be blocked
|
||||
parentTask->recomputeFeature();
|
||||
} else if (!blockUpdate) {
|
||||
TransformedView->recomputeFeature();
|
||||
}
|
||||
void TaskTransformedParameters::recomputeFeature() {
|
||||
getTopTransformedView()->recomputeFeature();
|
||||
}
|
||||
|
||||
const std::vector<App::DocumentObject*> TaskTransformedParameters::getOriginals(void) const
|
||||
{
|
||||
if (insideMultiTransform) {
|
||||
return parentTask->getOriginals();
|
||||
} else {
|
||||
PartDesign::Transformed* pcTransformed = static_cast<PartDesign::Transformed*>(TransformedView->getObject());
|
||||
std::vector<App::DocumentObject*> originals = pcTransformed->Originals.getValues();
|
||||
PartDesignGui::ViewProviderTransformed *TaskTransformedParameters::getTopTransformedView() const {
|
||||
PartDesignGui::ViewProviderTransformed *rv;
|
||||
|
||||
return originals;
|
||||
if (insideMultiTransform) {
|
||||
rv = parentTask->TransformedView;
|
||||
} else {
|
||||
rv = TransformedView;
|
||||
}
|
||||
assert (rv);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
App::DocumentObject* TaskTransformedParameters::getSupportObject() const
|
||||
{
|
||||
if (insideMultiTransform) {
|
||||
return parentTask->getSupportObject();
|
||||
} else {
|
||||
PartDesign::Transformed* pcTransformed = static_cast<PartDesign::Transformed*>(TransformedView->getObject());
|
||||
return pcTransformed->getSupportObject();
|
||||
}
|
||||
PartDesign::Transformed *TaskTransformedParameters::getTopTransformedObject() const {
|
||||
App::DocumentObject *transform = getTopTransformedView()->getObject();
|
||||
assert (transform->isDerivedFrom(PartDesign::Transformed::getClassTypeId()));
|
||||
return static_cast<PartDesign::Transformed*>(transform);
|
||||
}
|
||||
|
||||
App::DocumentObject* TaskTransformedParameters::getSketchObject() const
|
||||
{
|
||||
if (insideMultiTransform) {
|
||||
return parentTask->getSketchObject();
|
||||
} else {
|
||||
PartDesign::Transformed* pcTransformed = static_cast<PartDesign::Transformed*>(TransformedView->getObject());
|
||||
return pcTransformed->getSketchObject();
|
||||
}
|
||||
|
||||
PartDesign::Transformed *TaskTransformedParameters::getObject() const {
|
||||
if (insideMultiTransform)
|
||||
return parentTask->getSubFeature();
|
||||
else
|
||||
return static_cast<PartDesign::Transformed*>(TransformedView->getObject());
|
||||
}
|
||||
|
||||
Part::Feature *TaskTransformedParameters::getBaseObject() const {
|
||||
PartDesign::Feature* feature = getTopTransformedObject ();
|
||||
// NOTE: getBaseObject() throws if there is no base; shouldn't happen here.
|
||||
return feature->getBaseObject();
|
||||
}
|
||||
|
||||
const std::vector<App::DocumentObject*> & TaskTransformedParameters::getOriginals(void) const {
|
||||
return getTopTransformedObject()->Originals.getValues();
|
||||
}
|
||||
|
||||
App::DocumentObject* TaskTransformedParameters::getSketchObject() const {
|
||||
return getTopTransformedObject()->getSketchObject();
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::hideObject()
|
||||
{
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
if (doc) {
|
||||
if (insideMultiTransform) {
|
||||
doc->setHide(parentTask->TransformedView->getObject()->getNameInDocument());
|
||||
} else {
|
||||
doc->setHide(TransformedView->getObject()->getNameInDocument());
|
||||
}
|
||||
doc->setHide(getTopTransformedObject()->getNameInDocument());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -349,43 +339,27 @@ void TaskTransformedParameters::showObject()
|
|||
{
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
if (doc) {
|
||||
if (insideMultiTransform) {
|
||||
doc->setShow(parentTask->TransformedView->getObject()->getNameInDocument());
|
||||
} else {
|
||||
doc->setShow(TransformedView->getObject()->getNameInDocument());
|
||||
}
|
||||
doc->setShow(getTopTransformedObject()->getNameInDocument());
|
||||
}
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::hideBase()
|
||||
{
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
PartDesign::Body* pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */false);
|
||||
if (doc && pcActiveBody) {
|
||||
App::DocumentObject* prevFeature;
|
||||
if (insideMultiTransform) {
|
||||
prevFeature = pcActiveBody->getPrevSolidFeature(parentTask->TransformedView->getObject(), false);
|
||||
} else {
|
||||
prevFeature = pcActiveBody->getPrevSolidFeature(TransformedView->getObject(), false);
|
||||
}
|
||||
|
||||
doc->setHide(prevFeature->getNameInDocument());
|
||||
if (doc) {
|
||||
try {
|
||||
doc->setHide(getBaseObject()->getNameInDocument());
|
||||
} catch (const Base::Exception &) { }
|
||||
}
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::showBase()
|
||||
{
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
PartDesign::Body* pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */false);
|
||||
if (doc && pcActiveBody) {
|
||||
App::DocumentObject* prevFeature;
|
||||
if (insideMultiTransform) {
|
||||
prevFeature = pcActiveBody->getPrevSolidFeature(parentTask->TransformedView->getObject(), false);
|
||||
} else {
|
||||
prevFeature = pcActiveBody->getPrevSolidFeature(TransformedView->getObject(), false);
|
||||
}
|
||||
|
||||
doc->setShow(prevFeature->getNameInDocument());
|
||||
if (doc) {
|
||||
try {
|
||||
doc->setShow(getBaseObject()->getNameInDocument());
|
||||
} catch (const Base::Exception &) { }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -400,7 +374,7 @@ void TaskTransformedParameters::exitSelectionMode()
|
|||
|
||||
void TaskTransformedParameters::addReferenceSelectionGate(bool edge, bool face)
|
||||
{
|
||||
Gui::Selection().addSelectionGate(new ReferenceSelection(getSupportObject(), edge, face, true));
|
||||
Gui::Selection().addSelectionGate(new ReferenceSelection(getBaseObject(), edge, face, /*point =*/ true));
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
|
@ -409,10 +383,10 @@ void TaskTransformedParameters::addReferenceSelectionGate(bool edge, bool face)
|
|||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
TaskDlgTransformedParameters::TaskDlgTransformedParameters(ViewProviderTransformed *TransformedView_)
|
||||
: TaskDialog(), TransformedView(TransformedView_)
|
||||
: TaskDlgFeatureParameters(TransformedView_)
|
||||
{
|
||||
assert(TransformedView);
|
||||
message = new TaskTransformedMessages(TransformedView);
|
||||
assert(vp);
|
||||
message = new TaskTransformedMessages(getTransformedView());
|
||||
|
||||
Content.push_back(message);
|
||||
}
|
||||
|
@ -421,28 +395,22 @@ TaskDlgTransformedParameters::TaskDlgTransformedParameters(ViewProviderTransform
|
|||
|
||||
bool TaskDlgTransformedParameters::accept()
|
||||
{
|
||||
std::string name = TransformedView->getObject()->getNameInDocument();
|
||||
std::string name = vp->getObject()->getNameInDocument();
|
||||
|
||||
try {
|
||||
//Gui::Command::openCommand(featureName + " changed");
|
||||
std::vector<App::DocumentObject*> originals = parameter->getOriginals();
|
||||
std::stringstream str;
|
||||
str << "App.ActiveDocument." << name.c_str() << ".Originals = [";
|
||||
for (std::vector<App::DocumentObject*>::const_iterator it = originals.begin(); it != originals.end(); ++it)
|
||||
{
|
||||
if ((*it) != NULL)
|
||||
str << "App.ActiveDocument." << (*it)->getNameInDocument() << ",";
|
||||
}
|
||||
str << "]";
|
||||
Gui::Command::runCommand(Gui::Command::Doc,str.str().c_str());
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what()));
|
||||
return false;
|
||||
//Gui::Command::openCommand(featureName + " changed");
|
||||
std::vector<App::DocumentObject*> originals = parameter->getOriginals();
|
||||
std::stringstream str;
|
||||
str << "App.ActiveDocument." << name.c_str() << ".Originals = [";
|
||||
for (std::vector<App::DocumentObject*>::const_iterator it = originals.begin(); it != originals.end(); ++it)
|
||||
{
|
||||
if ((*it) != NULL)
|
||||
str << "App.ActiveDocument." << (*it)->getNameInDocument() << ",";
|
||||
}
|
||||
str << "]";
|
||||
Gui::Command::runCommand(Gui::Command::Doc,str.str().c_str());
|
||||
|
||||
// Continue (usually in virtual method accept())
|
||||
return true;
|
||||
return TaskDlgFeatureParameters::accept ();
|
||||
}
|
||||
|
||||
bool TaskDlgTransformedParameters::reject()
|
||||
|
@ -450,28 +418,10 @@ bool TaskDlgTransformedParameters::reject()
|
|||
// ensure that we are not in selection mode
|
||||
parameter->exitSelectionMode();
|
||||
|
||||
// roll back the done things
|
||||
Gui::Command::abortCommand();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
|
||||
|
||||
// Body housekeeping
|
||||
PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
if (activeBody != NULL) {
|
||||
// Make the new Tip and the previous solid feature visible again
|
||||
App::DocumentObject* tip = activeBody->Tip.getValue();
|
||||
App::DocumentObject* prev = activeBody->getPrevSolidFeature();
|
||||
if (tip != NULL) {
|
||||
Gui::Application::Instance->getViewProvider(tip)->show();
|
||||
if ((tip != prev) && (prev != NULL))
|
||||
Gui::Application::Instance->getViewProvider(prev)->show();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return TaskDlgFeatureParameters::reject ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "moc_TaskTransformedParameters.cpp"
|
||||
|
||||
|
||||
|
|
519
src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp.orig
Normal file
519
src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp.orig
Normal file
|
@ -0,0 +1,519 @@
|
|||
/******************************************************************************
|
||||
* 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 <QMessageBox>
|
||||
# include <QListWidget>
|
||||
# include <TopoDS_Shape.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <BRepAdaptor_Surface.hxx>
|
||||
#endif
|
||||
|
||||
#include "TaskTransformedParameters.h"
|
||||
#include "TaskMultiTransformParameters.h"
|
||||
#include "Workbench.h"
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/Part.h>
|
||||
#include <App/Origin.h>
|
||||
#include <App/Plane.h>
|
||||
#include <App/Line.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Gui/WaitCursor.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Mod/PartDesign/App/FeatureTransformed.h>
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
#include <Mod/PartDesign/App/FeatureAddSub.h>
|
||||
#include "ReferenceSelection.h"
|
||||
|
||||
using namespace PartDesignGui;
|
||||
using namespace Gui;
|
||||
|
||||
/* TRANSLATOR PartDesignGui::TaskTransformedParameters */
|
||||
|
||||
TaskTransformedParameters::TaskTransformedParameters(ViewProviderTransformed *TransformedView, QWidget *parent)
|
||||
: TaskBox(Gui::BitmapFactory().pixmap((std::string("PartDesign_") + TransformedView->featureName).c_str()),
|
||||
QString::fromLatin1((TransformedView->featureName + " parameters").c_str()),
|
||||
true,
|
||||
parent),
|
||||
TransformedView(TransformedView),
|
||||
parentTask(NULL),
|
||||
insideMultiTransform(false),
|
||||
blockUpdate(false)
|
||||
{
|
||||
selectionMode = none;
|
||||
}
|
||||
|
||||
TaskTransformedParameters::TaskTransformedParameters(TaskMultiTransformParameters *parentTask)
|
||||
: TaskBox(QPixmap(), tr(""), true, parentTask),
|
||||
TransformedView(NULL),
|
||||
parentTask(parentTask),
|
||||
insideMultiTransform(true),
|
||||
blockUpdate(false)
|
||||
{
|
||||
// Original feature selection makes no sense inside a MultiTransform
|
||||
selectionMode = none;
|
||||
}
|
||||
|
||||
TaskTransformedParameters::~TaskTransformedParameters()
|
||||
{
|
||||
// make sure to remove selection gate in all cases
|
||||
Gui::Selection().rmvSelectionGate();
|
||||
}
|
||||
|
||||
bool TaskTransformedParameters::isViewUpdated() const
|
||||
{
|
||||
return (blockUpdate == false);
|
||||
}
|
||||
|
||||
int TaskTransformedParameters::getUpdateViewTimeout() const
|
||||
{
|
||||
return 500;
|
||||
}
|
||||
|
||||
const bool TaskTransformedParameters::originalSelected(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection && (
|
||||
(selectionMode == addFeature) || (selectionMode == removeFeature))) {
|
||||
|
||||
if (strcmp(msg.pDocName, getObject()->getDocument()->getName()) != 0)
|
||||
return false;
|
||||
|
||||
PartDesign::Transformed* pcTransformed = getObject();
|
||||
App::DocumentObject* selectedObject = pcTransformed->getDocument()->getObject(msg.pObjectName);
|
||||
if (selectedObject->isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) {
|
||||
|
||||
// Do the same like in TaskDlgTransformedParameters::accept() but without doCommand
|
||||
std::vector<App::DocumentObject*> originals = pcTransformed->Originals.getValues();
|
||||
std::vector<App::DocumentObject*>::iterator o = std::find(originals.begin(), originals.end(), selectedObject);
|
||||
if (selectionMode == addFeature) {
|
||||
if (o == originals.end())
|
||||
originals.push_back(selectedObject);
|
||||
else
|
||||
return false; // duplicate selection
|
||||
} else {
|
||||
if (o != originals.end())
|
||||
originals.erase(o);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
pcTransformed->Originals.setValues(originals);
|
||||
recomputeFeature();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::onButtonAddFeature(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
hideObject();
|
||||
showBase();
|
||||
selectionMode = addFeature;
|
||||
Gui::Selection().clearSelection();
|
||||
} else {
|
||||
exitSelectionMode();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::onButtonRemoveFeature(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
hideObject();
|
||||
showBase();
|
||||
selectionMode = removeFeature;
|
||||
Gui::Selection().clearSelection();
|
||||
} else {
|
||||
exitSelectionMode();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::removeItemFromListWidget(QListWidget* widget, const char* itemstr)
|
||||
{
|
||||
QList<QListWidgetItem*> items = widget->findItems(QString::fromAscii(itemstr), Qt::MatchExactly);
|
||||
if (!items.empty()) {
|
||||
for (QList<QListWidgetItem*>::const_iterator i = items.begin(); i != items.end(); i++) {
|
||||
QListWidgetItem* it = widget->takeItem(widget->row(*i));
|
||||
delete it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
App::DocumentObject* TaskTransformedParameters::getPartPlanes(const char* str) const {
|
||||
//TODO: Adjust to GRAPH handling when available
|
||||
App::DocumentObject* obj = getObject();
|
||||
App::Part* part = getPartFor(obj, false);
|
||||
|
||||
if (part) {
|
||||
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(origs.size()<1)
|
||||
return nullptr;
|
||||
|
||||
App::Origin* orig = static_cast<App::Origin*>(origs[0]);
|
||||
auto planes = orig->getObjectsOfType(App::Plane::getClassTypeId());
|
||||
for(App::DocumentObject* plane : planes) {
|
||||
if( strcmp(static_cast<App::Plane*>(plane)->PlaneType.getValue(), str) == 0)
|
||||
return plane;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
App::DocumentObject* TaskTransformedParameters::getPartLines(const char* str) const {
|
||||
|
||||
//TODO: Adjust to GRAPH handling when available
|
||||
App::DocumentObject* obj = getObject();
|
||||
App::Part* part = getPartFor(obj, false);
|
||||
if (part) {
|
||||
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(origs.size()<1)
|
||||
return nullptr;
|
||||
|
||||
App::Origin* orig = static_cast<App::Origin*>(origs[0]);
|
||||
auto lines = orig->getObjectsOfType(App::Line::getClassTypeId());
|
||||
for(App::DocumentObject* line : lines) {
|
||||
|
||||
if( strcmp(static_cast<App::Line*>(line)->LineType.getValue(), str) == 0)
|
||||
return line;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::fillAxisCombo(ComboLinks &combolinks,
|
||||
Part::Part2DObject* sketch)
|
||||
{
|
||||
combolinks.clear();
|
||||
|
||||
//add sketch axes
|
||||
if (sketch){
|
||||
combolinks.addLink(sketch, "N_Axis",tr("Normal sketch axis"));
|
||||
combolinks.addLink(sketch,"V_Axis",tr("Vertical sketch axis"));
|
||||
combolinks.addLink(sketch,"H_Axis",tr("Horizontal sketch axis"));
|
||||
for (int i=0; i < sketch->getAxisCount(); i++) {
|
||||
QString itemText = tr("Construction line %1").arg(i+1);
|
||||
std::stringstream sub;
|
||||
sub << "Axis" << i;
|
||||
combolinks.addLink(sketch,sub.str(),itemText);
|
||||
}
|
||||
}
|
||||
|
||||
//add part axes
|
||||
App::DocumentObject* line = 0;
|
||||
line = getPartLines(App::Part::BaselineTypes[0]);
|
||||
if(line)
|
||||
combolinks.addLink(line,"",tr("Base X axis"));
|
||||
line = getPartLines(App::Part::BaselineTypes[1]);
|
||||
if(line)
|
||||
combolinks.addLink(line,"",tr("Base Y axis"));
|
||||
line = getPartLines(App::Part::BaselineTypes[2]);
|
||||
if(line)
|
||||
combolinks.addLink(line,"",tr("Base Z axis"));
|
||||
|
||||
//add "Select reference"
|
||||
combolinks.addLink(0,std::string(),tr("Select reference..."));
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::fillPlanesCombo(ComboLinks &combolinks,
|
||||
Part::Part2DObject* sketch)
|
||||
{
|
||||
combolinks.clear();
|
||||
|
||||
//add sketch axes
|
||||
if (sketch){
|
||||
combolinks.addLink(sketch,"V_Axis",QObject::tr("Vertical sketch axis"));
|
||||
combolinks.addLink(sketch,"H_Axis",QObject::tr("Horizontal sketch axis"));
|
||||
for (int i=0; i < sketch->getAxisCount(); i++) {
|
||||
QString itemText = tr("Construction line %1").arg(i+1);
|
||||
std::stringstream sub;
|
||||
sub << "Axis" << i;
|
||||
combolinks.addLink(sketch,sub.str(),itemText);
|
||||
}
|
||||
}
|
||||
|
||||
//add part baseplanes
|
||||
App::DocumentObject* plane = 0;
|
||||
plane = getPartPlanes(App::Part::BaseplaneTypes[0]);
|
||||
if(plane)
|
||||
combolinks.addLink(plane,"",tr("Base XY plane"));
|
||||
plane = getPartPlanes(App::Part::BaseplaneTypes[1]);
|
||||
if(plane)
|
||||
combolinks.addLink(plane,"",tr("Base XZ plane"));
|
||||
plane = getPartPlanes(App::Part::BaseplaneTypes[2]);
|
||||
if(plane)
|
||||
combolinks.addLink(plane,"",tr("Base YZ plane"));
|
||||
|
||||
//add "Select reference"
|
||||
combolinks.addLink(0,std::string(),tr("Select reference..."));
|
||||
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::recomputeFeature() {
|
||||
getTopTransformedView()->recomputeFeature();
|
||||
}
|
||||
|
||||
PartDesignGui::ViewProviderTransformed *TaskTransformedParameters::getTopTransformedView() const {
|
||||
PartDesignGui::ViewProviderTransformed *rv;
|
||||
|
||||
if (insideMultiTransform) {
|
||||
rv = parentTask->TransformedView;
|
||||
} else {
|
||||
rv = TransformedView;
|
||||
}
|
||||
assert (rv);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
PartDesign::Transformed *TaskTransformedParameters::getTopTransformedObject() const {
|
||||
App::DocumentObject *transform = getTopTransformedView()->getObject();
|
||||
assert (transform->isDerivedFrom(PartDesign::Transformed::getClassTypeId()));
|
||||
return static_cast<PartDesign::Transformed*>(transform);
|
||||
}
|
||||
|
||||
|
||||
PartDesign::Transformed *TaskTransformedParameters::getObject() const {
|
||||
if (insideMultiTransform)
|
||||
return parentTask->getSubFeature();
|
||||
else
|
||||
return static_cast<PartDesign::Transformed*>(TransformedView->getObject());
|
||||
}
|
||||
|
||||
Part::Feature *TaskTransformedParameters::getBaseObject() const {
|
||||
PartDesign::Feature* feature = getTopTransformedObject ();
|
||||
// NOTE: getBaseObject() throws if there is no base; shouldn't happen here.
|
||||
return feature->getBaseObject();
|
||||
}
|
||||
|
||||
const std::vector<App::DocumentObject*> & TaskTransformedParameters::getOriginals(void) const {
|
||||
return getTopTransformedObject()->Originals.getValues();
|
||||
}
|
||||
|
||||
App::DocumentObject* TaskTransformedParameters::getSketchObject() const {
|
||||
return getTopTransformedObject()->getSketchObject();
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::hideObject()
|
||||
{
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
if (doc) {
|
||||
doc->setHide(getTopTransformedObject()->getNameInDocument());
|
||||
}
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::showObject()
|
||||
{
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
if (doc) {
|
||||
doc->setShow(getTopTransformedObject()->getNameInDocument());
|
||||
}
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::hideBase()
|
||||
{
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
if (doc) {
|
||||
try {
|
||||
doc->setHide(getBaseObject()->getNameInDocument());
|
||||
} catch (const Base::Exception &) { }
|
||||
}
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::showBase()
|
||||
{
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
if (doc) {
|
||||
try {
|
||||
doc->setShow(getBaseObject()->getNameInDocument());
|
||||
} catch (const Base::Exception &) { }
|
||||
}
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::exitSelectionMode()
|
||||
{
|
||||
clearButtons();
|
||||
selectionMode = none;
|
||||
Gui::Selection().rmvSelectionGate();
|
||||
showObject();
|
||||
hideBase();
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::addReferenceSelectionGate(bool edge, bool face)
|
||||
{
|
||||
Gui::Selection().addSelectionGate(new ReferenceSelection(getBaseObject(), edge, face, /*point =*/ true));
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
//**************************************************************************
|
||||
// TaskDialog
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
TaskDlgTransformedParameters::TaskDlgTransformedParameters(ViewProviderTransformed *TransformedView_)
|
||||
: TaskDlgFeatureParameters(TransformedView_)
|
||||
{
|
||||
assert(vp);
|
||||
message = new TaskTransformedMessages(getTransformedView());
|
||||
|
||||
Content.push_back(message);
|
||||
}
|
||||
|
||||
//==== calls from the TaskView ===============================================================
|
||||
|
||||
bool TaskDlgTransformedParameters::accept()
|
||||
{
|
||||
<<<<<<< a6aea83ec9ef83d52a06178b32175b3e79f73c65
|
||||
std::string name = TransformedView->getObject()->getNameInDocument();
|
||||
|
||||
try {
|
||||
//Gui::Command::openCommand(featureName + " changed");
|
||||
std::vector<App::DocumentObject*> originals = parameter->getOriginals();
|
||||
std::stringstream str;
|
||||
str << "App.ActiveDocument." << name.c_str() << ".Originals = [";
|
||||
for (std::vector<App::DocumentObject*>::const_iterator it = originals.begin(); it != originals.end(); ++it)
|
||||
{
|
||||
if ((*it) != NULL)
|
||||
str << "App.ActiveDocument." << (*it)->getNameInDocument() << ",";
|
||||
}
|
||||
str << "]";
|
||||
Gui::Command::runCommand(Gui::Command::Doc,str.str().c_str());
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what()));
|
||||
return false;
|
||||
=======
|
||||
std::string name = vp->getObject()->getNameInDocument();
|
||||
|
||||
//Gui::Command::openCommand(featureName + " changed");
|
||||
std::vector<App::DocumentObject*> originals = parameter->getOriginals();
|
||||
std::stringstream str;
|
||||
str << "App.ActiveDocument." << name.c_str() << ".Originals = [";
|
||||
for (std::vector<App::DocumentObject*>::const_iterator it = originals.begin(); it != originals.end(); ++it)
|
||||
{
|
||||
if ((*it) != NULL)
|
||||
str << "App.ActiveDocument." << (*it)->getNameInDocument() << ",";
|
||||
>>>>>>> PartDesign: make transform parameter dialogs use common base code with other dialogs
|
||||
}
|
||||
str << "]";
|
||||
Gui::Command::runCommand(Gui::Command::Doc,str.str().c_str());
|
||||
|
||||
// Continue (usually in virtual method accept())
|
||||
return TaskDlgFeatureParameters::accept ();
|
||||
}
|
||||
|
||||
bool TaskDlgTransformedParameters::reject()
|
||||
{
|
||||
// ensure that we are not in selection mode
|
||||
parameter->exitSelectionMode();
|
||||
|
||||
return TaskDlgFeatureParameters::reject ();
|
||||
}
|
||||
|
||||
|
||||
#include "moc_TaskTransformedParameters.cpp"
|
||||
|
||||
|
||||
ComboLinks::ComboLinks(QComboBox &combo)
|
||||
: doc(0)
|
||||
{
|
||||
this->_combo = &combo;
|
||||
_combo->clear();
|
||||
}
|
||||
|
||||
int ComboLinks::addLink(const App::PropertyLinkSub &lnk, QString itemText)
|
||||
{
|
||||
if(!_combo)
|
||||
return 0;
|
||||
_combo->addItem(itemText);
|
||||
this->linksInList.push_back(new App::PropertyLinkSub());
|
||||
App::PropertyLinkSub &newitem = *(linksInList[linksInList.size()-1]);
|
||||
newitem.Paste(lnk);
|
||||
if (newitem.getValue() && this->doc == 0)
|
||||
this->doc = newitem.getValue()->getDocument();
|
||||
return linksInList.size()-1;
|
||||
}
|
||||
|
||||
int ComboLinks::addLink(App::DocumentObject *linkObj, std::string linkSubname, QString itemText)
|
||||
{
|
||||
if(!_combo)
|
||||
return 0;
|
||||
_combo->addItem(itemText);
|
||||
this->linksInList.push_back(new App::PropertyLinkSub());
|
||||
App::PropertyLinkSub &newitem = *(linksInList[linksInList.size()-1]);
|
||||
newitem.setValue(linkObj,std::vector<std::string>(1,linkSubname));
|
||||
if (newitem.getValue() && this->doc == 0)
|
||||
this->doc = newitem.getValue()->getDocument();
|
||||
return linksInList.size()-1;
|
||||
}
|
||||
|
||||
void ComboLinks::clear()
|
||||
{
|
||||
for(int i = 0 ; i < this->linksInList.size() ; i++){
|
||||
delete linksInList[i];
|
||||
}
|
||||
if(this->_combo)
|
||||
_combo->clear();
|
||||
}
|
||||
|
||||
App::PropertyLinkSub &ComboLinks::getLink(int index) const
|
||||
{
|
||||
if (index < 0 || index > linksInList.size()-1)
|
||||
throw Base::Exception("ComboLinks::getLink:Index out of range");
|
||||
if (linksInList[index]->getValue() && doc && !(doc->isIn(linksInList[index]->getValue())))
|
||||
throw Base::Exception("Linked object is not in the document; it may have been deleted");
|
||||
return *(linksInList[index]);
|
||||
}
|
||||
|
||||
App::PropertyLinkSub &ComboLinks::getCurrentLink() const
|
||||
{
|
||||
assert(_combo);
|
||||
return getLink(_combo->currentIndex());
|
||||
}
|
||||
|
||||
int ComboLinks::setCurrentLink(const App::PropertyLinkSub &lnk)
|
||||
{
|
||||
for(int i = 0 ; i < linksInList.size() ; i++) {
|
||||
App::PropertyLinkSub &it = *(linksInList[i]);
|
||||
if(lnk.getValue() == it.getValue() && lnk.getSubValues() == it.getSubValues()){
|
||||
bool wasBlocked = _combo->signalsBlocked();
|
||||
_combo->blockSignals(true);
|
||||
_combo->setCurrentIndex(i);
|
||||
_combo->blockSignals(wasBlocked);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
|
@ -30,13 +30,17 @@
|
|||
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
#include "TaskFeatureParameters.h"
|
||||
#include "TaskTransformedMessages.h"
|
||||
#include "ViewProviderTransformed.h"
|
||||
|
||||
class QListWidget;
|
||||
|
||||
namespace Part {
|
||||
class Feature;
|
||||
}
|
||||
|
||||
namespace PartDesign {
|
||||
class Transformed;
|
||||
}
|
||||
|
@ -121,9 +125,13 @@ public:
|
|||
TaskTransformedParameters(TaskMultiTransformParameters *parentTask);
|
||||
virtual ~TaskTransformedParameters();
|
||||
|
||||
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;
|
||||
/// Returns the originals property of associated top feeature object
|
||||
const std::vector<App::DocumentObject*> & getOriginals(void) const;
|
||||
|
||||
/// Get the TransformedFeature object associated with this task
|
||||
// Either through the ViewProvider or the currently active subFeature of the parentTask
|
||||
Part::Feature *getBaseObject() const;
|
||||
|
||||
/// Get the sketch object of the first original either of the object associated with this feature or with the parent feature (MultiTransform mode)
|
||||
App::DocumentObject* getSketchObject() const;
|
||||
|
||||
|
@ -132,6 +140,20 @@ public:
|
|||
virtual void apply() = 0;
|
||||
|
||||
protected Q_SLOTS:
|
||||
/**
|
||||
* Returns the base transformation view provider
|
||||
* For stand alone features it will be view provider associated with this object
|
||||
* For features inside multitransform it will be the view provider of the multitransform object
|
||||
*/
|
||||
PartDesignGui::ViewProviderTransformed *getTopTransformedView () const;
|
||||
|
||||
/**
|
||||
* Returns the base transformated object
|
||||
* For stand alone features it will be objects associated with this object
|
||||
* For features inside multitransform it will be the base multitransform object
|
||||
*/
|
||||
PartDesign::Transformed *getTopTransformedObject () const;
|
||||
|
||||
/// Connect the subTask OK button to the MultiTransform task
|
||||
virtual void onSubTaskButtonOK() {}
|
||||
void onButtonAddFeature(const bool checked);
|
||||
|
@ -139,11 +161,15 @@ protected Q_SLOTS:
|
|||
virtual void onFeatureDeleted(void)=0;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Returns the base transformation
|
||||
* For stand alone features it will be objects associated with the view provider
|
||||
* For features inside multitransform it will be the parent's multitransform object
|
||||
*/
|
||||
PartDesign::Transformed *getObject () const;
|
||||
|
||||
const bool originalSelected(const Gui::SelectionChanges& msg);
|
||||
|
||||
/// Get the TransformedFeature object associated with this task
|
||||
// Either through the ViewProvider or the currently active subFeature of the parentTask
|
||||
PartDesign::Transformed *getObject() const;
|
||||
/// Recompute either this feature or the parent feature (MultiTransform mode)
|
||||
void recomputeFeature();
|
||||
|
||||
|
@ -185,7 +211,7 @@ protected:
|
|||
};
|
||||
|
||||
/// simulation dialog for the TaskView
|
||||
class TaskDlgTransformedParameters : public Gui::TaskView::TaskDialog
|
||||
class TaskDlgTransformedParameters : public PartDesignGui::TaskDlgFeatureParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -194,29 +220,14 @@ public:
|
|||
virtual ~TaskDlgTransformedParameters() {}
|
||||
|
||||
ViewProviderTransformed* getTransformedView() const
|
||||
{ return TransformedView; }
|
||||
{ return static_cast<ViewProviderTransformed*>(vp); }
|
||||
|
||||
public:
|
||||
/// is called the TaskView when the dialog is opened
|
||||
virtual void open()
|
||||
{}
|
||||
/// is called by the framework if an button is clicked which has no accept or reject role
|
||||
virtual void clicked(int)
|
||||
{}
|
||||
/// is called by the framework if the dialog is accepted (Ok)
|
||||
virtual bool accept();
|
||||
/// is called by the framework if the dialog is rejected (Cancel)
|
||||
virtual bool reject();
|
||||
virtual bool isAllowedAlterDocument(void) const
|
||||
{ return false; }
|
||||
|
||||
/// returns for Close and Help button
|
||||
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
|
||||
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
|
||||
|
||||
protected:
|
||||
ViewProviderTransformed *TransformedView;
|
||||
|
||||
TaskTransformedParameters *parameter;
|
||||
TaskTransformedMessages *message;
|
||||
};
|
||||
|
|
247
src/Mod/PartDesign/Gui/TaskTransformedParameters.h.orig
Normal file
247
src/Mod/PartDesign/Gui/TaskTransformedParameters.h.orig
Normal file
|
@ -0,0 +1,247 @@
|
|||
/******************************************************************************
|
||||
* 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 GUI_TASKVIEW_TaskTransformedParameters_H
|
||||
#define GUI_TASKVIEW_TaskTransformedParameters_H
|
||||
|
||||
#include <QComboBox>
|
||||
|
||||
#include <Mod/Part/App/Part2DObject.h>
|
||||
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/Selection.h>
|
||||
|
||||
#include "TaskFeatureParameters.h"
|
||||
#include "TaskTransformedMessages.h"
|
||||
#include "ViewProviderTransformed.h"
|
||||
|
||||
class QListWidget;
|
||||
|
||||
namespace Part {
|
||||
class Feature;
|
||||
}
|
||||
|
||||
namespace PartDesign {
|
||||
class Transformed;
|
||||
}
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
class TaskMultiTransformParameters;
|
||||
|
||||
/**
|
||||
* @brief The ComboLinks class is a helper class that binds to a combo box and
|
||||
* provides an interface to add links, retrieve links and select items by link
|
||||
* value
|
||||
*/
|
||||
class ComboLinks
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief ComboLinks constructor.
|
||||
* @param combo. It will be cleared as soon as it is bound. Don't add or
|
||||
* remove items from the combo directly, otherwise internal tracking list
|
||||
* will go out of sync, and crashes may result.
|
||||
*/
|
||||
ComboLinks(QComboBox &combo);
|
||||
ComboLinks() {_combo = 0; doc = 0;};
|
||||
void setCombo(QComboBox &combo) {assert(_combo == 0); this->_combo = &combo; _combo->clear();}
|
||||
|
||||
/**
|
||||
* @brief addLink adds an item to the combo. Doesn't check for duplicates.
|
||||
* @param lnk can be a link to NULL, which is usually used for special item "Select Reference"
|
||||
* @param itemText
|
||||
* @return
|
||||
*/
|
||||
int addLink(const App::PropertyLinkSub &lnk, QString itemText);
|
||||
int addLink(App::DocumentObject* linkObj, std::string linkSubname, QString itemText);
|
||||
void clear();
|
||||
App::PropertyLinkSub& getLink(int index) const;
|
||||
|
||||
/**
|
||||
* @brief getCurrentLink
|
||||
* @return the link corresponding to the selected item. May be null link,
|
||||
* which is usually used to indicate a "Select reference..." special item.
|
||||
* Otherwise, the link is automatically tested for validity (oif an object
|
||||
* doesn't exist in the document, an exception will be thrown.)
|
||||
*/
|
||||
App::PropertyLinkSub& getCurrentLink() const;
|
||||
|
||||
/**
|
||||
* @brief setCurrentLink selects the item with the link that matches the
|
||||
* argument. If there is no such link in the list, -1 is returned and
|
||||
* selected item is not changed. Signals from combo are blocked in this
|
||||
* function.
|
||||
* @param lnk
|
||||
* @return the index of an item that was selected, -1 if link is not in the list yet.
|
||||
*/
|
||||
int setCurrentLink(const App::PropertyLinkSub &lnk);
|
||||
|
||||
QComboBox& combo(void) const {assert(_combo); return *_combo;};
|
||||
|
||||
~ComboLinks() {_combo = 0; clear();};
|
||||
private:
|
||||
QComboBox* _combo;
|
||||
App::Document* doc;
|
||||
std::vector<App::PropertyLinkSub*> linksInList;
|
||||
};
|
||||
|
||||
/**
|
||||
The transformed subclasses will be used in two different modes:
|
||||
1. As a stand-alone feature
|
||||
2. As a container that stores transformation info for a MultiTransform feature. In this case
|
||||
the flag insideMultiTransform is set to true.
|
||||
Because in the second case there is no ViewProvider, some special methods are required to
|
||||
access the underlying FeatureTransformed object in two different ways.
|
||||
**/
|
||||
class TaskTransformedParameters : public Gui::TaskView::TaskBox, public Gui::SelectionObserver
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/// Constructor for task with ViewProvider
|
||||
TaskTransformedParameters(ViewProviderTransformed *TransformedView, QWidget *parent = 0);
|
||||
/// Constructor for task with parent task (MultiTransform mode)
|
||||
TaskTransformedParameters(TaskMultiTransformParameters *parentTask);
|
||||
virtual ~TaskTransformedParameters();
|
||||
|
||||
/// Returns the originals property of associated top feeature object
|
||||
const std::vector<App::DocumentObject*> & getOriginals(void) const;
|
||||
|
||||
/// Get the TransformedFeature object associated with this task
|
||||
// Either through the ViewProvider or the currently active subFeature of the parentTask
|
||||
Part::Feature *getBaseObject() const;
|
||||
|
||||
/// Get the sketch object of the first original either of the object associated with this feature or with the parent feature (MultiTransform mode)
|
||||
App::DocumentObject* getSketchObject() const;
|
||||
|
||||
void exitSelectionMode();
|
||||
|
||||
virtual void apply() = 0;
|
||||
|
||||
protected Q_SLOTS:
|
||||
/**
|
||||
* Returns the base transformation view provider
|
||||
* For stand alone features it will be view provider associated with this object
|
||||
* For features inside multitransform it will be the view provider of the multitransform object
|
||||
*/
|
||||
PartDesignGui::ViewProviderTransformed *getTopTransformedView () const;
|
||||
|
||||
/**
|
||||
* Returns the base transformated object
|
||||
* For stand alone features it will be objects associated with this object
|
||||
* For features inside multitransform it will be the base multitransform object
|
||||
*/
|
||||
PartDesign::Transformed *getTopTransformedObject () const;
|
||||
|
||||
/// Connect the subTask OK button to the MultiTransform task
|
||||
virtual void onSubTaskButtonOK() {}
|
||||
void onButtonAddFeature(const bool checked);
|
||||
void onButtonRemoveFeature(const bool checked);
|
||||
virtual void onFeatureDeleted(void)=0;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Returns the base transformation
|
||||
* For stand alone features it will be objects associated with the view provider
|
||||
* For features inside multitransform it will be the parent's multitransform object
|
||||
*/
|
||||
PartDesign::Transformed *getObject () const;
|
||||
|
||||
const bool originalSelected(const Gui::SelectionChanges& msg);
|
||||
|
||||
/// Recompute either this feature or the parent feature (MultiTransform mode)
|
||||
void recomputeFeature();
|
||||
|
||||
void hideObject();
|
||||
void showObject();
|
||||
void hideBase();
|
||||
void showBase();
|
||||
|
||||
void addReferenceSelectionGate(bool edge, bool face);
|
||||
|
||||
bool isViewUpdated() const;
|
||||
int getUpdateViewTimeout() const;
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *e) = 0;
|
||||
virtual void onSelectionChanged(const Gui::SelectionChanges& msg) = 0;
|
||||
virtual void clearButtons()=0;
|
||||
static void removeItemFromListWidget(QListWidget* widget, const char* itemstr);
|
||||
|
||||
App::DocumentObject* getPartPlanes(const char* str) const;
|
||||
App::DocumentObject* getPartLines(const char* str) const;
|
||||
|
||||
void fillAxisCombo(ComboLinks &combolinks, Part::Part2DObject *sketch);
|
||||
void fillPlanesCombo(ComboLinks &combolinks, Part2DObject *sketch);
|
||||
|
||||
protected:
|
||||
QWidget* proxy;
|
||||
ViewProviderTransformed *TransformedView;
|
||||
|
||||
enum selectionModes { none, addFeature, removeFeature, reference };
|
||||
selectionModes selectionMode;
|
||||
|
||||
/// The MultiTransform parent task of this task
|
||||
TaskMultiTransformParameters* parentTask;
|
||||
/// Flag indicating whether this object is a container for MultiTransform
|
||||
bool insideMultiTransform;
|
||||
/// Lock updateUI(), applying changes to the underlying feature and calling recomputeFeature()
|
||||
bool blockUpdate;
|
||||
};
|
||||
|
||||
/// simulation dialog for the TaskView
|
||||
class TaskDlgTransformedParameters : public PartDesignGui::TaskDlgFeatureParameters
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskDlgTransformedParameters(ViewProviderTransformed *TransformedView);
|
||||
virtual ~TaskDlgTransformedParameters() {}
|
||||
|
||||
ViewProviderTransformed* getTransformedView() const
|
||||
{ return static_cast<ViewProviderTransformed*>(vp); }
|
||||
|
||||
public:
|
||||
/// is called by the framework if the dialog is accepted (Ok)
|
||||
virtual bool accept();
|
||||
/// is called by the framework if the dialog is rejected (Cancel)
|
||||
virtual bool reject();
|
||||
<<<<<<< a6aea83ec9ef83d52a06178b32175b3e79f73c65
|
||||
virtual bool isAllowedAlterDocument(void) const
|
||||
{ return false; }
|
||||
|
||||
/// returns for Close and Help button
|
||||
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
|
||||
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
|
||||
|
||||
=======
|
||||
>>>>>>> PartDesign: make transform parameter dialogs use common base code with other dialogs
|
||||
protected:
|
||||
TaskTransformedParameters *parameter;
|
||||
TaskTransformedMessages *message;
|
||||
};
|
||||
|
||||
} //namespace PartDesignGui
|
||||
|
||||
#endif // GUI_TASKVIEW_TASKAPPERANCE_H
|
Loading…
Reference in New Issue
Block a user