本文整理汇总了C++中SoCamera::unref方法的典型用法代码示例。如果您正苦于以下问题:C++ SoCamera::unref方法的具体用法?C++ SoCamera::unref怎么用?C++ SoCamera::unref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoCamera
的用法示例。
在下文中一共展示了SoCamera::unref方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PRIVATE
/*!
Set the Coin event manager for the widget.
*/
void
QuarterWidget::setSoEventManager(SoEventManager * manager)
{
bool carrydata = false;
SoNode * scene = NULL;
SoCamera * camera = NULL;
SbViewportRegion vp;
if (PRIVATE(this)->soeventmanager && (manager != NULL)) {
scene = PRIVATE(this)->soeventmanager->getSceneGraph();
camera = PRIVATE(this)->soeventmanager->getCamera();
vp = PRIVATE(this)->soeventmanager->getViewportRegion();
carrydata = true;
}
// ref before deleting the old scene manager to avoid that the nodes are deleted
if (scene) scene->ref();
if (camera) camera->ref();
if (PRIVATE(this)->initialsoeventmanager) {
delete PRIVATE(this)->soeventmanager;
PRIVATE(this)->initialsoeventmanager = false;
}
PRIVATE(this)->soeventmanager = manager;
if (carrydata) {
PRIVATE(this)->soeventmanager->setSceneGraph(scene);
PRIVATE(this)->soeventmanager->setCamera(camera);
PRIVATE(this)->soeventmanager->setViewportRegion(vp);
}
if (scene) scene->unref();
if (camera) camera->unref();
}
示例2: activated
void CmdRaytracingWriteCamera::activated(int iMsg)
{
const char* ppReturn=0;
getGuiApplication()->sendMsgToActiveView("GetCamera",&ppReturn);
if (ppReturn) {
std::string str(ppReturn);
if (str.find("PerspectiveCamera") == std::string::npos) {
int ret = QMessageBox::warning(Gui::getMainWindow(),
qApp->translate("CmdRaytracingWriteView","No perspective camera"),
qApp->translate("CmdRaytracingWriteView","The current view camera is not perspective"
" and thus the result of the povray image later might look different to"
" what you expect.\nDo you want to continue?"),
QMessageBox::Yes|QMessageBox::No);
if (ret != QMessageBox::Yes)
return;
}
}
SoInput in;
in.setBuffer((void*)ppReturn,std::strlen(ppReturn));
SoNode* rootNode;
SoDB::read(&in,rootNode);
if (!rootNode || !rootNode->getTypeId().isDerivedFrom(SoCamera::getClassTypeId()))
throw Base::Exception("CmdRaytracingWriteCamera::activated(): Could not read "
"camera information from ASCII stream....\n");
// root-node returned from SoDB::readAll() has initial zero
// ref-count, so reference it before we start using it to
// avoid premature destruction.
SoCamera * Cam = static_cast<SoCamera*>(rootNode);
Cam->ref();
SbRotation camrot = Cam->orientation.getValue();
SbVec3f upvec(0, 1, 0); // init to default up vector
camrot.multVec(upvec, upvec);
SbVec3f lookat(0, 0, -1); // init to default view direction vector
camrot.multVec(lookat, lookat);
SbVec3f pos = Cam->position.getValue();
float Dist = Cam->focalDistance.getValue();
QStringList filter;
filter << QObject::tr("Povray(*.pov)");
filter << QObject::tr("All Files (*.*)");
QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QObject::tr("Export page"), QString(), filter.join(QLatin1String(";;")));
if (fn.isEmpty())
return;
std::string cFullName = (const char*)fn.toUtf8();
// building up the python string
std::stringstream out;
out << "Raytracing.writeCameraFile(\"" << strToPython(cFullName) << "\","
<< "(" << pos.getValue()[0] <<"," << pos.getValue()[1] <<"," << pos.getValue()[2] <<"),"
<< "(" << lookat.getValue()[0] <<"," << lookat.getValue()[1] <<"," << lookat.getValue()[2] <<")," ;
lookat *= Dist;
lookat += pos;
out << "(" << lookat.getValue()[0] <<"," << lookat.getValue()[1] <<"," << lookat.getValue()[2] <<"),"
<< "(" << upvec.getValue()[0] <<"," << upvec.getValue()[1] <<"," << upvec.getValue()[2] <<") )" ;
doCommand(Doc,"import Raytracing");
doCommand(Gui,out.str().c_str());
// Bring ref-count of root-node back to zero to cause the
// destruction of the camera.
Cam->unref();
}