Some fixes in Body visualls (ongoing)
This commit is contained in:
parent
50652895d4
commit
aa216ee69d
|
@ -48,6 +48,7 @@ public:
|
|||
|
||||
virtual bool doubleClicked(void);
|
||||
private:
|
||||
/// group node for all children collected through claimChildren3D(), reused by all Assembly ViewProviders
|
||||
SoGroup *pcChildren;
|
||||
|
||||
};
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <Base/Placement.h>
|
||||
|
||||
#include "Feature.h"
|
||||
#include "Body.h"
|
||||
#include "BodyPy.h"
|
||||
|
||||
|
@ -52,7 +53,23 @@ short Body::mustExecute() const
|
|||
|
||||
App::DocumentObjectExecReturn *Body::execute(void)
|
||||
{
|
||||
|
||||
// TODO right selection for Body
|
||||
App::DocumentObject* link = Tip.getValue();
|
||||
if (!link)
|
||||
//return new App::DocumentObjectExecReturn("No object!");
|
||||
return App::DocumentObject::StdReturn;
|
||||
if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return new App::DocumentObjectExecReturn("Linked object is not a PartDesign object");
|
||||
//return App::DocumentObject::StdReturn;
|
||||
// get the shape of the tip
|
||||
const Part::TopoShape& TipShape = static_cast<Part::Feature*>(link)->Shape.getShape();
|
||||
if (TipShape._Shape.IsNull())
|
||||
//return new App::DocumentObjectExecReturn("empty shape");
|
||||
return App::DocumentObject::StdReturn;
|
||||
|
||||
Shape.setValue(TipShape);
|
||||
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,21 +75,22 @@ void validateSketches(std::vector<App::DocumentObject*>& sketches, const bool su
|
|||
std::vector<App::DocumentObject*>::iterator s = sketches.begin();
|
||||
|
||||
while (s != sketches.end()) {
|
||||
// Check whether this sketch is already being used by another feature
|
||||
std::vector<App::DocumentObject*> ref = (*s)->getInList();
|
||||
std::vector<App::DocumentObject*>::iterator r = ref.begin();
|
||||
while (r != ref.end()) {
|
||||
if (!(*r)->getTypeId().isDerivedFrom(PartDesign::SketchBased().getClassTypeId())) {
|
||||
r = ref.erase(r);
|
||||
continue;
|
||||
}
|
||||
++r;
|
||||
}
|
||||
if (!ref.empty()) {
|
||||
// TODO: Display some information message that this sketch was removed?
|
||||
s = sketches.erase(s);
|
||||
continue;
|
||||
}
|
||||
// sketch is allways part of the body first.
|
||||
//// Check whether this sketch is already being used by another feature
|
||||
//std::vector<App::DocumentObject*> ref = (*s)->getInList();
|
||||
//std::vector<App::DocumentObject*>::iterator r = ref.begin();
|
||||
//while (r != ref.end()) {
|
||||
// if (!(*r)->getTypeId().isDerivedFrom(PartDesign::SketchBased().getClassTypeId())) {
|
||||
// r = ref.erase(r);
|
||||
// continue;
|
||||
// }
|
||||
// ++r;
|
||||
//}
|
||||
//if (!ref.empty()) {
|
||||
// // TODO: Display some information message that this sketch was removed?
|
||||
// s = sketches.erase(s);
|
||||
// continue;
|
||||
//}
|
||||
|
||||
// Check whether the sketch shape is valid
|
||||
Part::Part2DObject* sketch = static_cast<Part::Part2DObject*>(*s);
|
||||
|
|
|
@ -41,15 +41,56 @@ ViewProviderBody::ViewProviderBody()
|
|||
{
|
||||
pcBodyChildren = new SoGroup();
|
||||
pcBodyChildren->ref();
|
||||
|
||||
pcBodyTip = new SoGroup();
|
||||
pcBodyTip->ref();
|
||||
}
|
||||
|
||||
ViewProviderBody::~ViewProviderBody()
|
||||
{
|
||||
pcBodyChildren->unref();
|
||||
pcBodyChildren = 0;
|
||||
pcBodyTip->unref();
|
||||
pcBodyTip = 0;
|
||||
}
|
||||
|
||||
|
||||
void ViewProviderBody::attach(App::DocumentObject *pcFeat)
|
||||
{
|
||||
// call parent attach method
|
||||
ViewProviderPart::attach(pcFeat);
|
||||
|
||||
|
||||
// putting all together with the switch
|
||||
addDisplayMaskMode(pcBodyTip, "Body");
|
||||
addDisplayMaskMode(pcBodyChildren, "Through");
|
||||
}
|
||||
|
||||
void ViewProviderBody::setDisplayMode(const char* ModeName)
|
||||
{
|
||||
if ( strcmp("Body",ModeName)==0 )
|
||||
setDisplayMaskMode("Body");
|
||||
if ( strcmp("Main",ModeName)==0 )
|
||||
setDisplayMaskMode("Main");
|
||||
if ( strcmp("Through",ModeName)==0 )
|
||||
setDisplayMaskMode("Through");
|
||||
|
||||
ViewProviderGeometryObject::setDisplayMode( ModeName );
|
||||
}
|
||||
|
||||
std::vector<std::string> ViewProviderBody::getDisplayModes(void) const
|
||||
{
|
||||
// get the modes of the father
|
||||
std::vector<std::string> StrList = ViewProviderGeometryObject::getDisplayModes();
|
||||
|
||||
// add your own modes
|
||||
StrList.push_back("Through");
|
||||
StrList.push_back("Body");
|
||||
|
||||
return StrList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool ViewProviderBody::doubleClicked(void)
|
||||
{
|
||||
// assure the PartDesign workbench
|
||||
|
|
|
@ -29,6 +29,12 @@
|
|||
|
||||
namespace PartDesignGui {
|
||||
|
||||
/** ViewProvider of the Body feature
|
||||
* This class manage the visual apperance of the features in the
|
||||
* Body feature. That mean while editing only the tip feature is
|
||||
* visible. If the Body is not active it shows only the result shape (tip).
|
||||
* \author jriegel
|
||||
*/
|
||||
class PartDesignGuiExport ViewProviderBody : public PartGui::ViewProviderPart
|
||||
{
|
||||
PROPERTY_HEADER(PartGui::ViewProviderBody);
|
||||
|
@ -38,6 +44,11 @@ public:
|
|||
ViewProviderBody();
|
||||
/// destructor
|
||||
virtual ~ViewProviderBody();
|
||||
|
||||
virtual void attach(App::DocumentObject *);
|
||||
virtual void setDisplayMode(const char* ModeName);
|
||||
/// returns a list of all possible modes
|
||||
virtual std::vector<std::string> getDisplayModes(void) const;
|
||||
|
||||
virtual bool doubleClicked(void);
|
||||
std::vector<App::DocumentObject*> claimChildren(void)const;
|
||||
|
@ -47,7 +58,10 @@ public:
|
|||
std::vector<App::DocumentObject*> claimChildren3D(void)const;
|
||||
|
||||
private:
|
||||
/// group used to store children collected by claimChildren3D()
|
||||
SoGroup *pcBodyChildren;
|
||||
/// group used to show the tip element in "edit" mode
|
||||
SoGroup *pcBodyTip;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user