+ fixes #0001735: Ellipsoids visibility problems

This commit is contained in:
wmayer 2014-10-16 19:36:54 +02:00
parent 84bd9a4a88
commit dd392efeb1
4 changed files with 39 additions and 102 deletions

View File

@ -1132,59 +1132,3 @@ void ViewProviderPartBase::showControlPointsOfFace(const TopoDS_Face& face)
pcControlPoints->addChild(nodes); pcControlPoints->addChild(nodes);
} }
// ----------------------------------------------------------------------------
PROPERTY_SOURCE(PartGui::ViewProviderEllipsoid, PartGui::ViewProviderPartBase)
ViewProviderEllipsoid::ViewProviderEllipsoid()
{
pSphere = new SoSphere();
pSphere->ref();
pScaling = new SoScale();
pScaling->ref();
sPixmap = "Tree_Part_Ellipsoid_Parametric.svg";
}
ViewProviderEllipsoid::~ViewProviderEllipsoid()
{
pSphere->unref();
pScaling->unref();
}
void ViewProviderEllipsoid::updateData(const App::Property* prop)
{
if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId()) {
const TopoDS_Shape& cShape = static_cast<const Part::PropertyPartShape*>(prop)->getValue();
// clear anchor nodes
//vertexShapeMap.clear();
EdgeRoot->removeAllChildren();
FaceRoot->removeAllChildren();
VertexRoot->removeAllChildren();
// do nothing if shape is empty
if (cShape.IsNull())
return;
App::DocumentObject* object = this->getObject();
if (object && object->isDerivedFrom(Part::Ellipsoid::getClassTypeId())) {
double angle1 = static_cast<Part::Ellipsoid*>(object)->Angle1.getValue();
double angle2 = static_cast<Part::Ellipsoid*>(object)->Angle2.getValue();
double angle3 = static_cast<Part::Ellipsoid*>(object)->Angle3.getValue();
float radius1 = static_cast<Part::Ellipsoid*>(object)->Radius1.getValue();
float radius2 = static_cast<Part::Ellipsoid*>(object)->Radius2.getValue();
if (angle1 == -90.0 && angle2 == 90.0 && angle3 == 360.0) {
float scale = radius1/radius2;
pScaling->scaleFactor.setValue(1,1,scale);
pSphere->radius.setValue(radius2);
FaceRoot->addChild(pScaling);
FaceRoot->addChild(pSphere);
return; // ok, done
}
}
// if not a full ellipsoid do it the general way
ViewProviderPartBase::updateData(prop);
}
else {
Gui::ViewProviderGeometryObject::updateData(prop);
}
}

View File

@ -131,23 +131,6 @@ private:
std::map<SoVertexShape*, TopoDS_Shape> vertexShapeMap; std::map<SoVertexShape*, TopoDS_Shape> vertexShapeMap;
}; };
class PartGuiExport ViewProviderEllipsoid : public ViewProviderPartBase
{
PROPERTY_HEADER(PartGui::ViewProviderEllipsoid);
public:
/// constructor
ViewProviderEllipsoid();
/// destructor
virtual ~ViewProviderEllipsoid();
void updateData(const App::Property*);
private:
SoSphere* pSphere;
SoScale * pScaling;
};
#if defined(FC_USE_FAST_SHAPE_RENDERING) #if defined(FC_USE_FAST_SHAPE_RENDERING)
class PartGuiExport ViewProviderPart : public ViewProviderPartExt class PartGuiExport ViewProviderPart : public ViewProviderPartExt
{ {

View File

@ -26,18 +26,9 @@
#ifndef _PreComp_ #ifndef _PreComp_
#endif #endif
/// Here the FreeCAD includes sorted by Base,App,Gui......
#include <Base/Parameter.h>
#include "ViewProviderSphereParametric.h" #include "ViewProviderSphereParametric.h"
//#include "Tree.h"
using namespace PartGui; using namespace PartGui;
using namespace std;
//************************************************************************** //**************************************************************************
@ -45,7 +36,6 @@ using namespace std;
PROPERTY_SOURCE(PartGui::ViewProviderSphereParametric, PartGui::ViewProviderPart) PROPERTY_SOURCE(PartGui::ViewProviderSphereParametric, PartGui::ViewProviderPart)
ViewProviderSphereParametric::ViewProviderSphereParametric() ViewProviderSphereParametric::ViewProviderSphereParametric()
{ {
sPixmap = "Tree_Part_Sphere_Parametric.svg"; sPixmap = "Tree_Part_Sphere_Parametric.svg";
@ -56,13 +46,34 @@ ViewProviderSphereParametric::~ViewProviderSphereParametric()
} }
// **********************************************************************************
std::vector<std::string> ViewProviderSphereParametric::getDisplayModes(void) const std::vector<std::string> ViewProviderSphereParametric::getDisplayModes(void) const
{ {
// get the modes of the father std::vector<std::string> StrList;
// add your own modes
StrList.push_back("Flat Lines");
StrList.push_back("Shaded");
StrList.push_back("Wireframe");
StrList.push_back("Points");
return StrList;
}
// ----------------------------------------------------------------------------
PROPERTY_SOURCE(PartGui::ViewProviderEllipsoid, PartGui::ViewProviderPart)
ViewProviderEllipsoid::ViewProviderEllipsoid()
{
sPixmap = "Tree_Part_Ellipsoid_Parametric.svg";
}
ViewProviderEllipsoid::~ViewProviderEllipsoid()
{
}
std::vector<std::string> ViewProviderEllipsoid::getDisplayModes(void) const
{
std::vector<std::string> StrList; std::vector<std::string> StrList;
// add your own modes // add your own modes

View File

@ -26,22 +26,9 @@
#include "ViewProvider.h" #include "ViewProvider.h"
class TopoDS_Shape;
class TopoDS_Face;
class SoSeparator;
class SbVec3f;
class SoTransform;
namespace Gui {
class View3DInventorViewer;
class SoFCSelection;
}
namespace PartGui { namespace PartGui {
class PartGuiExport ViewProviderSphereParametric : public ViewProviderPart
class PartGuiExport ViewProviderSphereParametric:public ViewProviderPart
{ {
PROPERTY_HEADER(PartGui::ViewProviderSphereParametric); PROPERTY_HEADER(PartGui::ViewProviderSphereParametric);
@ -57,6 +44,18 @@ protected:
}; };
class PartGuiExport ViewProviderEllipsoid : public ViewProviderPart
{
PROPERTY_HEADER(PartGui::ViewProviderEllipsoid);
public:
/// constructor
ViewProviderEllipsoid();
/// destructor
virtual ~ViewProviderEllipsoid();
std::vector<std::string> getDisplayModes(void) const;
};
} // namespace PartGui } // namespace PartGui