本文整理汇总了C++中SoInput::isValidBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ SoInput::isValidBuffer方法的具体用法?C++ SoInput::isValidBuffer怎么用?C++ SoInput::isValidBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoInput
的用法示例。
在下文中一共展示了SoInput::isValidBuffer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
DragDropHandlerP::dropEvent(QDropEvent * event)
{
const QMimeData * mimedata = event->mimeData();
SoSeparator * root;
SoInput in;
QByteArray bytes;
if (mimedata->hasUrls()) {
QUrl url = mimedata->urls().takeFirst();
if (url.scheme().isEmpty() || url.scheme().toLower() == QString("file") ) {
// attempt to open file
if (!in.openFile(url.toLocalFile().toLatin1().constData())) return;
}
} else if (mimedata->hasText()) {
/* FIXME 2007-11-09 preng: dropping text buffer does not work on Windows Vista. */
bytes = mimedata->text().toUtf8();
in.setBuffer((void *) bytes.constData(), bytes.size());
if (!in.isValidBuffer()) return;
}
// attempt to import it
root = SoDB::readAll(&in);
if (root == NULL) return;
// set new scenegraph
this->quarterwidget->setSceneGraph(root);
this->quarterwidget->viewport()->update();
}
示例2: doc_insert_geometric_object
int QilexDoc::doc_insert_geometric_object(QDomElement geom_element)
{
int error = 0;
const char * buffer;
SbVec3f joinax;
SoTransform *pos_rot = new SoTransform;
float joinangle;
float pos_x, pos_y, pos_z, pos_rx, pos_ry, pos_rz;
QString data, name;
QDomNode node;
QDomElement element;
QDomNodeList list;
SoSeparator *geomelement = new SoSeparator;
SoSeparator *geomtest = new SoSeparator;
name = geom_element.attribute ("name", QString::null);
data = geom_element.attribute ("pos_x", QString::null);
pos_x = data.toFloat();
data = geom_element.attribute ("pos_y", QString::null);
pos_y = data.toFloat();
data = geom_element.attribute ("pos_z", QString::null);
pos_z = data.toFloat();
data = geom_element.attribute ("pos_rx", QString::null);
pos_rx = data.toFloat();
data = geom_element.attribute ("pos_ry", QString::null);
pos_ry = data.toFloat();
data = geom_element.attribute ("pos_rz", QString::null);
pos_rz = data.toFloat();
data = geom_element.attribute ("pos_angle", QString::null);
joinangle = data.toFloat();
joinax.setValue(SbVec3f( pos_x, pos_y, pos_z));
pos_rot->translation.setValue(joinax);
pos_rot->rotation.setValue(SbVec3f(pos_rx, pos_ry, pos_rz), (float) rad((double)joinangle));
list = geom_element.elementsByTagName ("model3d");
if (list.length() == 1)
{
node = list.item(0);
element = node.toElement();
data = element.attribute ("format", QString::null);
// some stuff to take care about the format
data = element.attribute ("size", QString::null);
size_t size = (size_t)data.toULong(0,10);
buffer = new char[size];
data = element.text();
buffer = data.ascii();
SoInput input;
input.setBuffer((void*) buffer, size);
if (input.isValidBuffer())
{
geomelement = SoDB::readAll(&input);
if (geomelement == NULL)
error = 10;
}
else
{error = 8;} // assigno un nombre diferent de 0
}
else
{ error =9; }// assigno un nombre diferent de 0
if (error == 0)
{
geomelement->ref();
geomtest = (SoSeparator*)SoNode::getByName(name.latin1());
if (geomtest==NULL)
{
//we need to put it in a buffer to write the xml file
// if is Ok
geomelement->insertChild(pos_rot, 0);
geomelement->setName(name.latin1());
view->addObjectCell(geomelement);
}
}
return error;
}
示例3: doc_insert_kinematic_chain
int QilexDoc::doc_insert_kinematic_chain(QDomElement kine_element)
{
int error = 0;
const char * buffer;
QDomNodeList list;
Rchain *kineengine = new Rchain;
SoSeparator *kinechain = new SoSeparator;
SoSeparator *kinetest = new SoSeparator;
//Rchain *kineengine = new Rchain;
SoTransform *pos_rot = new SoTransform;
SbVec3f joinax;
float joinangle;
float pos_x, pos_y, pos_z, pos_rx, pos_ry, pos_rz;
QString data, name;
QDomNode node;
QDomElement element;
name = kine_element.attribute ("name", QString::null);
data = kine_element.attribute ("kineengine", QString::null);
// here put some stuff to select the kinechain engine
data = kine_element.attribute ("pos_x", QString::null);
pos_x = data.toFloat();
data = kine_element.attribute ("pos_y", QString::null);
pos_y = data.toFloat();
data = kine_element.attribute ("pos_z", QString::null);
pos_z = data.toFloat();
data = kine_element.attribute ("pos_rx", QString::null);
pos_rx = data.toFloat();
data = kine_element.attribute ("pos_ry", QString::null);
pos_ry = data.toFloat();
data = kine_element.attribute ("pos_rz", QString::null);
pos_rz = data.toFloat();
data = kine_element.attribute ("pos_angle", QString::null);
joinangle = data.toFloat();
joinax.setValue(SbVec3f( pos_x, pos_y, pos_z));
pos_rot->translation.setValue(joinax);
pos_rot->rotation.setValue(SbVec3f(pos_rx, pos_ry, pos_rz), (float) rad((double)joinangle));
list = kine_element.elementsByTagName ("kinechain");
if (list.length() == 1)
{
node = list.item(0);
element = node.toElement();
error = kineengine->read_element_xml (element);
}
else
{ error =4;} // assigno un nombre diferrent de 0
list = kine_element.elementsByTagName ("model3d");
if (list.length() == 1)
{
node = list.item(0);
element = node.toElement();
data = element.attribute ("format", QString::null);
// some stuff to take care about the format
data = element.attribute ("size", QString::null);
size_t size = (size_t)data.toULong(0,10);
buffer = new char[size];
data = element.text();
buffer = data.ascii();
/* char *buffer2 = new char[size];
for(unsigned i=0;i<size;i++)
buffer2[i] = buffer[i];
*/
SoInput input;
input.setBuffer((void *)buffer, size);
if (input.isValidBuffer())
{
kinechain = SoDB::readAll(&input);
if (kinechain == NULL)
error = 10;
}
else
{error = 8;} // assigno un nombre diferent de 0
}
else
{ error =9; }// assigno un nombre diferent de 0
//.........这里部分代码省略.........