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) 2002 *
* Copyright (c) Juergen Riegel (juergen.riegel@web.de) 2002 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
@ -45,7 +45,7 @@ GeoFeature::GeoFeature(void)
GeoFeature::~GeoFeature(void)
{
}
}
void GeoFeature::transformPlacement(const Base::Placement &transform)
{

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
* Copyright (c) Juergen Riegel (juergen.riegel@web.de) 2002 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
@ -52,4 +52,4 @@ public:
} //namespace App
#endif // APP_GEOFEATURE_H
#endif // APP_GEOFEATURE_H

View File

@ -96,7 +96,7 @@ SoAutoZoomTranslation::SoAutoZoomTranslation()
void SoAutoZoomTranslation::GLRender(SoGLRenderAction * action)
{
Base::Console().Log("Draw\n");
//Base::Console().Log("Draw\n");
SoAutoZoomTranslation::doAction((SoAction *)action);
inherited::GLRender(action);
}
@ -107,7 +107,7 @@ void SoAutoZoomTranslation::doAction(SoAction * action)
float sf = this->getScaleFactor(action);
SoModelMatrixElement::scaleBy(action->getState(), this,
SbVec3f(sf,sf,sf));
Base::Console().Log("Scale: %f\n",sf);
//Base::Console().Log("Scale: %f\n",sf);
}
// set the auto scale factor.
@ -123,7 +123,7 @@ void SoAutoZoomTranslation::doAction(SoAction * action)
void SoAutoZoomTranslation::getMatrix(SoGetMatrixAction * action)
{
Base::Console().Log("Matrix\n");
//Base::Console().Log("Matrix\n");
float sf = this->getScaleFactor(action);
SbVec3f scalevec = SbVec3f(sf,sf,sf);
@ -138,25 +138,25 @@ void SoAutoZoomTranslation::getMatrix(SoGetMatrixAction * action)
void SoAutoZoomTranslation::callback(SoCallbackAction * action)
{
Base::Console().Log("callback\n");
// Base::Console().Log("callback\n");
SoAutoZoomTranslation::doAction((SoAction*)action);
}
void SoAutoZoomTranslation::getBoundingBox(SoGetBoundingBoxAction * action)
{
Base::Console().Log("getBoundingBox\n");
//Base::Console().Log("getBoundingBox\n");
SoAutoZoomTranslation::doAction((SoAction*)action);
}
void SoAutoZoomTranslation::pick(SoPickAction * action)
{
Base::Console().Log("pick\n");
//Base::Console().Log("pick\n");
SoAutoZoomTranslation::doAction((SoAction*)action);
}
// Doc in superclass.
void SoAutoZoomTranslation::getPrimitiveCount(SoGetPrimitiveCountAction * action)
{
Base::Console().Log("getPrimitiveCount\n");
//Base::Console().Log("getPrimitiveCount\n");
SoAutoZoomTranslation::doAction((SoAction*)action);
}

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;
}

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. *
* *
@ -54,7 +54,7 @@ public:
std::vector<std::string> getDisplayModes(void) const;
void setDisplayMode(const char* ModeName);
/// indicates if the ViewProvider use the new Selection model
/// indicates if the ViewProvider use the new Selection model
virtual bool useNewSelectionModel(void) const {return true;}
/// indicates if the ViewProvider can be selected
virtual bool isSelectable(void) const ;
@ -62,8 +62,6 @@ public:
virtual std::string getElement(const SoDetail *) const;
virtual SoDetail* getDetail(const char*) const;
static void measureDistanceCallback(void * ud, SoEventCallback * n);
protected:
void onChanged(const App::Property* prop);

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. *
* *
@ -44,6 +44,7 @@
#include <Inventor/nodes/SoAnnotation.h>
#include <Inventor/details/SoLineDetail.h>
#include "ViewProviderPlane.h"
#include "SoFCSelection.h"
#include "Application.h"
#include "Document.h"
#include "View3DInventorViewer.h"