21 #include "Inventor/nodes/SoMaterial.h"
22 #include <Inventor/nodes/SoPerspectiveCamera.h>
23 #include <Inventor/nodes/SoOrthographicCamera.h>
24 #include <Inventor/nodes/SoGroup.h>
25 #include <Inventor/nodes/SoNurbsCurve.h>
26 #include <Inventor/nodes/SoCoordinate4.h>
28 #include <Inventor/SoPath.h>
29 #include <Inventor/SoOffscreenRenderer.h>
30 #include "Inventor/Qt/SoQtRenderArea.h"
31 #include <Inventor/actions/SoSearchAction.h>
32 #include <Inventor/SoDB.h>
33 #include <Inventor/actions/SoWriteAction.h>
35 #include <Inventor/nodes/SoLineSet.h>
36 #include <Inventor/nodes/SoVertexProperty.h>
39 #include <Inventor/VRMLnodes/SoVRMLGroup.h>
40 #include <Inventor/actions/SoToVRML2Action.h>
46 #include <QTextStream>
49 #include <QtCoreVersion>
54 ucharAddress(
auto *
pv){
55 return reinterpret_cast<unsigned char *
>(
pv);
76 static void latorgba(
unsigned char *
b,
unsigned char *
a,
unsigned char *
l,
int n)
88 unsigned char *
b,
unsigned char *
l,
int n)
95 l += 4; ++
r; ++
g; ++
b;
100 unsigned char *
b,
unsigned char *
a,
unsigned char *
l,
int n)
107 l += 4; ++
r; ++
g; ++
b; ++
a;
144 endianTest.testWord = 1;
145 if (endianTest.testByte[0] == 1) {
153 fprintf(
stderr,
"Out of memory!\n");
161 int bytesRead = fread(
image, 1, 12,
image->file);
164 fprintf(
stderr,
"fread failed!\n");
181 const unsigned int colourBuffSize=
image->xsize*256
u;
183 image->tmpR = ucharAddress(
malloc(colourBuffSize));
184 image->tmpG = ucharAddress(
malloc(colourBuffSize));
185 image->tmpB = ucharAddress(
malloc(colourBuffSize));
186 if (
image->tmp == NULL ||
image->tmpR == NULL ||
image->tmpG == NULL ||
187 image->tmpB == NULL) {
188 fprintf(
stderr,
"Out of memory!\n");
193 if ((
image->type & 0xFF00) == 0x0100) {
194 size_t x = ((size_t)
image->ysize * (
size_t)
image->zsize) *
sizeof(
unsigned);
197 if (
image->rowStart == NULL ||
image->rowSize == NULL) {
198 fprintf(
stderr,
"Out of memory!\n");
201 image->rleEnd = 512 + (2 *
x);
202 const int fseekRetVal= fseek(
image->file, 512, SEEK_SET);
203 if (fseekRetVal !=0){
204 fprintf(
stderr,
"Something very wrong with fseek near line 205 of VP1QtInventorUtils.cxx");
206 size_t bytesRead = 0;
207 bytesRead = fread(
image->rowStart, 1,
x,
image->file);
209 bytesRead = fread(
image->rowSize, 1,
x,
image->file);
217 image->rowStart = NULL;
218 image->rowSize = NULL;
230 free(
image->rowSize);
231 free(
image->rowStart);
236 unsigned char *buf,
int y,
int z)
238 unsigned char *iPtr, *oPtr,
pixel;
242 if ((
image->type & 0xFF00) == 0x0100) {
244 int okseek = fseek(
image->file, (
long)
image->rowStart[
y+
z*
image->ysize], SEEK_SET);
245 int okread = fread(
image->tmp, 1, (
unsigned int)
image->rowSize[
y+
z*
image->ysize],
271 int okstatus = fseek(
image->file, 512
u+yDim+zDim, SEEK_SET);
274 size_t bytesRead = 0;
275 bytesRead = fread(buf, 1,
image->xsize,
image->file);
281 std::cout <<
"Warning! ImageGetRow() - no 'image'..." << std::endl;
287 unsigned *
base, *lptr;
288 unsigned char *rbuf, *gbuf, *bbuf, *abuf;
297 (*width)=
image->xsize;
298 (*height)=
image->ysize;
299 (*components)=
image->zsize;
300 const unsigned int imageWidth =
image->xsize;
301 const unsigned int imageHeight =
image->ysize;
302 const unsigned int uintSize(
sizeof(
unsigned)), ucharSize(
sizeof(
unsigned char));
303 const unsigned int colourBufSize=imageWidth*ucharSize;
304 base =
reinterpret_cast<unsigned *
>(
malloc(imageWidth*imageHeight*uintSize));
305 rbuf = ucharAddress(
malloc(colourBufSize));
306 gbuf = ucharAddress(
malloc(colourBufSize));
307 bbuf = ucharAddress(
malloc(colourBufSize));
308 abuf = ucharAddress(
malloc(colourBufSize));
309 if(!
base || !rbuf || !gbuf || !bbuf) {
312 if (rbuf) free(rbuf);
313 if (gbuf) free(gbuf);
314 if (bbuf) free(bbuf);
315 if (abuf) free(abuf);
320 if (
image->zsize>=4) {
326 lptr +=
image->xsize;
327 }
else if(
image->zsize==3) {
332 lptr +=
image->xsize;
333 }
else if(
image->zsize==2) {
337 lptr +=
image->xsize;
341 lptr +=
image->xsize;
350 return (
unsigned *)
base;
406 if(
width == 0 || height == 0 ) std::cout <<
"VP1QtInventorUtils::imageFromRGBFile - read_texture failed?" << std::endl;
408 unsigned char *
data =
reinterpret_cast<unsigned char*
>(imagedata);
411 QImage
im(
width,height, ( components <= 3 ? QImage::Format_RGB32 : QImage::Format_ARGB32 ) );
414 for (
y=0;
y<height; ++
y) {
429 bool transparent_background,
double actualRenderedSizeFact )
442 if (actualRenderedSizeFact!=1.0&&!transparent_background) {
444 static_cast<int>(pixels_x*actualRenderedSizeFact+0.5),
445 static_cast<int>(pixels_y*actualRenderedSizeFact+0.5),
448 .scaled(pixels_x,pixels_y,Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
451 if (transparent_background) {
456 SbColor save_bgd = ra->getBackgroundColor();
457 SbBool save_redraw = ra->isAutoRedraw();
459 ra->setAutoRedraw(
false);
462 QImage im_black_bgd, im_white_bgd;
463 if (actualRenderedSizeFact==1.0) {
464 ra->setBackgroundColor(SbColor(0.0,0.0,0.0));
465 im_black_bgd =
renderToImage(ra, pixels_x, pixels_y,
false,1.0);
466 ra->setBackgroundColor(SbColor(1.0,1.0,1.0));
467 im_white_bgd =
renderToImage(ra, pixels_x, pixels_y,
false,1.0);
469 ra->setBackgroundColor(SbColor(0.0,0.0,0.0));
470 im_black_bgd =
renderToImage(ra,
static_cast<int>(pixels_x*actualRenderedSizeFact+0.5),
static_cast<int>(pixels_y*actualRenderedSizeFact+0.5),
false,1.0);
471 ra->setBackgroundColor(SbColor(1.0,1.0,1.0));
472 im_white_bgd =
renderToImage(ra,
static_cast<int>(pixels_x*actualRenderedSizeFact+0.5),
static_cast<int>(pixels_y*actualRenderedSizeFact+0.5),
false,1.0);
475 ra->setBackgroundColor(save_bgd);
476 ra->setAutoRedraw(save_redraw);
478 if (actualRenderedSizeFact==1.0)
482 .scaled(pixels_x,pixels_y,Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
499 SoNode *rootOverlay = ra->getOverlaySceneGraph();
504 SbViewportRegion myViewport;
505 myViewport.setWindowSize(SbVec2s(pixels_x,pixels_y));
507 QString tmppath(QDir::tempPath());
508 if (!tmppath.endsWith(QDir::separator()))
509 tmppath+=QDir::separator();
510 tmppath +=
"vp1tmpfileXXXXXX.rgb";
511 std::string stmppath = tmppath.toStdString();
512 int tmpfd = mkstemps (stmppath.data(), 4);
513 FILE* tmpf = fdopen (tmpfd,
"w");
514 QString tmpfile (stmppath.c_str());
517 SoOffscreenRenderer *myRenderer =
new SoOffscreenRenderer(myViewport);
520 myRenderer->setBackgroundColor(ra->getBackgroundColor());
523 myRenderer->setComponents(SoOffscreenRenderer::RGB_TRANSPARENCY);
524 myRenderer->getGLRenderAction()->setTransparencyType(ra->getTransparencyType());
528 SbBool smoothing;
int numPasses;
529 ra->getAntialiasing (smoothing, numPasses);
530 myRenderer->getGLRenderAction()->setSmoothing (smoothing);
531 myRenderer->getGLRenderAction()->setNumPasses(numPasses);
538 if (!myRenderer->render(
root)) {
548 bool okOver = myRenderer->render(rootOverlay);
561 if (!myRenderer->writeToRGB(tmpf)) {
564 QFile(tmpfile).remove();
579 QFile(tmpfile).remove();
588 bool transparent_background,
double actualRenderedSizeFact )
590 return QPixmap::fromImage(
renderToImage(ra, pixels_x, pixels_y, transparent_background, actualRenderedSizeFact));
596 if (im_black_bgd.isNull()||im_white_bgd.isNull()||im_black_bgd.size()!=im_white_bgd.size())
599 QImage
im(im_black_bgd.size(),QImage::Format_ARGB32);
602 int height =
im.height();
603 QRgb white = qRgba(255,255,255,255);
604 QRgb black = qRgba(0,0,0,255);
607 for (
int y = 0;
y < height; ++
y) {
608 if (im_black_bgd.pixel(
x,
y)==im_white_bgd.pixel(
x,
y)) {
609 im.setPixel(
x,
y,im_white_bgd.pixel(
x,
y));
610 }
else if (im_black_bgd.pixel(
x,
y)==black&&im_white_bgd.pixel(
x,
y)==white) {
611 im.setPixel(
x,
y,Qt::transparent);
614 QColor pix_b = QColor(im_black_bgd.pixel(
x,
y));
615 QColor pix_w = QColor(im_white_bgd.pixel(
x,
y));
616 qreal
alpha = 1.0 - pix_w.redF() + pix_b.redF();
618 im.setPixel(
x,
y,Qt::transparent);
620 im.setPixel(
x,
y,qRgba(
static_cast<int>(pix_b.redF()/
alpha*255+0.5),
621 static_cast<int>(pix_b.greenF()/
alpha*255+0.5),
622 static_cast<int>(pix_b.blueF()/
alpha*255+0.5),
623 static_cast<int>(
alpha*255+0.5)));
635 return SoGLRenderAction::DELAYED_BLEND;
641 QList<SoGLRenderAction::TransparencyType>
l;
643 << SoGLRenderAction::SCREEN_DOOR
645 << SoGLRenderAction::DELAYED_ADD
646 << SoGLRenderAction::SORTED_OBJECT_ADD
647 << SoGLRenderAction::BLEND
648 << SoGLRenderAction::DELAYED_BLEND
649 << SoGLRenderAction::SORTED_OBJECT_BLEND
650 << SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD
651 << SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND
652 << SoGLRenderAction::SORTED_LAYERS_BLEND;
660 case SoGLRenderAction::SCREEN_DOOR:
return 0;
662 case SoGLRenderAction::DELAYED_ADD:
return 2;
663 case SoGLRenderAction::SORTED_OBJECT_ADD:
return 3;
664 case SoGLRenderAction::BLEND:
return 4;
665 case SoGLRenderAction::DELAYED_BLEND:
return 5;
666 case SoGLRenderAction::SORTED_OBJECT_BLEND:
return 6;
667 case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD:
return 7;
668 case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND:
return 8;
670 case SoGLRenderAction::SORTED_LAYERS_BLEND:
return 10;
672 VP1Msg::messageDebug(
"VP1QtInventorUtils::transparencyTypeToInt ERROR: Unknown transparency type");
680 case 0:
return SoGLRenderAction::SCREEN_DOOR;
682 case 2:
return SoGLRenderAction::DELAYED_ADD;
683 case 3:
return SoGLRenderAction::SORTED_OBJECT_ADD;
684 case 4:
return SoGLRenderAction::BLEND;
685 case 5:
return SoGLRenderAction::DELAYED_BLEND;
686 case 6:
return SoGLRenderAction::SORTED_OBJECT_BLEND;
687 case 7:
return SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD;
688 case 8:
return SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND;
690 case 10:
return SoGLRenderAction::SORTED_LAYERS_BLEND;
693 return SoGLRenderAction::DELAYED_BLEND;
702 case SoGLRenderAction::DELAYED_BLEND:
return "Delayed blend";
break;
703 case SoGLRenderAction::SCREEN_DOOR:
return "Screen door";
break;
705 case SoGLRenderAction::DELAYED_ADD:
return "Delayed add";
break;
706 case SoGLRenderAction::SORTED_OBJECT_ADD:
return "Sorted object add";
break;
707 case SoGLRenderAction::BLEND:
return "Blend (Best for Geo volumes)";
break;
708 case SoGLRenderAction::SORTED_OBJECT_BLEND:
return "Sorted object blend (Best for physics objects: jets, tracks, ...)";
break;
709 case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_ADD:
return "Sorted object sorted triangle add";
break;
710 case SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND:
return "Sorted object sorted triangle blend";
break;
712 case SoGLRenderAction::SORTED_LAYERS_BLEND:
return "Sorted layers blend";
break;
723 QByteArray byteArray;
724 QBuffer
buffer(&byteArray);
725 buffer.open(QIODevice::WriteOnly);
731 rot.getValue (q0,q1,q2,q3);
755 buffer.open(QIODevice::ReadOnly);
756 QDataStream state(&
buffer);
760 state.setFloatingPointPrecision(QDataStream::SinglePrecision);
768 rot.setValue (q0,q1,q2,q3);
786 rot.setValue (q0,q1,q2,q3);
806 QByteArray byteArray;
807 QBuffer
buffer(&byteArray);
808 buffer.open(QIODevice::WriteOnly);
834 buffer.open(QIODevice::ReadOnly);
835 QDataStream state(&
buffer);
839 state.setFloatingPointPrecision(QDataStream::SinglePrecision);
883 QByteArray byteArray;
884 QBuffer
buffer(&byteArray);
885 buffer.open(QIODevice::WriteOnly);
890 SbRotation camrot = cam.orientation.getValue();
892 SbVec3f campos = cam.position.getValue();
894 float f_aspectRatio(cam.aspectRatio.getValue());
895 float f_nearDistance(cam.nearDistance.getValue());
896 float f_farDistance(cam.farDistance.getValue());
897 float f_focalDistance(cam.focalDistance.getValue());
904 switch (cam.viewportMapping.getValue()) {
905 case SoCamera::CROP_VIEWPORT_FILL_FRAME: viewportmap = 0;
break;
906 case SoCamera::CROP_VIEWPORT_LINE_FRAME: viewportmap = 1;
break;
907 case SoCamera::CROP_VIEWPORT_NO_FRAME: viewportmap = 2;
break;
908 case SoCamera::ADJUST_CAMERA: viewportmap = 3;
break;
909 case SoCamera::LEAVE_ALONE: viewportmap = 4;
break;
915 if (cam.getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId()))
917 else if (cam.getTypeId().isDerivedFrom(SoOrthographicCamera::getClassTypeId()))
922 out << (double)static_cast<const SoPerspectiveCamera*>(&cam)->heightAngle.getValue();
923 }
else if (camtype==1) {
924 out << (double)static_cast<const SoOrthographicCamera*>(&cam)->height.getValue();
939 +QString(camtype==0?
"perspective":(camtype==1?
"orthographic":
"unknown")));
942 +
QString::number(
static_cast<const SoPerspectiveCamera*
>(&cam)->heightAngle.getValue()));
945 +
QString::number(
static_cast<const SoOrthographicCamera*
>(&cam)->height.getValue()));
956 if (ba==QByteArray())
961 buffer.open(QIODevice::ReadOnly);
962 QDataStream state(&
buffer);
966 state.setFloatingPointPrecision(QDataStream::SinglePrecision);
969 SbRotation rot; QByteArray ba_rot; state >> ba_rot;
972 SbVec3f
pos; QByteArray ba_pos; state >> ba_pos;
975 bool save = cam.enableNotify(
false);
977 cam.orientation.setValue(rot);
978 cam.position.setValue(
pos);
980 float f_aspectRatio, f_nearDistance, f_farDistance, f_focalDistance;
982 state >> f_aspectRatio; cam.aspectRatio.setValue(f_aspectRatio);
983 state >> f_nearDistance; cam.nearDistance.setValue(f_nearDistance);
984 state >> f_farDistance; cam.farDistance.setValue(f_farDistance);
985 state >> f_focalDistance; cam.focalDistance.setValue(f_focalDistance);
989 switch (viewportmap) {
990 case 0: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_FILL_FRAME);
break;
991 case 1: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_LINE_FRAME);
break;
992 case 2: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_NO_FRAME);
break;
993 case 3: cam.viewportMapping.setValue(SoCamera::ADJUST_CAMERA);
break;
994 case 4: cam.viewportMapping.setValue(SoCamera::LEAVE_ALONE);
break;
998 bool passedcameraisperspective = cam.getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId());
1003 float f_orthopersp_heightpar(-999);
1006 if (!passedcameraisperspective)
1008 state >> f_orthopersp_heightpar;
1009 static_cast<SoPerspectiveCamera*
>(&cam)->heightAngle.setValue(f_orthopersp_heightpar);
1010 }
else if (camtype==1) {
1012 if (passedcameraisperspective)
1014 state >> f_orthopersp_heightpar;
1015 static_cast<SoOrthographicCamera*
>(&cam)->height.setValue(f_orthopersp_heightpar);
1019 cam.enableNotify(
true);
1033 +QString(camtype==0?
"perspective":(camtype==1?
"orthographic":
"unknown")));
1047 SbRotation rot; QByteArray ba_rot; state >> ba_rot;
1050 SbVec3f
pos; QByteArray ba_pos; state >> ba_pos;
1053 bool save = cam.enableNotify(
false);
1055 cam.orientation.setValue(rot);
1056 cam.position.setValue(
pos);
1058 double f_aspectRatio, f_nearDistance, f_farDistance, f_focalDistance;
1060 state >> f_aspectRatio; cam.aspectRatio.setValue(f_aspectRatio);
1061 state >> f_nearDistance; cam.nearDistance.setValue(f_nearDistance);
1062 state >> f_farDistance; cam.farDistance.setValue(f_farDistance);
1063 state >> f_focalDistance; cam.focalDistance.setValue(f_focalDistance);
1067 switch (viewportmap) {
1068 case 0: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_FILL_FRAME);
break;
1069 case 1: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_LINE_FRAME);
break;
1070 case 2: cam.viewportMapping.setValue(SoCamera::CROP_VIEWPORT_NO_FRAME);
break;
1071 case 3: cam.viewportMapping.setValue(SoCamera::ADJUST_CAMERA);
break;
1072 case 4: cam.viewportMapping.setValue(SoCamera::LEAVE_ALONE);
break;
1076 bool passedcameraisperspective = cam.getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId());
1081 double f_orthopersp_heightpar(-999);
1084 if (!passedcameraisperspective)
1086 state >> f_orthopersp_heightpar;
1087 static_cast<SoPerspectiveCamera*
>(&cam)->heightAngle.setValue(f_orthopersp_heightpar);
1088 }
else if (camtype==1) {
1090 if (passedcameraisperspective)
1092 state >> f_orthopersp_heightpar;
1093 static_cast<SoOrthographicCamera*
>(&cam)->height.setValue(f_orthopersp_heightpar);
1097 cam.enableNotify(
true);
1111 +QString(camtype==0?
"perspective":(camtype==1?
"orthographic":
"unknown")));
1122 cam.unrefNoDelete();
1130 return SbColor( col.red()/255.0, col.green()/255.0, col.blue()/255.0 );
1137 col.getValue(
r,
g,
b);
1138 return QColor::fromRgbF(
r,
g,
b );
1144 if (!
m||
m->ambientColor.getNum()!=1
1145 ||
m->diffuseColor.getNum()!=1
1146 ||
m->specularColor.getNum()!=1
1147 ||
m->emissiveColor.getNum()!=1
1148 ||
m->transparency.getNum()!=1
1149 ||
m->shininess.getNum()!=1) {
1151 "Passed material must have exactly one value in each of the 6 fields!!");
1152 return QByteArray();
1157 QByteArray byteArray;
1158 QBuffer
buffer(&byteArray);
1159 buffer.open(QIODevice::WriteOnly);
1163 out << QString(
"somat_v1_begin");
1169 out << (
double)
m->transparency[0];
1170 out << QString(
"somat_end");
1182 if (!
m||
m->ambientColor.getNum()!=1
1183 ||
m->diffuseColor.getNum()!=1
1184 ||
m->specularColor.getNum()!=1
1185 ||
m->emissiveColor.getNum()!=1
1186 ||
m->transparency.getNum()!=1
1187 ||
m->shininess.getNum()!=1) {
1189 "Passed material must have exactly one value in each of the 6 fields!!");
1195 buffer.open(QIODevice::ReadOnly);
1198 stream.setFloatingPointPrecision(QDataStream::SinglePrecision);
1202 if (
str!=
"somat_v1_begin")
1205 QColor ambientcol;
stream >> ambientcol;
1206 if (!ambientcol.isValid())
1209 QColor diffusecol;
stream >> diffusecol;
1210 if (!diffusecol.isValid())
1213 QColor specularcol;
stream >> specularcol;
1214 if (!specularcol.isValid())
1217 QColor emissivecol;
stream >> emissivecol;
1218 if (!emissivecol.isValid())
1221 if(ba.size()==106) {
1223 float shininess;
stream >> shininess;
1224 if (shininess<0.0f||shininess>1.0
f)
1227 float transparency;
stream >> transparency;
1228 if (transparency<0.0f||transparency>1.0
f)
1232 if (
str!=
"somat_end")
1240 m->specularColor.setValue(
qcol2sbcol(specularcol));
1241 m->emissiveColor.setValue(
qcol2sbcol(emissivecol));
1242 m->shininess.setValue(shininess);
1243 m->transparency.setValue(transparency);
1247 double shininess;
stream >> shininess;
1248 if (shininess<0.0||shininess>1.0)
1251 double transparency;
stream >> transparency;
1252 if (transparency<0.0||transparency>1.0)
1256 if (
str!=
"somat_end")
1264 m->specularColor.setValue(
qcol2sbcol(specularcol));
1265 m->emissiveColor.setValue(
qcol2sbcol(emissivecol));
1266 m->shininess.setValue(shininess);
1267 m->transparency.setValue(transparency);
1276 SoGroup* grp =
new SoGroup;
1279 SoCoordinate4 *
coord =
new SoCoordinate4;
1280 const double invsqrttwo=0.707106781186547;
1283 coord->point.set1Value(icoord++,SbVec4f(1*
radius,0,0,1));
1284 coord->point.set1Value(icoord++,SbVec4f(invsqrttwo*
radius,invsqrttwo*
radius,0,invsqrttwo));
1285 coord->point.set1Value(icoord++,SbVec4f(0,1*
radius,0,1));
1286 coord->point.set1Value(icoord++,SbVec4f(-invsqrttwo*
radius,invsqrttwo*
radius,0,invsqrttwo));
1287 coord->point.set1Value(icoord++,SbVec4f(-1*
radius,0,0,1));
1288 coord->point.set1Value(icoord++,SbVec4f(-invsqrttwo*
radius,-invsqrttwo*
radius,0,invsqrttwo));
1289 coord->point.set1Value(icoord++,SbVec4f(0,-1*
radius,0,1));
1290 coord->point.set1Value(icoord++,SbVec4f(invsqrttwo*
radius,-invsqrttwo*
radius,0,invsqrttwo));
1291 coord->point.set1Value(icoord++,SbVec4f(1*
radius,0,0,1));
1293 SoNurbsCurve * curve =
new SoNurbsCurve;
1294 curve->numControlPoints = icoord;
1298 curve->knotVector.set1Value(iknot++,0);
1299 curve->knotVector.set1Value(iknot++,0);
1300 curve->knotVector.set1Value(iknot++,0);
1301 curve->knotVector.set1Value(iknot++,1);
1302 curve->knotVector.set1Value(iknot++,1);
1303 curve->knotVector.set1Value(iknot++,2);
1304 curve->knotVector.set1Value(iknot++,2);
1305 curve->knotVector.set1Value(iknot++,3);
1306 curve->knotVector.set1Value(iknot++,3);
1307 curve->knotVector.set1Value(iknot++,4);
1308 curve->knotVector.set1Value(iknot++,4);
1309 curve->knotVector.set1Value(iknot++,4);
1310 grp->addChild(
coord);
1311 grp->addChild(curve);
1313 grp->unrefNoDelete();
1320 SoVertexProperty *vertices =
new SoVertexProperty();
1323 vertices->vertex.set1Value(iver++,radiusX,0.0,0.0);
1324 for (
int i = 1;
i < numnodes;
i++)
1326 vertices->vertex.set1Value(iver++,
1327 cos(2.0*
static_cast<double>(
i)*
M_PI/
static_cast<double>(numnodes))*radiusX,
1328 sin(2.0*
static_cast<double>(
i)*
M_PI/
static_cast<double>(numnodes))*radiusY,0.0);
1330 vertices->vertex.set1Value(iver++,radiusX,0.0,0.0);
1332 SoLineSet * ellipse =
new SoLineSet();
1333 ellipse->numVertices = iver;
1334 ellipse->vertexProperty = vertices;
1342 if (!
path||!commonBranchPoint||!newtail)
1346 sa.setInterest(SoSearchAction::FIRST);
1347 sa.setNode(newtail);
1348 sa.apply(commonBranchPoint);
1351 SoPath * newpath = sa.getPath();
1355 for (
int i=0;
i<
path->getLength();++
i) {
1356 if (
path->getNode(
i)==commonBranchPoint) {
1358 path->truncate(
i+1);
1363 path->append(newpath);
1386 out.setBuffer(
buffer, buffer_size, buffer_realloc);
1388 SoWriteAction wa(&
out);
1399 SoToVRML2Action vwa;
1402 SoVRMLGroup * newroot = vwa.getVRML2SceneGraph();
1406 out.setHeaderString(
"#VRML V2.0 utf8");
1407 SoWriteAction wra(&
out);
1422 root->unrefNoDelete();
1425 if (
data.open(QFile::WriteOnly | QFile::Truncate)) {
1427 #if QTCORE_VERSION >= 0x050E00
1428 out <<
s << Qt::endl;
1443 if (!in.openFile(
filename.toStdString().c_str()))
1445 return SoDB::readAll(&in);
1457 root->unrefNoDelete();
1475 const double& brightness,
const double& transp )
1483 const double& brightness,
const double& transp )
1485 setMatColor(
m, col.redF(), col.greenF(), col.blueF(), brightness, transp);
1518 "purpose of getting supported line widths and point sizes!");
1522 SbVec2f
range;
float granularity;
1523 ra->getLineWidthLimits(
range, granularity);
1529 VP1Msg::messageVerbose(
"VP1QtInventorUtils Determined line widths supported by hardware (min,max,granularity) = ("
1531 ra->getPointSizeLimits(
range, granularity);
1536 VP1Msg::messageVerbose(
"VP1QtInventorUtils Determined point sizes supported by hardware (min,max,granularity) = ("
1563 slider->setRange(0,nsteps);
1564 slider->setSingleStep(1);
1565 slider->setPageStep(stepsPerUnit);
1575 int nsteps =
std::min(1000,std::max<int>(0,
1577 int stepsPerUnit =
std::min(nsteps,std::max<int>(1,
1579 slider->setRange(0,nsteps);
1580 slider->setSingleStep(1);
1581 slider->setPageStep(stepsPerUnit);
1591 int itarget =
std::min(slider->maximum(),std::max<int>(slider->minimum(),
1593 if (slider->value()!=itarget)
1594 slider->setValue(itarget);
1604 int itarget =
std::min(slider->maximum(),std::max<int>(slider->minimum(),
1606 if (slider->value()!=itarget)
1607 slider->setValue(itarget);