20 #include "Inventor/nodes/SoMaterial.h"
21 #include <Inventor/nodes/SoPerspectiveCamera.h>
22 #include <Inventor/nodes/SoOrthographicCamera.h>
23 #include <Inventor/nodes/SoGroup.h>
24 #include <Inventor/nodes/SoNurbsCurve.h>
25 #include <Inventor/nodes/SoCoordinate4.h>
27 #include <Inventor/SoPath.h>
28 #include <Inventor/SoOffscreenRenderer.h>
29 #include "Inventor/Qt/SoQtRenderArea.h"
30 #include <Inventor/actions/SoSearchAction.h>
31 #include <Inventor/SoDB.h>
32 #include <Inventor/actions/SoWriteAction.h>
34 #include <Inventor/nodes/SoLineSet.h>
35 #include <Inventor/nodes/SoVertexProperty.h>
38 #include <Inventor/VRMLnodes/SoVRMLGroup.h>
39 #include <Inventor/actions/SoToVRML2Action.h>
45 #include <QTextStream>
48 #include <QtCoreVersion>
69 static void latorgba(
unsigned char *
b,
unsigned char *
a,
unsigned char *
l,
int n)
81 unsigned char *
b,
unsigned char *
l,
int n)
88 l += 4; ++
r; ++
g; ++
b;
93 unsigned char *
b,
unsigned char *
a,
unsigned char *
l,
int n)
100 l += 4; ++
r; ++
g; ++
b; ++
a;
125 ptr = (
unsigned char *)
array;
129 *
array++ = (b1 << 8) | (b2);
135 unsigned b1, b2, b3, b4;
138 ptr = (
unsigned char *)
array;
144 *
array++ = (b1 << 24) | (b2 << 16) | (b3 << 8) | (b4);
157 endianTest.testWord = 1;
158 if (endianTest.testByte[0] == 1) {
166 fprintf(
stderr,
"Out of memory!\n");
174 int bytesRead = fread(
image, 1, 12,
image->file);
177 fprintf(
stderr,
"fread failed!\n");
189 const unsigned int colourBuffSize=
image->xsize*256
u;
190 image->tmp = (
unsigned char *)
malloc(colourBuffSize);
191 image->tmpR = (
unsigned char *)
malloc(colourBuffSize);
192 image->tmpG = (
unsigned char *)
malloc(colourBuffSize);
193 image->tmpB = (
unsigned char *)
malloc(colourBuffSize);
194 if (
image->tmp == NULL ||
image->tmpR == NULL ||
image->tmpG == NULL ||
195 image->tmpB == NULL) {
196 fprintf(
stderr,
"Out of memory!\n");
201 if ((
image->type & 0xFF00) == 0x0100) {
202 size_t x = ((size_t)
image->ysize * (
size_t)
image->zsize) *
sizeof(
unsigned);
205 if (
image->rowStart == NULL ||
image->rowSize == NULL) {
206 fprintf(
stderr,
"Out of memory!\n");
209 image->rleEnd = 512 + (2 *
x);
210 const int fseekRetVal= fseek(
image->file, 512, SEEK_SET);
211 if (fseekRetVal !=0){
212 fprintf(
stderr,
"Something very wrong with fseek near line 205 of VP1QtInventorUtils.cxx");
214 size_t bytesRead = 0;
215 bytesRead = fread(
image->rowStart, 1,
x,
image->file);
217 bytesRead = fread(
image->rowSize, 1,
x,
image->file);
225 image->rowStart = NULL;
226 image->rowSize = NULL;
238 free(
image->rowSize);
239 free(
image->rowStart);
244 unsigned char *buf,
int y,
int z)
246 unsigned char *iPtr, *oPtr,
pixel;
250 if ((
image->type & 0xFF00) == 0x0100) {
252 int okseek = fseek(
image->file, (
long)
image->rowStart[
y+
z*
image->ysize], SEEK_SET);
253 int okread = fread(
image->tmp, 1, (
unsigned int)
image->rowSize[
y+
z*
image->ysize],
279 int okstatus = fseek(
image->file, 512
u+yDim+zDim, SEEK_SET);
282 size_t bytesRead = 0;
283 bytesRead = fread(buf, 1,
image->xsize,
image->file);
289 std::cout <<
"Warning! ImageGetRow() - no 'image'..." << std::endl;
295 unsigned *
base, *lptr;
296 unsigned char *rbuf, *gbuf, *bbuf, *abuf;
305 (*width)=
image->xsize;
306 (*height)=
image->ysize;
307 (*components)=
image->zsize;
308 const unsigned int imageWidth =
image->xsize;
309 const unsigned int imageHeight =
image->ysize;
310 const unsigned int uintSize(
sizeof(
unsigned)), ucharSize(
sizeof(
unsigned char));
311 const unsigned int colourBufSize=imageWidth*ucharSize;
312 base = (
unsigned *)
malloc(imageWidth*imageHeight*uintSize);
313 rbuf = (
unsigned char *)
malloc(colourBufSize);
314 gbuf = (
unsigned char *)
malloc(colourBufSize);
315 bbuf = (
unsigned char *)
malloc(colourBufSize);
316 abuf = (
unsigned char *)
malloc(colourBufSize);
317 if(!
base || !rbuf || !gbuf || !bbuf) {
320 if (rbuf) free(rbuf);
321 if (gbuf) free(gbuf);
322 if (bbuf) free(bbuf);
323 if (abuf) free(abuf);
328 if (
image->zsize>=4) {
334 lptr +=
image->xsize;
335 }
else if(
image->zsize==3) {
340 lptr +=
image->xsize;
341 }
else if(
image->zsize==2) {
345 lptr +=
image->xsize;
349 lptr +=
image->xsize;
358 return (
unsigned *)
base;
414 if(
width == 0 || height == 0 ) std::cout <<
"VP1QtInventorUtils::imageFromRGBFile - read_texture failed?" << std::endl;
416 unsigned char *
data =
reinterpret_cast<unsigned char*
>(imagedata);
419 QImage
im(
width,height, ( components <= 3 ? QImage::Format_RGB32 : QImage::Format_ARGB32 ) );
422 for (
y=0;
y<height; ++
y) {
437 bool transparent_background,
double actualRenderedSizeFact )
450 if (actualRenderedSizeFact!=1.0&&!transparent_background) {
452 static_cast<int>(pixels_x*actualRenderedSizeFact+0.5),
453 static_cast<int>(pixels_y*actualRenderedSizeFact+0.5),
456 .scaled(pixels_x,pixels_y,Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
459 if (transparent_background) {
464 SbColor save_bgd = ra->getBackgroundColor();
465 SbBool save_redraw = ra->isAutoRedraw();
467 ra->setAutoRedraw(
false);
470 QImage im_black_bgd, im_white_bgd;
471 if (actualRenderedSizeFact==1.0) {
472 ra->setBackgroundColor(SbColor(0.0,0.0,0.0));
473 im_black_bgd =
renderToImage(ra, pixels_x, pixels_y,
false,1.0);
474 ra->setBackgroundColor(SbColor(1.0,1.0,1.0));
475 im_white_bgd =
renderToImage(ra, pixels_x, pixels_y,
false,1.0);
477 ra->setBackgroundColor(SbColor(0.0,0.0,0.0));
478 im_black_bgd =
renderToImage(ra,
static_cast<int>(pixels_x*actualRenderedSizeFact+0.5),
static_cast<int>(pixels_y*actualRenderedSizeFact+0.5),
false,1.0);
479 ra->setBackgroundColor(SbColor(1.0,1.0,1.0));
480 im_white_bgd =
renderToImage(ra,
static_cast<int>(pixels_x*actualRenderedSizeFact+0.5),
static_cast<int>(pixels_y*actualRenderedSizeFact+0.5),
false,1.0);
483 ra->setBackgroundColor(save_bgd);
484 ra->setAutoRedraw(save_redraw);
486 if (actualRenderedSizeFact==1.0)
490 .scaled(pixels_x,pixels_y,Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
507 SoNode *rootOverlay = ra->getOverlaySceneGraph();
512 SbViewportRegion myViewport;
513 myViewport.setWindowSize(SbVec2s(pixels_x,pixels_y));
515 QString tmppath(QDir::tempPath());
516 if (!tmppath.endsWith(QDir::separator()))
517 tmppath+=QDir::separator();
518 tmppath +=
"vp1tmpfileXXXXXX.rgb";
519 std::string stmppath = tmppath.toStdString();
520 int tmpfd = mkstemps (stmppath.data(), 4);
521 FILE* tmpf = fdopen (tmpfd,
"w");
522 QString tmpfile (stmppath.c_str());
525 SoOffscreenRenderer *myRenderer =
new SoOffscreenRenderer(myViewport);
528 myRenderer->setBackgroundColor(ra->getBackgroundColor());
531 myRenderer->setComponents(SoOffscreenRenderer::RGB_TRANSPARENCY);
532 myRenderer->getGLRenderAction()->setTransparencyType(ra->getTransparencyType());
536 SbBool smoothing;
int numPasses;
537 ra->getAntialiasing (smoothing, numPasses);
538 myRenderer->getGLRenderAction()->setSmoothing (smoothing);
539 myRenderer->getGLRenderAction()->setNumPasses(numPasses);
546 if (!myRenderer->render(
root)) {
555 bool okOver = myRenderer->render(rootOverlay);
567 if (!myRenderer->writeToRGB(tmpf)) {
570 QFile(tmpfile).remove();
585 QFile(tmpfile).remove();
594 bool transparent_background,
double actualRenderedSizeFact )
596 return QPixmap::fromImage(
renderToImage(ra, pixels_x, pixels_y, transparent_background, actualRenderedSizeFact));
602 if (im_black_bgd.isNull()||im_white_bgd.isNull()||im_black_bgd.size()!=im_white_bgd.size())
605 QImage
im(im_black_bgd.size(),QImage::Format_ARGB32);
608 int height =
im.height();
609 QRgb white = qRgba(255,255,255,255);
610 QRgb black = qRgba(0,0,0,255);
613 for (
int y = 0;
y < height; ++
y) {
614 if (im_black_bgd.pixel(
x,
y)==im_white_bgd.pixel(
x,
y)) {
615 im.setPixel(
x,
y,im_white_bgd.pixel(
x,
y));
616 }
else if (im_black_bgd.pixel(
x,
y)==black&&im_white_bgd.pixel(
x,
y)==white) {
617 im.setPixel(
x,
y,Qt::transparent);
620 QColor pix_b = QColor(im_black_bgd.pixel(
x,
y));
621 QColor pix_w = QColor(im_white_bgd.pixel(
x,
y));
622 qreal alpha = 1.0 - pix_w.redF() + pix_b.redF();
624 im.setPixel(
x,
y,Qt::transparent);
626 im.setPixel(
x,
y,qRgba(
static_cast<int>(pix_b.redF()/alpha*255+0.5),
627 static_cast<int>(pix_b.greenF()/alpha*255+0.5),
628 static_cast<int>(pix_b.blueF()/alpha*255+0.5),
629 static_cast<int>(alpha*255+0.5)));
641 return SoGLRenderAction::DELAYED_BLEND;
647 QList<SoGLRenderAction::TransparencyType>
l;
649 << SoGLRenderAction::SCREEN_DOOR
651 << SoGLRenderAction::DELAYED_ADD
652 << SoGLRenderAction::SORTED_OBJECT_ADD
653 << SoGLRenderAction::BLEND
654 << SoGLRenderAction::DELAYED_BLEND
655 << SoGLRenderAction::SORTED_OBJECT_BLEND
656 << SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD
657 << SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND
658 << SoGLRenderAction::SORTED_LAYERS_BLEND;
666 case SoGLRenderAction::SCREEN_DOOR:
return 0;
668 case SoGLRenderAction::DELAYED_ADD:
return 2;
669 case SoGLRenderAction::SORTED_OBJECT_ADD:
return 3;
670 case SoGLRenderAction::BLEND:
return 4;
671 case SoGLRenderAction::DELAYED_BLEND:
return 5;
672 case SoGLRenderAction::SORTED_OBJECT_BLEND:
return 6;
673 case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD:
return 7;
674 case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND:
return 8;
676 case SoGLRenderAction::SORTED_LAYERS_BLEND:
return 10;
678 VP1Msg::messageDebug(
"VP1QtInventorUtils::transparencyTypeToInt ERROR: Unknown transparency type");
686 case 0:
return SoGLRenderAction::SCREEN_DOOR;
688 case 2:
return SoGLRenderAction::DELAYED_ADD;
689 case 3:
return SoGLRenderAction::SORTED_OBJECT_ADD;
690 case 4:
return SoGLRenderAction::BLEND;
691 case 5:
return SoGLRenderAction::DELAYED_BLEND;
692 case 6:
return SoGLRenderAction::SORTED_OBJECT_BLEND;
693 case 7:
return SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD;
694 case 8:
return SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND;
696 case 10:
return SoGLRenderAction::SORTED_LAYERS_BLEND;
699 return SoGLRenderAction::DELAYED_BLEND;
708 case SoGLRenderAction::DELAYED_BLEND:
return "Delayed blend";
break;
709 case SoGLRenderAction::SCREEN_DOOR:
return "Screen door";
break;
711 case SoGLRenderAction::DELAYED_ADD:
return "Delayed add";
break;
712 case SoGLRenderAction::SORTED_OBJECT_ADD:
return "Sorted object add";
break;
713 case SoGLRenderAction::BLEND:
return "Blend (Best for Geo volumes)";
break;
714 case SoGLRenderAction::SORTED_OBJECT_BLEND:
return "Sorted object blend (Best for physics objects: jets, tracks, ...)";
break;
715 case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD:
return "Sorted object sorted triangle add";
break;
716 case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND:
return "Sorted object sorted triangle blend";
break;
718 case SoGLRenderAction::SORTED_LAYERS_BLEND:
return "Sorted layers blend";
break;
729 QByteArray byteArray;
730 QBuffer
buffer(&byteArray);
731 buffer.open(QIODevice::WriteOnly);
737 rot.getValue (q0,q1,q2,q3);
761 buffer.open(QIODevice::ReadOnly);
762 QDataStream state(&
buffer);
766 state.setFloatingPointPrecision(QDataStream::SinglePrecision);
774 rot.setValue (q0,q1,q2,q3);
792 rot.setValue (q0,q1,q2,q3);
812 QByteArray byteArray;
813 QBuffer
buffer(&byteArray);
814 buffer.open(QIODevice::WriteOnly);
840 buffer.open(QIODevice::ReadOnly);
841 QDataStream state(&
buffer);
845 state.setFloatingPointPrecision(QDataStream::SinglePrecision);
889 QByteArray byteArray;
890 QBuffer
buffer(&byteArray);
891 buffer.open(QIODevice::WriteOnly);
896 SbRotation camrot = cam.orientation.getValue();
898 SbVec3f campos = cam.position.getValue();
900 float f_aspectRatio(cam.aspectRatio.getValue());
901 float f_nearDistance(cam.nearDistance.getValue());
902 float f_farDistance(cam.farDistance.getValue());
903 float f_focalDistance(cam.focalDistance.getValue());
910 switch (cam.viewportMapping.getValue()) {
911 case SoCamera::CROP_VIEWPORT_FILL_FRAME: viewportmap = 0;
break;
912 case SoCamera::CROP_VIEWPORT_LINE_FRAME: viewportmap = 1;
break;
913 case SoCamera::CROP_VIEWPORT_NO_FRAME: viewportmap = 2;
break;
914 case SoCamera::ADJUST_CAMERA: viewportmap = 3;
break;
915 case SoCamera::LEAVE_ALONE: viewportmap = 4;
break;
921 if (cam.getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId()))
923 else if (cam.getTypeId().isDerivedFrom(SoOrthographicCamera::getClassTypeId()))
928 out << (double)static_cast<const SoPerspectiveCamera*>(&cam)->heightAngle.getValue();
929 }
else if (camtype==1) {
930 out << (double)static_cast<const SoOrthographicCamera*>(&cam)->height.getValue();
945 +QString(camtype==0?
"perspective":(camtype==1?
"orthographic":
"unknown")));
948 +
QString::number(
static_cast<const SoPerspectiveCamera*
>(&cam)->heightAngle.getValue()));
951 +
QString::number(
static_cast<const SoOrthographicCamera*
>(&cam)->height.getValue()));
962 if (ba==QByteArray())
967 buffer.open(QIODevice::ReadOnly);
968 QDataStream state(&
buffer);
972 state.setFloatingPointPrecision(QDataStream::SinglePrecision);
975 SbRotation rot; QByteArray ba_rot; state >> ba_rot;
978 SbVec3f
pos; QByteArray ba_pos; state >> ba_pos;
981 bool save = cam.enableNotify(
false);
983 cam.orientation.setValue(rot);
984 cam.position.setValue(
pos);
986 float f_aspectRatio, f_nearDistance, f_farDistance, f_focalDistance;
988 state >> f_aspectRatio; cam.aspectRatio.setValue(f_aspectRatio);
989 state >> f_nearDistance; cam.nearDistance.setValue(f_nearDistance);
990 state >> f_farDistance; cam.farDistance.setValue(f_farDistance);
991 state >> f_focalDistance; cam.focalDistance.setValue(f_focalDistance);
995 switch (viewportmap) {
996 case 0: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_FILL_FRAME);
break;
997 case 1: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_LINE_FRAME);
break;
998 case 2: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_NO_FRAME);
break;
999 case 3: cam.viewportMapping.setValue(SoCamera::ADJUST_CAMERA);
break;
1000 case 4: cam.viewportMapping.setValue(SoCamera::LEAVE_ALONE);
break;
1004 bool passedcameraisperspective = cam.getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId());
1009 float f_orthopersp_heightpar(-999);
1012 if (!passedcameraisperspective)
1014 state >> f_orthopersp_heightpar;
1015 static_cast<SoPerspectiveCamera*
>(&cam)->heightAngle.setValue(f_orthopersp_heightpar);
1016 }
else if (camtype==1) {
1018 if (passedcameraisperspective)
1020 state >> f_orthopersp_heightpar;
1021 static_cast<SoOrthographicCamera*
>(&cam)->height.setValue(f_orthopersp_heightpar);
1025 cam.enableNotify(
true);
1039 +QString(camtype==0?
"perspective":(camtype==1?
"orthographic":
"unknown")));
1053 SbRotation rot; QByteArray ba_rot; state >> ba_rot;
1056 SbVec3f
pos; QByteArray ba_pos; state >> ba_pos;
1059 bool save = cam.enableNotify(
false);
1061 cam.orientation.setValue(rot);
1062 cam.position.setValue(
pos);
1064 double f_aspectRatio, f_nearDistance, f_farDistance, f_focalDistance;
1066 state >> f_aspectRatio; cam.aspectRatio.setValue(f_aspectRatio);
1067 state >> f_nearDistance; cam.nearDistance.setValue(f_nearDistance);
1068 state >> f_farDistance; cam.farDistance.setValue(f_farDistance);
1069 state >> f_focalDistance; cam.focalDistance.setValue(f_focalDistance);
1073 switch (viewportmap) {
1074 case 0: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_FILL_FRAME);
break;
1075 case 1: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_LINE_FRAME);
break;
1076 case 2: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_NO_FRAME);
break;
1077 case 3: cam.viewportMapping.setValue(SoCamera::ADJUST_CAMERA);
break;
1078 case 4: cam.viewportMapping.setValue(SoCamera::LEAVE_ALONE);
break;
1082 bool passedcameraisperspective = cam.getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId());
1087 double f_orthopersp_heightpar(-999);
1090 if (!passedcameraisperspective)
1092 state >> f_orthopersp_heightpar;
1093 static_cast<SoPerspectiveCamera*
>(&cam)->heightAngle.setValue(f_orthopersp_heightpar);
1094 }
else if (camtype==1) {
1096 if (passedcameraisperspective)
1098 state >> f_orthopersp_heightpar;
1099 static_cast<SoOrthographicCamera*
>(&cam)->height.setValue(f_orthopersp_heightpar);
1103 cam.enableNotify(
true);
1117 +QString(camtype==0?
"perspective":(camtype==1?
"orthographic":
"unknown")));
1128 cam.unrefNoDelete();
1136 return SbColor(
col.red()/255.0,
col.green()/255.0,
col.blue()/255.0 );
1144 return QColor::fromRgbF(
r,
g,
b );
1150 if (!
m||
m->ambientColor.getNum()!=1
1151 ||
m->diffuseColor.getNum()!=1
1152 ||
m->specularColor.getNum()!=1
1153 ||
m->emissiveColor.getNum()!=1
1154 ||
m->transparency.getNum()!=1
1155 ||
m->shininess.getNum()!=1) {
1157 "Passed material must have exactly one value in each of the 6 fields!!");
1158 return QByteArray();
1163 QByteArray byteArray;
1164 QBuffer
buffer(&byteArray);
1165 buffer.open(QIODevice::WriteOnly);
1169 out << QString(
"somat_v1_begin");
1175 out << (
double)
m->transparency[0];
1176 out << QString(
"somat_end");
1188 if (!
m||
m->ambientColor.getNum()!=1
1189 ||
m->diffuseColor.getNum()!=1
1190 ||
m->specularColor.getNum()!=1
1191 ||
m->emissiveColor.getNum()!=1
1192 ||
m->transparency.getNum()!=1
1193 ||
m->shininess.getNum()!=1) {
1195 "Passed material must have exactly one value in each of the 6 fields!!");
1201 buffer.open(QIODevice::ReadOnly);
1204 stream.setFloatingPointPrecision(QDataStream::SinglePrecision);
1208 if (
str!=
"somat_v1_begin")
1211 QColor ambientcol;
stream >> ambientcol;
1212 if (!ambientcol.isValid())
1215 QColor diffusecol;
stream >> diffusecol;
1216 if (!diffusecol.isValid())
1219 QColor specularcol;
stream >> specularcol;
1220 if (!specularcol.isValid())
1223 QColor emissivecol;
stream >> emissivecol;
1224 if (!emissivecol.isValid())
1227 if(ba.size()==106) {
1229 float shininess;
stream >> shininess;
1230 if (shininess<0.0f||shininess>1.0
f)
1233 float transparency;
stream >> transparency;
1234 if (transparency<0.0f||transparency>1.0
f)
1238 if (
str!=
"somat_end")
1246 m->specularColor.setValue(
qcol2sbcol(specularcol));
1247 m->emissiveColor.setValue(
qcol2sbcol(emissivecol));
1248 m->shininess.setValue(shininess);
1249 m->transparency.setValue(transparency);
1253 double shininess;
stream >> shininess;
1254 if (shininess<0.0||shininess>1.0)
1257 double transparency;
stream >> transparency;
1258 if (transparency<0.0||transparency>1.0)
1262 if (
str!=
"somat_end")
1270 m->specularColor.setValue(
qcol2sbcol(specularcol));
1271 m->emissiveColor.setValue(
qcol2sbcol(emissivecol));
1272 m->shininess.setValue(shininess);
1273 m->transparency.setValue(transparency);
1282 SoGroup* grp =
new SoGroup;
1285 SoCoordinate4 *
coord =
new SoCoordinate4;
1286 const double invsqrttwo=0.707106781186547;
1289 coord->point.set1Value(icoord++,SbVec4f(1*
radius,0,0,1));
1290 coord->point.set1Value(icoord++,SbVec4f(invsqrttwo*
radius,invsqrttwo*
radius,0,invsqrttwo));
1291 coord->point.set1Value(icoord++,SbVec4f(0,1*
radius,0,1));
1292 coord->point.set1Value(icoord++,SbVec4f(-invsqrttwo*
radius,invsqrttwo*
radius,0,invsqrttwo));
1293 coord->point.set1Value(icoord++,SbVec4f(-1*
radius,0,0,1));
1294 coord->point.set1Value(icoord++,SbVec4f(-invsqrttwo*
radius,-invsqrttwo*
radius,0,invsqrttwo));
1295 coord->point.set1Value(icoord++,SbVec4f(0,-1*
radius,0,1));
1296 coord->point.set1Value(icoord++,SbVec4f(invsqrttwo*
radius,-invsqrttwo*
radius,0,invsqrttwo));
1297 coord->point.set1Value(icoord++,SbVec4f(1*
radius,0,0,1));
1299 SoNurbsCurve * curve =
new SoNurbsCurve;
1300 curve->numControlPoints = icoord;
1304 curve->knotVector.set1Value(iknot++,0);
1305 curve->knotVector.set1Value(iknot++,0);
1306 curve->knotVector.set1Value(iknot++,0);
1307 curve->knotVector.set1Value(iknot++,1);
1308 curve->knotVector.set1Value(iknot++,1);
1309 curve->knotVector.set1Value(iknot++,2);
1310 curve->knotVector.set1Value(iknot++,2);
1311 curve->knotVector.set1Value(iknot++,3);
1312 curve->knotVector.set1Value(iknot++,3);
1313 curve->knotVector.set1Value(iknot++,4);
1314 curve->knotVector.set1Value(iknot++,4);
1315 curve->knotVector.set1Value(iknot++,4);
1316 grp->addChild(
coord);
1317 grp->addChild(curve);
1319 grp->unrefNoDelete();
1326 SoVertexProperty *vertices =
new SoVertexProperty();
1329 vertices->vertex.set1Value(iver++,radiusX,0.0,0.0);
1330 for (
int i = 1;
i < numnodes;
i++)
1332 vertices->vertex.set1Value(iver++,
1333 cos(2.0*
static_cast<double>(
i)*
M_PI/
static_cast<double>(numnodes))*radiusX,
1334 sin(2.0*
static_cast<double>(
i)*
M_PI/
static_cast<double>(numnodes))*radiusY,0.0);
1336 vertices->vertex.set1Value(iver++,radiusX,0.0,0.0);
1338 SoLineSet * ellipse =
new SoLineSet();
1339 ellipse->numVertices = iver;
1340 ellipse->vertexProperty = vertices;
1348 if (!
path||!commonBranchPoint||!newtail)
1352 sa.setInterest(SoSearchAction::FIRST);
1353 sa.setNode(newtail);
1354 sa.apply(commonBranchPoint);
1357 SoPath * newpath = sa.getPath();
1361 for (
int i=0;
i<
path->getLength();++
i) {
1362 if (
path->getNode(
i)==commonBranchPoint) {
1364 path->truncate(
i+1);
1369 path->append(newpath);
1392 out.setBuffer(
buffer, buffer_size, buffer_realloc);
1394 SoWriteAction wa(&
out);
1405 SoToVRML2Action vwa;
1408 SoVRMLGroup * newroot = vwa.getVRML2SceneGraph();
1412 out.setHeaderString(
"#VRML V2.0 utf8");
1413 SoWriteAction wra(&
out);
1428 root->unrefNoDelete();
1431 if (
data.open(QFile::WriteOnly | QFile::Truncate)) {
1433 #if QTCORE_VERSION >= 0x050E00
1434 out <<
s << Qt::endl;
1449 if (!in.openFile(
filename.toStdString().c_str()))
1451 return SoDB::readAll(&in);
1463 root->unrefNoDelete();
1481 const double& brightness,
const double& transp )
1489 const double& brightness,
const double& transp )
1524 "purpose of getting supported line widths and point sizes!");
1528 SbVec2f
range;
float granularity;
1529 ra->getLineWidthLimits(
range, granularity);
1535 VP1Msg::messageVerbose(
"VP1QtInventorUtils Determined line widths supported by hardware (min,max,granularity) = ("
1537 ra->getPointSizeLimits(
range, granularity);
1542 VP1Msg::messageVerbose(
"VP1QtInventorUtils Determined point sizes supported by hardware (min,max,granularity) = ("
1569 slider->setRange(0,nsteps);
1570 slider->setSingleStep(1);
1571 slider->setPageStep(stepsPerUnit);
1581 int nsteps =
std::min(1000,std::max<int>(0,
1583 int stepsPerUnit =
std::min(nsteps,std::max<int>(1,
1585 slider->setRange(0,nsteps);
1586 slider->setSingleStep(1);
1587 slider->setPageStep(stepsPerUnit);
1597 int itarget =
std::min(slider->maximum(),std::max<int>(slider->minimum(),
1599 if (slider->value()!=itarget)
1600 slider->setValue(itarget);
1610 int itarget =
std::min(slider->maximum(),std::max<int>(slider->minimum(),
1612 if (slider->value()!=itarget)
1613 slider->setValue(itarget);