+ whitespace improvements

This commit is contained in:
wmayer
2014-05-09 12:18:58 +02:00
parent 0e5f3049b7
commit a376d6398a
2 changed files with 165 additions and 165 deletions

View File

@@ -259,7 +259,7 @@ View3DInventorViewer::View3DInventorViewer (QWidget *parent, const char *name,
// This is a callback node that logs all action that traverse the Inventor tree.
#if defined (FC_DEBUG) && defined(FC_LOGGING_CB)
SoCallback * cb = new SoCallback;
SoCallback * cb = new SoCallback;
cb->setCallback(interactionLoggerCB, this);
pcViewProviderRoot->addChild(cb);
#endif
@@ -352,7 +352,7 @@ SbBool View3DInventorViewer::hasViewProvider(ViewProvider* pcProvider) const
void View3DInventorViewer::addViewProvider(ViewProvider* pcProvider)
{
SoSeparator* root = pcProvider->getRoot();
if (root){
if (root) {
pcViewProviderRoot->addChild(root);
_ViewProviderMap[root] = pcProvider;
}
@@ -371,7 +371,7 @@ void View3DInventorViewer::removeViewProvider(ViewProvider* pcProvider)
resetEditingViewProvider();
SoSeparator* root = pcProvider->getRoot();
if (root){
if (root) {
pcViewProviderRoot->removeChild(root);
_ViewProviderMap.erase(root);
}
@@ -495,13 +495,13 @@ void View3DInventorViewer::setEnabledFPSCounter(bool on)
#endif
}
void View3DInventorViewer::setAxisCross(bool b)
void View3DInventorViewer::setAxisCross(bool on)
{
SoNode* scene = getSceneGraph();
SoSeparator* sep = static_cast<SoSeparator*>(scene);
if(b){
if(!axisGroup){
if (on) {
if (!axisGroup) {
axisCross = new Gui::SoShapeScale;
Gui::SoAxisCrossKit* axisKit = new Gui::SoAxisCrossKit();
axisKit->set("xAxis.appearance.drawStyle", "lineWidth 2");
@@ -514,19 +514,20 @@ void View3DInventorViewer::setAxisCross(bool b)
sep->addChild(axisGroup);
}
}else{
if(axisGroup){
}
else {
if (axisGroup) {
sep->removeChild(axisGroup);
axisGroup = 0;
}
}
}
bool View3DInventorViewer::hasAxisCross(void)
{
return axisGroup;
}
void View3DInventorViewer::setNavigationType(Base::Type t)
{
if (t.isBad())
@@ -1865,158 +1866,157 @@ static GLubyte zbmp[] = { 0x1f,0x10,0x08,0x04,0x02,0x01,0x1f };
void View3DInventorViewer::drawAxisCross(void)
{
// FIXME: convert this to a superimposition scenegraph instead of
// OpenGL calls. 20020603 mortene.
// FIXME: convert this to a superimposition scenegraph instead of
// OpenGL calls. 20020603 mortene.
// Store GL state.
glPushAttrib(GL_ALL_ATTRIB_BITS);
GLfloat depthrange[2];
glGetFloatv(GL_DEPTH_RANGE, depthrange);
GLdouble projectionmatrix[16];
glGetDoublev(GL_PROJECTION_MATRIX, projectionmatrix);
// Store GL state.
glPushAttrib(GL_ALL_ATTRIB_BITS);
GLfloat depthrange[2];
glGetFloatv(GL_DEPTH_RANGE, depthrange);
GLdouble projectionmatrix[16];
glGetDoublev(GL_PROJECTION_MATRIX, projectionmatrix);
glDepthFunc(GL_ALWAYS);
glDepthMask(GL_TRUE);
glDepthRange(0, 0);
glEnable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
glDisable(GL_BLEND); // Kills transparency.
glDepthFunc(GL_ALWAYS);
glDepthMask(GL_TRUE);
glDepthRange(0, 0);
glEnable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
glDisable(GL_BLEND); // Kills transparency.
// Set the viewport in the OpenGL canvas. Dimensions are calculated
// as a percentage of the total canvas size.
SbVec2s view = this->getGLSize();
const int pixelarea =
int(float(this->axiscrossSize)/100.0f * SoQtMin(view[0], view[1]));
// Set the viewport in the OpenGL canvas. Dimensions are calculated
// as a percentage of the total canvas size.
SbVec2s view = this->getGLSize();
const int pixelarea =
int(float(this->axiscrossSize)/100.0f * SoQtMin(view[0], view[1]));
#if 0 // middle of canvas
SbVec2s origin(view[0]/2 - pixelarea/2, view[1]/2 - pixelarea/2);
SbVec2s origin(view[0]/2 - pixelarea/2, view[1]/2 - pixelarea/2);
#endif // middle of canvas
#if 1 // lower right of canvas
SbVec2s origin(view[0] - pixelarea, 0);
SbVec2s origin(view[0] - pixelarea, 0);
#endif // lower right of canvas
glViewport(origin[0], origin[1], pixelarea, pixelarea);
glViewport(origin[0], origin[1], pixelarea, pixelarea);
// Set up the projection matrix.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
const float NEARVAL = 0.1f;
const float FARVAL = 10.0f;
const float dim = NEARVAL * float(tan(M_PI / 8.0)); // FOV is 45° (45/360 = 1/8)
glFrustum(-dim, dim, -dim, dim, NEARVAL, FARVAL);
// Set up the projection matrix.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// Set up the model matrix.
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
SbMatrix mx;
SoCamera * cam = this->getCamera();
const float NEARVAL = 0.1f;
const float FARVAL = 10.0f;
const float dim = NEARVAL * float(tan(M_PI / 8.0)); // FOV is 45° (45/360 = 1/8)
glFrustum(-dim, dim, -dim, dim, NEARVAL, FARVAL);
// If there is no camera (like for an empty scene, for instance),
// just use an identity rotation.
if (cam) { mx = cam->orientation.getValue(); }
else { mx = SbMatrix::identity(); }
mx = mx.inverse();
mx[3][2] = -3.5; // Translate away from the projection point (along z axis).
glLoadMatrixf((float *)mx);
// Set up the model matrix.
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
SbMatrix mx;
SoCamera * cam = this->getCamera();
// Find unit vector end points.
SbMatrix px;
glGetFloatv(GL_PROJECTION_MATRIX, (float *)px);
SbMatrix comb = mx.multRight(px);
// If there is no camera (like for an empty scene, for instance),
// just use an identity rotation.
if (cam) { mx = cam->orientation.getValue(); }
else { mx = SbMatrix::identity(); }
mx = mx.inverse();
mx[3][2] = -3.5; // Translate away from the projection point (along z axis).
glLoadMatrixf((float *)mx);
SbVec3f xpos;
comb.multVecMatrix(SbVec3f(1,0,0), xpos);
xpos[0] = (1 + xpos[0]) * view[0]/2;
xpos[1] = (1 + xpos[1]) * view[1]/2;
SbVec3f ypos;
comb.multVecMatrix(SbVec3f(0,1,0), ypos);
ypos[0] = (1 + ypos[0]) * view[0]/2;
ypos[1] = (1 + ypos[1]) * view[1]/2;
SbVec3f zpos;
comb.multVecMatrix(SbVec3f(0,0,1), zpos);
zpos[0] = (1 + zpos[0]) * view[0]/2;
zpos[1] = (1 + zpos[1]) * view[1]/2;
// Find unit vector end points.
SbMatrix px;
glGetFloatv(GL_PROJECTION_MATRIX, (float *)px);
SbMatrix comb = mx.multRight(px);
// Render the cross.
{
glLineWidth(2.0);
SbVec3f xpos;
comb.multVecMatrix(SbVec3f(1,0,0), xpos);
xpos[0] = (1 + xpos[0]) * view[0]/2;
xpos[1] = (1 + xpos[1]) * view[1]/2;
SbVec3f ypos;
comb.multVecMatrix(SbVec3f(0,1,0), ypos);
ypos[0] = (1 + ypos[0]) * view[0]/2;
ypos[1] = (1 + ypos[1]) * view[1]/2;
SbVec3f zpos;
comb.multVecMatrix(SbVec3f(0,0,1), zpos);
zpos[0] = (1 + zpos[0]) * view[0]/2;
zpos[1] = (1 + zpos[1]) * view[1]/2;
enum { XAXIS, YAXIS, ZAXIS };
int idx[3] = { XAXIS, YAXIS, ZAXIS };
float val[3] = { xpos[2], ypos[2], zpos[2] };
// Bubble sort.. :-}
if (val[0] < val[1]) { SoQtSwap(val[0], val[1]); SoQtSwap(idx[0], idx[1]); }
if (val[1] < val[2]) { SoQtSwap(val[1], val[2]); SoQtSwap(idx[1], idx[2]); }
if (val[0] < val[1]) { SoQtSwap(val[0], val[1]); SoQtSwap(idx[0], idx[1]); }
assert((val[0] >= val[1]) && (val[1] >= val[2])); // Just checking..
// Render the cross.
{
glLineWidth(2.0);
enum { XAXIS, YAXIS, ZAXIS };
int idx[3] = { XAXIS, YAXIS, ZAXIS };
float val[3] = { xpos[2], ypos[2], zpos[2] };
// Bubble sort.. :-}
if (val[0] < val[1]) { SoQtSwap(val[0], val[1]); SoQtSwap(idx[0], idx[1]); }
if (val[1] < val[2]) { SoQtSwap(val[1], val[2]); SoQtSwap(idx[1], idx[2]); }
if (val[0] < val[1]) { SoQtSwap(val[0], val[1]); SoQtSwap(idx[0], idx[1]); }
assert((val[0] >= val[1]) && (val[1] >= val[2])); // Just checking..
for (int i=0; i < 3; i++) {
glPushMatrix();
if (idx[i] == XAXIS) { // X axis.
if (isStereoViewing())
glColor3f(0.500f, 0.5f, 0.5f);
else
glColor3f(0.500f, 0.125f, 0.125f);
} else if (idx[i] == YAXIS) { // Y axis.
glRotatef(90, 0, 0, 1);
if (isStereoViewing())
glColor3f(0.400f, 0.4f, 0.4f);
else
glColor3f(0.125f, 0.500f, 0.125f);
} else { // Z axis.
glRotatef(-90, 0, 1, 0);
if (isStereoViewing())
glColor3f(0.300f, 0.3f, 0.3f);
else
glColor3f(0.125f, 0.125f, 0.500f);
}
this->drawArrow();
glPopMatrix();
for (int i=0; i < 3; i++) {
glPushMatrix();
if (idx[i] == XAXIS) { // X axis.
if (isStereoViewing())
glColor3f(0.500f, 0.5f, 0.5f);
else
glColor3f(0.500f, 0.125f, 0.125f);
} else if (idx[i] == YAXIS) { // Y axis.
glRotatef(90, 0, 0, 1);
if (isStereoViewing())
glColor3f(0.400f, 0.4f, 0.4f);
else
glColor3f(0.125f, 0.500f, 0.125f);
} else { // Z axis.
glRotatef(-90, 0, 1, 0);
if (isStereoViewing())
glColor3f(0.300f, 0.3f, 0.3f);
else
glColor3f(0.125f, 0.125f, 0.500f);
}
this->drawArrow();
glPopMatrix();
}
}
}
// Render axis notation letters ("X", "Y", "Z").
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, view[0], 0, view[1], -1, 1);
// Render axis notation letters ("X", "Y", "Z").
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, view[0], 0, view[1], -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
GLint unpack;
glGetIntegerv(GL_UNPACK_ALIGNMENT, &unpack);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
GLint unpack;
glGetIntegerv(GL_UNPACK_ALIGNMENT, &unpack);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if(isStereoViewing())
glColor3fv(SbVec3f(1.0f, 1.0f, 1.0f).getValue());
else
glColor3fv(SbVec3f(0.0f, 0.0f, 0.0f).getValue());
if(isStereoViewing())
glColor3fv(SbVec3f(1.0f, 1.0f, 1.0f).getValue());
else
glColor3fv(SbVec3f(0.0f, 0.0f, 0.0f).getValue());
glRasterPos2d(xpos[0], xpos[1]);
glBitmap(8, 7, 0, 0, 0, 0, xbmp);
glRasterPos2d(ypos[0], ypos[1]);
glBitmap(8, 7, 0, 0, 0, 0, ybmp);
glRasterPos2d(zpos[0], zpos[1]);
glBitmap(8, 7, 0, 0, 0, 0, zbmp);
glRasterPos2d(xpos[0], xpos[1]);
glBitmap(8, 7, 0, 0, 0, 0, xbmp);
glRasterPos2d(ypos[0], ypos[1]);
glBitmap(8, 7, 0, 0, 0, 0, ybmp);
glRasterPos2d(zpos[0], zpos[1]);
glBitmap(8, 7, 0, 0, 0, 0, zbmp);
glPixelStorei(GL_UNPACK_ALIGNMENT, unpack);
glPopMatrix();
glPixelStorei(GL_UNPACK_ALIGNMENT, unpack);
glPopMatrix();
// Reset original state.
// Reset original state.
// FIXME: are these 3 lines really necessary, as we push
// GL_ALL_ATTRIB_BITS at the start? 20000604 mortene.
glDepthRange(depthrange[0], depthrange[1]);
glMatrixMode(GL_PROJECTION);
glLoadMatrixd(projectionmatrix);
// FIXME: are these 3 lines really necessary, as we push
// GL_ALL_ATTRIB_BITS at the start? 20000604 mortene.
glDepthRange(depthrange[0], depthrange[1]);
glMatrixMode(GL_PROJECTION);
glLoadMatrixd(projectionmatrix);
glPopAttrib();
glPopAttrib();
}
// Draw an arrow for the axis representation directly through OpenGL.
@@ -2074,16 +2074,17 @@ static unsigned char hand_mask_bitmap[] = {
#define CROSS_HOT_Y 7
static unsigned char cross_bitmap[] = {
0xc0, 0x03, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02,
0x40, 0x02, 0x40, 0x02, 0x7f, 0xfe, 0x01, 0x80,
0x01, 0x80, 0x7f, 0xfe, 0x40, 0x02, 0x40, 0x02,
0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0xc0, 0x03
0xc0, 0x03, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02,
0x40, 0x02, 0x40, 0x02, 0x7f, 0xfe, 0x01, 0x80,
0x01, 0x80, 0x7f, 0xfe, 0x40, 0x02, 0x40, 0x02,
0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0xc0, 0x03
};
static unsigned char cross_mask_bitmap[] = {
0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,
0xc0,0x03
0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03,
0xc0, 0x03, 0xc0, 0x03, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xc0, 0x03, 0xc0, 0x03,
0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03
};
// Set cursor graphics according to mode.
@@ -2269,55 +2270,55 @@ std::vector<ViewProvider*> View3DInventorViewer::getViewProvidersOfType(const Ba
void View3DInventorViewer::turnAllDimensionsOn()
{
dimensionRoot->whichChild = SO_SWITCH_ALL;
dimensionRoot->whichChild = SO_SWITCH_ALL;
}
void View3DInventorViewer::turnAllDimensionsOff()
{
dimensionRoot->whichChild = SO_SWITCH_NONE;
dimensionRoot->whichChild = SO_SWITCH_NONE;
}
void View3DInventorViewer::eraseAllDimensions()
{
static_cast<SoSwitch *>(dimensionRoot->getChild(0))->removeAllChildren();
static_cast<SoSwitch *>(dimensionRoot->getChild(1))->removeAllChildren();
static_cast<SoSwitch *>(dimensionRoot->getChild(0))->removeAllChildren();
static_cast<SoSwitch *>(dimensionRoot->getChild(1))->removeAllChildren();
}
void View3DInventorViewer::turn3dDimensionsOn()
{
static_cast<SoSwitch *>(dimensionRoot->getChild(0))->whichChild = SO_SWITCH_ALL;
static_cast<SoSwitch *>(dimensionRoot->getChild(0))->whichChild = SO_SWITCH_ALL;
}
void View3DInventorViewer::turn3dDimensionsOff()
{
static_cast<SoSwitch *>(dimensionRoot->getChild(0))->whichChild = SO_SWITCH_NONE;
static_cast<SoSwitch *>(dimensionRoot->getChild(0))->whichChild = SO_SWITCH_NONE;
}
void View3DInventorViewer::addDimension3d(SoNode *node)
{
static_cast<SoSwitch *>(dimensionRoot->getChild(0))->addChild(node);
static_cast<SoSwitch *>(dimensionRoot->getChild(0))->addChild(node);
}
void View3DInventorViewer::addDimensionDelta(SoNode *node)
{
static_cast<SoSwitch *>(dimensionRoot->getChild(1))->addChild(node);
static_cast<SoSwitch *>(dimensionRoot->getChild(1))->addChild(node);
}
void View3DInventorViewer::turnDeltaDimensionsOn()
{
static_cast<SoSwitch *>(dimensionRoot->getChild(1))->whichChild = SO_SWITCH_ALL;
static_cast<SoSwitch *>(dimensionRoot->getChild(1))->whichChild = SO_SWITCH_ALL;
}
void View3DInventorViewer::turnDeltaDimensionsOff()
{
static_cast<SoSwitch *>(dimensionRoot->getChild(1))->whichChild = SO_SWITCH_NONE;
static_cast<SoSwitch *>(dimensionRoot->getChild(1))->whichChild = SO_SWITCH_NONE;
}
void View3DInventorViewer::setAntiAliasingMode(View3DInventorViewer::AntiAliasing mode)
{
getGLRenderAction()->setSmoothing(false);
int buffers = 0;
switch( mode ) {
case Smoothing:
getGLRenderAction()->setSmoothing(true);
@@ -2344,27 +2345,26 @@ void View3DInventorViewer::setAntiAliasingMode(View3DInventorViewer::AntiAliasin
#endif
}
View3DInventorViewer::AntiAliasing View3DInventorViewer::getAntiAliasingMode()
View3DInventorViewer::AntiAliasing View3DInventorViewer::getAntiAliasingMode() const
{
if(getGLRenderAction()->isSmoothing())
if (getGLRenderAction()->isSmoothing())
return Smoothing;
#if SOQT_MAJOR_VERSION > 1 || (SOQT_MAJOR_VERSION == 1 && SOQT_MINOR_VERSION >= 5)
int buffers = getSampleBuffers();
switch(buffers) {
case 0:
int buffers = getSampleBuffers();
switch(buffers) {
case 0:
return None;
case 2:
case 2:
return MSAA2x;
case 4:
case 4:
return MSAA4x;
case 8:
case 8:
return MSAA8x;
default:
setSampleBuffers(0);
default:
const_cast<View3DInventorViewer*>(this)->setSampleBuffers(0);
return None;
};
};
#else
return None;
#endif

View File

@@ -287,7 +287,7 @@ public:
*/
//@{
void setAntiAliasingMode(AntiAliasing mode);
AntiAliasing getAntiAliasingMode();
AntiAliasing getAntiAliasingMode() const;
//@}
/**