本文整理汇总了C++中SbString类的典型用法代码示例。如果您正苦于以下问题:C++ SbString类的具体用法?C++ SbString怎么用?C++ SbString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SbString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: soupgrader_add_to_namedict
// add a name to the upgrader lookup dict.
static void
soupgrader_add_to_namedict(const SbString & name)
{
assert(soupgrader_namedict);
// Note: the SbString->SbName wrapping is necessary, or the const
// char* will _not_ be valid upon the SbString going out of scope
// (while SbName makes permanent const char* references).
soupgrader_namedict->put(SbName(name.getString()).getString(), NULL);
// Create lookup both with and without the "So" prefix. This is
// necessary for the hash lookup in soupgrader_exists() to match
// with both permutations.
SbString tmp;
if (name.compareSubString("So") == 0) {
tmp = name.getSubString(2);
}
else {
tmp = "So";
tmp += name;
}
// Note: the SbString->SbName wrapping is necessary, see above
// comment.
soupgrader_namedict->put(SbName(tmp.getString()).getString(), NULL);
}
示例2: saveScreenshot
void IKRRTWindow::saveScreenshot()
{
static int counter = 0;
SbString framefile;
framefile.sprintf("renderFrame_%06d.png", counter);
counter++;
redraw();
viewer->getSceneManager()->render();
viewer->getSceneManager()->scheduleRedraw();
QGLWidget* w = (QGLWidget*)viewer->getGLWidget();
QImage i = w->grabFrameBuffer();
bool bRes = i.save(framefile.getString(), "BMP");
if (bRes)
{
cout << "wrote image " << counter << endl;
}
else
{
cout << "failed writing image " << counter << endl;
}
}
示例3: writeImage
SbBool
writeImage( const char* file, unsigned int offset, SbXipImage& image )
{
#ifdef WIN32
//assuming everything is done using the bad backslashes... so we convert all forward slashes to those
const char * fileLocal = XipReplaceChar(file, '/', '\\').getString();
#else //UNIX
//assuming the other way around since we need forward slashes now...
const char * fileLocal = XipReplaceChar(file, '\\', '/').getString();
#endif //WIN32
int r = 0;
void* imageBufferPtr = image.refBufferPtr();
if( imageBufferPtr )
{
SbString path = XipStrExpandEnv( fileLocal );
FILE* fs = fopen( path.getString(), "wb" );
if (!fs)
return FALSE;
fseek( fs, offset, SEEK_SET );
r = fwrite(imageBufferPtr, 1, image.bufferSize(), fs );
fclose( fs );
}
image.unrefBufferPtr();
return (r == image.bufferSize());
}
示例4: SoRegPoint
/**
* Creates a point element as visible feedback for the user.
*/
SoNode* ManualAlignment::pickedPointsSubGraph(const SbVec3f& p, const SbVec3f& n, int id)
{
static const float color_table [10][3] = {
{1.0f,0.0f,0.0f}, // red
{0.0f,1.0f,0.0f}, // green
{0.0f,0.0f,1.0f}, // blue
{1.0f,1.0f,0.0f}, // yellow
{0.0f,1.0f,1.0f}, // cyan
{0.7f,0.0f,0.0f},
{0.0f,0.7f,0.0f},
{0.7f,0.7f,0.0f},
{0.7f,0.0f,0.5f},
{1.0f,0.7f,0.0f}
};
int index = (id-1) % 10;
SoRegPoint* probe = new SoRegPoint();
probe->base.setValue(p);
probe->normal.setValue(n);
probe->color.setValue(color_table[index][0],color_table[index][1],color_table[index][2]);
SbString s;
probe->text.setValue(s.sprintf("RegPoint_%d", id));
return probe;
}
示例5:
void
SoXipImageOverlayManager::updateSliceMap()
{
// Removes all the previous entries
mSliceMap.clear();
SoSearchAction sa;
sa.setInterest( SoSearchAction::ALL );
sa.setType( SoXipShapeList::getClassTypeId() );
sa.setSearchingAll( TRUE );
sa.apply( mShapeSwitch );
SoPathList paths = sa.getPaths();
for( int i = 0; i < paths.getLength(); ++ i )
{
SbString label = ((SoXipShapeList *) paths[i]->getTail())->label.getValue().getString();
int sliceIndex;
if( sscanf( label.getString(), "%d", &sliceIndex ) != 1 )
{
SoDebugError::post( __FILE__, "Invalid label found '%s'", label.getString() );
continue ;
}
mSliceMap[ sliceIndex ] = (SoXipShapeList *) paths[i]->getTail();
}
}
示例6: clearClipboard
void
SoXipImageOverlayManager::loadOverlays()
{
// When the patient changes
clearClipboard();
// Remove all the geometries from the switch
mShapeSwitch->removeAllChildren();
mShapeSwitch->whichChild.setValue(-1);
mCurrentSlice = -1;
if( mImageData )
{
SbString overlayStr = mImageData->getProperty( "overlays" );
SoNodeList nodes = XipOverlayUtils::loadOverlaysFromString( overlayStr.getString(), overlayStr.getLength(), TRUE );
for( int i = 0; i < nodes.getLength(); ++ i )
{
if( !nodes[i]->isOfType( SoXipShapeList::getClassTypeId() ) )
{
SoDebugError::post( __FILE__, "Invalid overlay node found in Dicom. Ignored." );
continue ;
}
mShapeSwitch->addChild( nodes[i] );
}
}
updateSliceMap();
}
示例7: SbMax
// Documented in superclass. Overridden to pass GL state to the
// previous element.
void
SoGLMultiTextureImageElement::pop(SoState * state,
const SoElement * prevTopElement)
{
inherited::pop(state, prevTopElement);
SoGLMultiTextureImageElement * prev = (SoGLMultiTextureImageElement*)
prevTopElement;
SoGLShaderProgram * prog = SoGLShaderProgramElement::get(state);
SbString str;
const int maxunits = SbMax(PRIVATE(prev)->unitdata.getLength(),
PRIVATE(this)->unitdata.getLength());
for (int i = 0; i < maxunits; i++) {
const GLUnitData & prevud =
(i < PRIVATE(prev)->unitdata.getLength()) ?
PRIVATE(prev)->unitdata[i] :
PRIVATE(prev)->defaultdata;
const GLUnitData & thisud =
(i < PRIVATE(this)->unitdata.getLength()) ?
PRIVATE(this)->unitdata[i] :
PRIVATE(this)->defaultdata;
if (thisud.glimage != prevud.glimage) this->updateGL(i);
str.sprintf("coin_texunit%d_model", i);
if (prog) prog->updateCoinParameter(state, SbName(str.getString()),
thisud.glimage != NULL ? this->getUnitData(i).model : 0);
}
}
示例8: autoLock
void
SoVRMLAudioClipP::loadUrl()
{
#ifdef HAVE_THREADS
SbThreadAutoLock autoLock(&this->syncmutex);
#endif
this->unloadUrl();
for (int i=0; i<PUBLIC(this)->url.getNum(); i++) {
const char * str = PUBLIC(this)->url[i].getString();
if ( (str == NULL) || (strlen(str)==0) )
continue; // ignore empty url
SbString filename =
SoInput::searchForFile(SbString(str), SoInput::getDirectories(),
SoVRMLAudioClip::getSubdirectories());
if (filename.getLength() <= 0) {
SoDebugError::postWarning("SoVRMLAudioClipP::loadUrl(index)",
"File not found: '%s'",
str);
continue; // ignore invalid file
}
this->playlist.append(filename);
}
}
示例9: errorHandlerCB
void
errorHandlerCB(const SoError * error, void * data)
{
if (pipeErrorMessagesToConsole) {
(void)printf("%s\n", error->getDebugString().getString());
}
else {
SbString debugstring = error->getDebugString();
::MessageBox(NULL, CHAR_TO_NATIVE(debugstring.getString()), TEXT("SoError"), MB_OK | MB_ICONERROR);
}
}
示例10: COIN_UNUSED_ARG
SoCallbackAction::Response
SoToVRMLActionP::unsupported_cb(void * closure, SoCallbackAction * COIN_UNUSED_ARG(action), const SoNode * node)
{
SoInfo * info = NEW_NODE(SoInfo, node);
SbString str;
str.sprintf("Unsupported node: %s",
node->getTypeId().getName().getString());
info->string = str;
THISP(closure)->get_current_tail()->addChild(info);
return SoCallbackAction::CONTINUE;
}
示例11: SbStringList
void ViewProviderVRMLObject::addResource(const SbString& url, std::list<std::string>& resources)
{
SbString found = SoInput::searchForFile(url, SoInput::getDirectories(), SbStringList());
Base::FileInfo fi(found.getString());
if (fi.exists()) {
// add the resource file if not yet listed
if (std::find(resources.begin(), resources.end(), found.getString()) == resources.end()) {
resources.push_back(found.getString());
}
}
}
示例12: PRIVATE
/*!
Sets the current texture. Id \a didapply is TRUE, it is assumed
that the texture image already is the current GL texture. Do not
use this feature unless you know what you're doing.
*/
void
SoGLMultiTextureImageElement::set(SoState * const state, SoNode * const node,
const int unit,
SoGLImage * image,
Model model,
const SbColor & blendColor)
{
SoGLMultiTextureImageElement * elem = (SoGLMultiTextureImageElement*)
state->getElement(classStackIndex);
PRIVATE(elem)->ensureCapacity(unit);
GLUnitData & ud = PRIVATE(elem)->unitdata[unit];
// FIXME: buggy. Find some solution to handle this. pederb, 2003-11-12
// if (ud.glimage && ud.glimage->getImage()) ud.glimage->getImage()->readUnlock();
if (image) {
// keep SoMultiTextureImageElement "up-to-date"
inherited::set(state, node,
unit,
SbVec3s(0,0,0),
0,
NULL,
multi_translateWrap(image->getWrapS()),
multi_translateWrap(image->getWrapT()),
multi_translateWrap(image->getWrapR()),
model,
blendColor);
ud.glimage = image;
// make sure image isn't changed while this is the active texture
// FIXME: buggy. Find some solution to handle this. pederb, 2003-11-12
// if (image->getImage()) image->getImage()->readLock();
}
else {
ud.glimage = NULL;
inherited::setDefault(state, node, unit);
}
elem->updateGL(unit);
// FIXME: check if it's possible to support for other units as well
if ((unit == 0) && image && image->isOfType(SoGLBigImage::getClassTypeId())) {
SoShapeStyleElement::setBigImageEnabled(state, TRUE);
}
SoShapeStyleElement::setTransparentTexture(state,
SoGLMultiTextureImageElement::hasTransparency(state));
SoGLShaderProgram * prog = SoGLShaderProgramElement::get(state);
if (prog) {
SbString str;
str.sprintf("coin_texunit%d_model", unit);
prog->updateCoinParameter(state, SbName(str.getString()), ud.glimage ? model : 0);
}
}
示例13: data
QVariant ParametersItem::data ( int role ) const
{
if( role == Qt::DisplayRole )
{
if ( column() == 0 ) return m_text;
SbString fieldValue = "null";
m_pField->get( fieldValue );
return QString( fieldValue.getString() );
}
else
return QStandardItem::data( role );
}
示例14: glColor3f
void SoView2DLiftChart::drawSliceIndicator(int x1, int x2, int y, int slice) {
glColor3f(1, 1, 1);
glBegin(GL_LINES);
glVertex2f(x1, y - 1);
glVertex2f(x2 + 6, y - 1);
glEnd();
// convert float distance to string
SbString sliceString = float(slice);
View2DFont* font = SoView2D::globalFont(_dsl->getCurrentCacheContext());
float fcolor[4] = {color.getValue()[0],color.getValue()[1],color.getValue()[2],1};
font->drawString(x2 + 10, y - 6, 12, fcolor, sliceString.getString(), 0, true);
}
示例15: getLength
SbString
SbString::getSubString(int startChar, int endChar) const
{
int len = getLength();
// Get substring that starts at specified character
SbString tmp = &string[startChar];
// Delete characters from end if necessary
if (endChar >= 0 && endChar < len - 1)
tmp.deleteSubString(endChar - startChar + 1);
return tmp;
}