+ fix crash when viewer has no camera
This commit is contained in:
parent
3003f16389
commit
a4f0f5c129
|
@ -103,7 +103,9 @@ void StdOrthographicCamera::activated(int iMsg)
|
|||
{
|
||||
if (iMsg == 1) {
|
||||
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
|
||||
if (view->getViewer()->getSoRenderManager()->getCamera()->getTypeId() != SoOrthographicCamera::getClassTypeId())
|
||||
SoCamera* cam = view->getViewer()->getSoRenderManager()->getCamera();
|
||||
if (!cam || cam->getTypeId() != SoOrthographicCamera::getClassTypeId())
|
||||
|
||||
doCommand(Command::Gui,"Gui.activeDocument().activeView().setCameraType(\"Orthographic\")");
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +116,9 @@ bool StdOrthographicCamera::isActive(void)
|
|||
if (view) {
|
||||
// update the action group if needed
|
||||
bool check = _pcAction->isChecked();
|
||||
bool mode = view->getViewer()->getSoRenderManager()->getCamera()->getTypeId() == SoOrthographicCamera::getClassTypeId();
|
||||
SoCamera* cam = view->getViewer()->getSoRenderManager()->getCamera();
|
||||
bool mode = cam ? cam->getTypeId() == SoOrthographicCamera::getClassTypeId() : false;
|
||||
|
||||
if (mode != check)
|
||||
_pcAction->setChecked(mode);
|
||||
return true;
|
||||
|
@ -149,7 +153,9 @@ void StdPerspectiveCamera::activated(int iMsg)
|
|||
{
|
||||
if (iMsg == 1) {
|
||||
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
|
||||
if (view->getViewer()->getSoRenderManager()->getCamera()->getTypeId() != SoPerspectiveCamera::getClassTypeId())
|
||||
SoCamera* cam = view->getViewer()->getSoRenderManager()->getCamera();
|
||||
if (!cam || cam->getTypeId() != SoPerspectiveCamera::getClassTypeId())
|
||||
|
||||
doCommand(Command::Gui,"Gui.activeDocument().activeView().setCameraType(\"Perspective\")");
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +166,9 @@ bool StdPerspectiveCamera::isActive(void)
|
|||
if (view) {
|
||||
// update the action group if needed
|
||||
bool check = _pcAction->isChecked();
|
||||
bool mode = view->getViewer()->getSoRenderManager()->getCamera()->getTypeId() == SoPerspectiveCamera::getClassTypeId();
|
||||
SoCamera* cam = view->getViewer()->getSoRenderManager()->getCamera();
|
||||
bool mode = cam ? cam->getTypeId() == SoPerspectiveCamera::getClassTypeId() : false;
|
||||
|
||||
if (mode != check)
|
||||
_pcAction->setChecked(mode);
|
||||
|
||||
|
|
|
@ -196,19 +196,20 @@ QWidget* SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getGLWidget() const
|
|||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::setCameraType(SoType type)
|
||||
{
|
||||
if(!getSoRenderManager()->getCamera()->isOfType(SoPerspectiveCamera::getClassTypeId()) &&
|
||||
!getSoRenderManager()->getCamera()->isOfType(SoOrthographicCamera::getClassTypeId())) {
|
||||
!getSoRenderManager()->getCamera()->isOfType(SoOrthographicCamera::getClassTypeId())) {
|
||||
Base::Console().Warning("Quarter::setCameraType",
|
||||
"Only SoPerspectiveCamera and SoOrthographicCamera is supported.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
SoCamera* cam = getSoRenderManager()->getCamera();
|
||||
SoType perspectivetype = SoPerspectiveCamera::getClassTypeId();
|
||||
SbBool oldisperspective = getSoRenderManager()->getCamera()->getTypeId().isDerivedFrom(perspectivetype);
|
||||
SbBool oldisperspective = cam ? cam->getTypeId().isDerivedFrom(perspectivetype) : false;
|
||||
SbBool newisperspective = type.isDerivedFrom(perspectivetype);
|
||||
|
||||
if((oldisperspective && newisperspective) ||
|
||||
(!oldisperspective && !newisperspective)) // Same old, same old..
|
||||
(!oldisperspective && !newisperspective)) // Same old, same old..
|
||||
return;
|
||||
|
||||
|
||||
|
@ -506,7 +507,12 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::seeksensorCB(void* data, SoSensor
|
|||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::saveHomePosition(void)
|
||||
{
|
||||
SoType t = getSoRenderManager()->getCamera()->getTypeId();
|
||||
SoCamera* cam = getSoRenderManager()->getCamera();
|
||||
if (!cam) {
|
||||
return;
|
||||
}
|
||||
|
||||
SoType t = cam->getTypeId();
|
||||
assert(t.isDerivedFrom(SoNode::getClassTypeId()));
|
||||
assert(t.canCreateInstance());
|
||||
|
||||
|
@ -522,6 +528,11 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::saveHomePosition(void)
|
|||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::resetToHomePosition(void)
|
||||
{
|
||||
SoCamera* cam = getSoRenderManager()->getCamera();
|
||||
if (!cam) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!m_storedcamera) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user