Skip to content

Commit

Permalink
Attacher: make Placement read-only when attached
Browse files Browse the repository at this point in the history
Read-onlyness of Placement and superPlacement properties is now
dynamically controlled by MapMode property value.
  • Loading branch information
DeepSOIC authored and wwmayer committed May 7, 2016
1 parent ebd5414 commit b3e9c6b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Mod/Part/App/AttachableObject.cpp
Expand Up @@ -28,6 +28,7 @@
#include "AttachableObject.h"

#include <Base/Console.h>
#include <App/Application.h>



Expand Down Expand Up @@ -95,6 +96,14 @@ App::DocumentObjectExecReturn *AttachableObject::execute()
return Part::Feature::execute();
}

void setReadonlyness(App::Property &prop, bool on)
{
unsigned long status = prop.getStatus();
prop.setStatus(App::Property::ReadOnly, on);
if (status != prop.getStatus())
App::GetApplication().signalChangePropertyEditor(prop);
}

void AttachableObject::onChanged(const App::Property* prop)
{
if(! this->isRestoring()){
Expand All @@ -103,8 +112,14 @@ void AttachableObject::onChanged(const App::Property* prop)
|| prop == &MapMode
|| prop == &MapPathParameter
|| prop == &MapReversed
|| prop == &superPlacement))
|| prop == &superPlacement)){

eMapMode mmode = eMapMode(this->MapMode.getValue());
setReadonlyness(this->superPlacement, mmode == mmDeactivated);
setReadonlyness(this->Placement, mmode != mmDeactivated && mmode != mmTranslate);

positionBySupport();
}
} catch (Base::Exception &e) {
this->setError();
Base::Console().Error("PositionBySupport: %s",e.what());
Expand Down

0 comments on commit b3e9c6b

Please sign in to comment.