Skip to content

Commit

Permalink
+ fixes #1735: Ellipsoids visibility problems
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Oct 16, 2014
1 parent 84bd9a4 commit dd392ef
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 100 deletions.
56 changes: 0 additions & 56 deletions src/Mod/Part/Gui/ViewProvider.cpp
Expand Up @@ -1132,59 +1132,3 @@ void ViewProviderPartBase::showControlPointsOfFace(const TopoDS_Face& face)

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);
}
}
17 changes: 0 additions & 17 deletions src/Mod/Part/Gui/ViewProvider.h
Expand Up @@ -131,23 +131,6 @@ class PartGuiExport ViewProviderPartBase : public Gui::ViewProviderGeometryObjec
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)
class PartGuiExport ViewProviderPart : public ViewProviderPartExt
{
Expand Down
37 changes: 24 additions & 13 deletions src/Mod/Part/Gui/ViewProviderSphereParametric.cpp
Expand Up @@ -26,26 +26,16 @@
#ifndef _PreComp_
#endif

/// Here the FreeCAD includes sorted by Base,App,Gui......
#include <Base/Parameter.h>

#include "ViewProviderSphereParametric.h"


//#include "Tree.h"



using namespace PartGui;
using namespace std;


//**************************************************************************
// Construction/Destruction

PROPERTY_SOURCE(PartGui::ViewProviderSphereParametric, PartGui::ViewProviderPart)


ViewProviderSphereParametric::ViewProviderSphereParametric()
{
sPixmap = "Tree_Part_Sphere_Parametric.svg";
Expand All @@ -56,13 +46,34 @@ ViewProviderSphereParametric::~ViewProviderSphereParametric()

}

std::vector<std::string> ViewProviderSphereParametric::getDisplayModes(void) const
{
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";
}

std::vector<std::string> ViewProviderSphereParametric::getDisplayModes(void) const
ViewProviderEllipsoid::~ViewProviderEllipsoid()
{
}

std::vector<std::string> ViewProviderEllipsoid::getDisplayModes(void) const
{
// get the modes of the father
std::vector<std::string> StrList;

// add your own modes
Expand Down
27 changes: 13 additions & 14 deletions src/Mod/Part/Gui/ViewProviderSphereParametric.h
Expand Up @@ -26,22 +26,9 @@

#include "ViewProvider.h"


class TopoDS_Shape;
class TopoDS_Face;
class SoSeparator;
class SbVec3f;
class SoTransform;

namespace Gui {
class View3DInventorViewer;
class SoFCSelection;
}

namespace PartGui {


class PartGuiExport ViewProviderSphereParametric:public ViewProviderPart
class PartGuiExport ViewProviderSphereParametric : public ViewProviderPart
{
PROPERTY_HEADER(PartGui::ViewProviderSphereParametric);

Expand All @@ -57,6 +44,18 @@ class PartGuiExport ViewProviderSphereParametric:public ViewProviderPart

};

class PartGuiExport ViewProviderEllipsoid : public ViewProviderPart
{
PROPERTY_HEADER(PartGui::ViewProviderEllipsoid);

public:
/// constructor
ViewProviderEllipsoid();
/// destructor
virtual ~ViewProviderEllipsoid();
std::vector<std::string> getDisplayModes(void) const;
};

} // namespace PartGui


Expand Down

0 comments on commit dd392ef

Please sign in to comment.