implementing Plane visual

This commit is contained in:
jriegel
2012-01-28 22:37:34 +01:00
committed by Stefan Tröger
parent ed5a055444
commit 4f0f3e8c94
6 changed files with 21 additions and 83 deletions

View File

@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2012 *
* Copyright (c) Juergen Riegel (juergen.riegel@web.de) 2012 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
@@ -62,15 +62,15 @@ using namespace Gui;
PROPERTY_SOURCE(Gui::ViewProviderPlacement, Gui::ViewProviderGeometryObject)
ViewProviderPlacement::ViewProviderPlacement()
ViewProviderPlacement::ViewProviderPlacement()
{
pMat = new SoMaterial();
pMat->ref();
const float dist = 2;
const float size = 6;
const float pSize = 4;
const float pSize = 4;
static const SbVec3f verts[13] =
{
@@ -161,73 +161,12 @@ void ViewProviderPlacement::attach(App::DocumentObject* pcObject)
lineSep->addChild(pMat);
lineSep->addChild(pCoords);
lineSep->addChild(pLines);
// Making the whole measurement object selectable by 3d view can
// become cumbersome since it has influence to any raypick action.
// Thus, it's only selectable by its text label
//SoFCSelection* textsep = new SoFCSelection();
//textsep->objectName = pcObject->getNameInDocument();
//textsep->documentName = pcObject->getDocument()->getName();
//textsep->subElementName = "Main";
////SoSeparator* textsep = new SoSeparator();
//textsep->addChild(pTranslation);
//textsep->addChild(pTextColor);
//textsep->addChild(pFont);
//textsep->addChild(pLabel);
//SoSeparator* sep = new SoSeparator();
//sep->addChild(lineSep);
//sep->addChild(textsep);
addDisplayMaskMode(lineSep, "Base");
}
void ViewProviderPlacement::updateData(const App::Property* prop)
{
//if (prop->getTypeId() == App::PropertyVector::getClassTypeId() ||
// prop == &Mirror || prop == &DistFactor) {
// if (strcmp(prop->getName(),"P1") == 0) {
// Base::Vector3f v = static_cast<const App::PropertyVector*>(prop)->getValue();
// pCoords->point.set1Value(0, SbVec3f(v.x,v.y,v.z));
// }
// else if (strcmp(prop->getName(),"P2") == 0) {
// Base::Vector3f v = static_cast<const App::PropertyVector*>(prop)->getValue();
// pCoords->point.set1Value(1, SbVec3f(v.x,v.y,v.z));
// }
// SbVec3f pt1 = pCoords->point[0];
// SbVec3f pt2 = pCoords->point[1];
// SbVec3f dif = pt1-pt2;
// float length = fabs(dif.length())*DistFactor.getValue();
// if (Mirror.getValue())
// length = -length;
// if (dif.sqrLength() < 10.0e-6f) {
// pCoords->point.set1Value(2, pt1+SbVec3f(0.0f,0.0f,length));
// pCoords->point.set1Value(3, pt2+SbVec3f(0.0f,0.0f,length));
// }
// else {
// SbVec3f dir = dif.cross(SbVec3f(1.0f,0.0f,0.0f));
// if (dir.sqrLength() < 10.0e-6f)
// dir = dif.cross(SbVec3f(0.0f,1.0f,0.0f));
// if (dir.sqrLength() < 10.0e-6f)
// dir = dif.cross(SbVec3f(0.0f,0.0f,1.0f));
// dir.normalize();
// if (dir.dot(SbVec3f(0.0f,0.0f,1.0f)) < 0.0f)
// length = -length;
// pCoords->point.set1Value(2, pt1 + length*dir);
// pCoords->point.set1Value(3, pt2 + length*dir);
// }
// SbVec3f pos = (pCoords->point[2]+pCoords->point[3])/2.0f;
// pTranslation->translation.setValue(pos);
// std::stringstream s;
// s.precision(3);
// s.setf(std::ios::fixed | std::ios::showpoint);
// s << dif.length();
// pLabel->string.setValue(s.str().c_str());
//}
ViewProviderGeometryObject::updateData(prop);
}
@@ -255,7 +194,7 @@ std::string ViewProviderPlacement::getElement(const SoDetail* detail) const
SoDetail* ViewProviderPlacement::getDetail(const char* subelement) const
{
SoLineDetail* detail = 0;
std::string subelem(subelement);
std::string subelem(subelement);
int edge = -1;
if(subelem == "X-Axis") edge = 0;
@@ -274,7 +213,7 @@ SoDetail* ViewProviderPlacement::getDetail(const char* subelement) const
return detail;
}
bool ViewProviderPlacement::isSelectable(void) const
bool ViewProviderPlacement::isSelectable(void) const
{
return true;
}