+ Thomas Anderson's patch for spacenav

git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5242 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
wmayer
2011-12-09 11:29:51 +00:00
parent a5c8113aaa
commit 012e50c524
6 changed files with 123 additions and 56 deletions

View File

@@ -1059,6 +1059,8 @@ void View3DInventorViewer::processEvent(QEvent * event)
return;
}
motionEvent->setHandled(true);
static float translationConstant(-.001f);
float xTrans, yTrans, zTrans;
xTrans = static_cast<float>(motionEvent->translationX());
@@ -1379,15 +1381,15 @@ void View3DInventorViewer::viewAll()
}
//navigation->viewAll();
}
void View3DInventorViewer::viewAll(float factor)
{
void View3DInventorViewer::viewAll(float factor)
{
SoCamera * cam = this->getCamera();
if (!cam) return;
if (factor <= 0.0f) return;
if (factor != 1.0f) {
SoSearchAction sa;
if (factor != 1.0f) {
SoSearchAction sa;
sa.setType(SoSkipBoundingGroup::getClassTypeId());
sa.setInterest(SoSearchAction::ALL);
sa.apply(this->getSceneGraph());
@@ -1425,11 +1427,11 @@ void View3DInventorViewer::viewAll(float factor)
graph->addChild(cube);
cam->viewAll(graph, this->getViewportRegion());
graph->unref();
}
else {
viewAll();
}
}
}
else {
viewAll();
}
}
void View3DInventorViewer::viewSelection()
{
@@ -2053,16 +2055,16 @@ SoPath * View3DInventorViewer::pickFilterCB(void *viewer, const SoPickedPoint *
{
ViewProvider* vp = static_cast<View3DInventorViewer*>(viewer)->getViewProviderByPath(pp->getPath());
if (vp && vp->useNewSelectionModel()) {
std::string e = vp->getElement(pp);
vp->getSelectionShape(e.c_str());
static char buf[513];
snprintf(buf,512,"Hovered: %s (%f,%f,%f)"
,e.c_str()
,pp->getPoint()[0]
,pp->getPoint()[1]
,pp->getPoint()[2]);
getMainWindow()->statusBar()->showMessage(QString::fromAscii(buf),3000);
std::string e = vp->getElement(pp);
vp->getSelectionShape(e.c_str());
static char buf[513];
snprintf(buf,512,"Hovered: %s (%f,%f,%f)"
,e.c_str()
,pp->getPoint()[0]
,pp->getPoint()[1]
,pp->getPoint()[2]);
getMainWindow()->statusBar()->showMessage(QString::fromAscii(buf),3000);
}
return pp->getPath();
}
@@ -2094,18 +2096,18 @@ ViewProvider* View3DInventorViewer::getViewProviderByPath(SoPath * path) const
ViewProvider* View3DInventorViewer::getViewProviderByPathFromTail(SoPath * path) const
{
// Make sure I'm the lowest LocHL in the pick path!
for (int i = 0; i < path->getLength(); i++) {
SoNode *node = path->getNodeFromTail(i);
if (node->isOfType(SoSeparator::getClassTypeId())) {
std::map<SoSeparator*,ViewProvider*>::const_iterator it = _ViewProviderMap.find(static_cast<SoSeparator*>(node));
if (it != _ViewProviderMap.end()){
return it->second;
}
}
}
return 0;
// Make sure I'm the lowest LocHL in the pick path!
for (int i = 0; i < path->getLength(); i++) {
SoNode *node = path->getNodeFromTail(i);
if (node->isOfType(SoSeparator::getClassTypeId())) {
std::map<SoSeparator*,ViewProvider*>::const_iterator it = _ViewProviderMap.find(static_cast<SoSeparator*>(node));
if (it != _ViewProviderMap.end()){
return it->second;
}
}
}
return 0;
}
std::vector<ViewProvider*> View3DInventorViewer::getViewProvidersOfType(const Base::Type& typeId) const