Gui: Use auto and range-based for (#7481)
* On lines where the variable type is obvious from inspection, avoid repeating the type using auto. * When possible use a ranged for loop instead of begin() and end() iterators
This commit is contained in:
@@ -135,14 +135,14 @@ void TDragger::buildFirstInstance()
|
||||
{
|
||||
SoGroup *geometryGroup = buildGeometry();
|
||||
|
||||
SoSeparator *localTranslator = new SoSeparator();
|
||||
auto localTranslator = new SoSeparator();
|
||||
localTranslator->setName("CSysDynamics_TDragger_Translator");
|
||||
localTranslator->addChild(geometryGroup);
|
||||
SoFCDB::getStorage()->addChild(localTranslator);
|
||||
|
||||
SoSeparator *localTranslatorActive = new SoSeparator();
|
||||
auto localTranslatorActive = new SoSeparator();
|
||||
localTranslatorActive->setName("CSysDynamics_TDragger_TranslatorActive");
|
||||
SoBaseColor *colorActive = new SoBaseColor();
|
||||
auto colorActive = new SoBaseColor();
|
||||
colorActive->rgb.setValue(1.0, 1.0, 0.0);
|
||||
localTranslatorActive->addChild(colorActive);
|
||||
localTranslatorActive->addChild(geometryGroup);
|
||||
@@ -154,19 +154,19 @@ SoGroup* TDragger::buildGeometry()
|
||||
//this builds one leg in the Y+ direction because of default done direction.
|
||||
//the location anchor for shapes is the center of shape.
|
||||
|
||||
SoGroup *root = new SoGroup();
|
||||
auto root = new SoGroup();
|
||||
|
||||
//cylinder
|
||||
float cylinderHeight = 10.0;
|
||||
float cylinderRadius = 0.2f;
|
||||
SoSeparator *cylinderSeparator = new SoSeparator();
|
||||
auto cylinderSeparator = new SoSeparator();
|
||||
root->addChild(cylinderSeparator);
|
||||
|
||||
SoTranslation *cylinderTranslation = new SoTranslation();
|
||||
auto cylinderTranslation = new SoTranslation();
|
||||
cylinderTranslation->translation.setValue(0.0, cylinderHeight / 2.0, 0.0);
|
||||
cylinderSeparator->addChild(cylinderTranslation);
|
||||
|
||||
SoCylinder *cylinder = new SoCylinder();
|
||||
auto cylinder = new SoCylinder();
|
||||
cylinder->radius.setValue(cylinderRadius);
|
||||
cylinder->height.setValue(cylinderHeight);
|
||||
cylinderSeparator->addChild(cylinder);
|
||||
@@ -174,19 +174,19 @@ SoGroup* TDragger::buildGeometry()
|
||||
//cone
|
||||
float coneBottomRadius = 1.0;
|
||||
float coneHeight = 2.0;
|
||||
SoSeparator *coneSeparator = new SoSeparator();
|
||||
auto coneSeparator = new SoSeparator();
|
||||
root->addChild(coneSeparator);
|
||||
|
||||
SoPickStyle *pickStyle = new SoPickStyle();
|
||||
auto pickStyle = new SoPickStyle();
|
||||
pickStyle->style.setValue(SoPickStyle::SHAPE);
|
||||
pickStyle->setOverride(TRUE);
|
||||
coneSeparator->addChild(pickStyle);
|
||||
|
||||
SoTranslation *coneTranslation = new SoTranslation();
|
||||
auto coneTranslation = new SoTranslation();
|
||||
coneTranslation->translation.setValue(0.0, cylinderHeight + coneHeight / 2.0, 0.0);
|
||||
coneSeparator->addChild(coneTranslation);
|
||||
|
||||
SoCone *cone = new SoCone();
|
||||
auto cone = new SoCone();
|
||||
cone->bottomRadius.setValue(coneBottomRadius);
|
||||
cone->height.setValue(coneHeight);
|
||||
coneSeparator->addChild(cone);
|
||||
@@ -196,25 +196,25 @@ SoGroup* TDragger::buildGeometry()
|
||||
|
||||
void TDragger::startCB(void *, SoDragger *d)
|
||||
{
|
||||
TDragger *sudoThis = static_cast<TDragger *>(d);
|
||||
auto sudoThis = static_cast<TDragger *>(d);
|
||||
sudoThis->dragStart();
|
||||
}
|
||||
|
||||
void TDragger::motionCB(void *, SoDragger *d)
|
||||
{
|
||||
TDragger *sudoThis = static_cast<TDragger *>(d);
|
||||
auto sudoThis = static_cast<TDragger *>(d);
|
||||
sudoThis->drag();
|
||||
}
|
||||
|
||||
void TDragger::finishCB(void *, SoDragger *d)
|
||||
{
|
||||
TDragger *sudoThis = static_cast<TDragger *>(d);
|
||||
auto sudoThis = static_cast<TDragger *>(d);
|
||||
sudoThis->dragFinish();
|
||||
}
|
||||
|
||||
void TDragger::fieldSensorCB(void *f, SoSensor *)
|
||||
{
|
||||
TDragger *sudoThis = static_cast<TDragger *>(f);
|
||||
auto sudoThis = static_cast<TDragger *>(f);
|
||||
|
||||
SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft
|
||||
sudoThis->workFieldsIntoTransform(matrix);
|
||||
@@ -223,7 +223,7 @@ void TDragger::fieldSensorCB(void *f, SoSensor *)
|
||||
|
||||
void TDragger::valueChangedCB(void *, SoDragger *d)
|
||||
{
|
||||
TDragger *sudoThis = dynamic_cast<TDragger *>(d);
|
||||
auto sudoThis = dynamic_cast<TDragger *>(d);
|
||||
assert(sudoThis);
|
||||
SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft
|
||||
|
||||
@@ -409,14 +409,14 @@ void RDragger::buildFirstInstance()
|
||||
{
|
||||
SoGroup *geometryGroup = buildGeometry();
|
||||
|
||||
SoSeparator *localRotator = new SoSeparator();
|
||||
auto localRotator = new SoSeparator();
|
||||
localRotator->setName("CSysDynamics_RDragger_Rotator");
|
||||
localRotator->addChild(geometryGroup);
|
||||
SoFCDB::getStorage()->addChild(localRotator);
|
||||
|
||||
SoSeparator *localRotatorActive = new SoSeparator();
|
||||
auto localRotatorActive = new SoSeparator();
|
||||
localRotatorActive->setName("CSysDynamics_RDragger_RotatorActive");
|
||||
SoBaseColor *colorActive = new SoBaseColor();
|
||||
auto colorActive = new SoBaseColor();
|
||||
colorActive->rgb.setValue(1.0, 1.0, 0.0);
|
||||
localRotatorActive->addChild(colorActive);
|
||||
localRotatorActive->addChild(geometryGroup);
|
||||
@@ -425,10 +425,10 @@ void RDragger::buildFirstInstance()
|
||||
|
||||
SoGroup* RDragger::buildGeometry()
|
||||
{
|
||||
SoGroup *root = new SoGroup();
|
||||
auto root = new SoGroup();
|
||||
|
||||
//arc
|
||||
SoCoordinate3 *coordinates = new SoCoordinate3();
|
||||
auto coordinates = new SoCoordinate3();
|
||||
|
||||
unsigned int segments = 6;
|
||||
|
||||
@@ -442,11 +442,11 @@ SoGroup* RDragger::buildGeometry()
|
||||
}
|
||||
root->addChild(coordinates);
|
||||
|
||||
SoLineSet *lineSet = new SoLineSet();
|
||||
auto lineSet = new SoLineSet();
|
||||
lineSet->numVertices.setValue(segments + 1);
|
||||
root->addChild(lineSet);
|
||||
|
||||
SoPickStyle *pickStyle = new SoPickStyle();
|
||||
auto pickStyle = new SoPickStyle();
|
||||
pickStyle->style.setValue(SoPickStyle::SHAPE);
|
||||
pickStyle->setOverride(TRUE);
|
||||
root->addChild(pickStyle);
|
||||
@@ -455,11 +455,11 @@ SoGroup* RDragger::buildGeometry()
|
||||
SbVec3f origin(1.0, 1.0, 0.0);
|
||||
origin.normalize();
|
||||
origin *= arcRadius;
|
||||
SoTranslation *sphereTranslation = new SoTranslation();
|
||||
auto sphereTranslation = new SoTranslation();
|
||||
sphereTranslation->translation.setValue(origin);
|
||||
root->addChild(sphereTranslation);
|
||||
|
||||
SoSphere *sphere = new SoSphere();
|
||||
auto sphere = new SoSphere();
|
||||
sphere->radius.setValue(1.0);
|
||||
root->addChild(sphere);
|
||||
|
||||
@@ -468,25 +468,25 @@ SoGroup* RDragger::buildGeometry()
|
||||
|
||||
void RDragger::startCB(void *, SoDragger *d)
|
||||
{
|
||||
RDragger *sudoThis = static_cast<RDragger *>(d);
|
||||
auto sudoThis = static_cast<RDragger *>(d);
|
||||
sudoThis->dragStart();
|
||||
}
|
||||
|
||||
void RDragger::motionCB(void *, SoDragger *d)
|
||||
{
|
||||
RDragger *sudoThis = static_cast<RDragger *>(d);
|
||||
auto sudoThis = static_cast<RDragger *>(d);
|
||||
sudoThis->drag();
|
||||
}
|
||||
|
||||
void RDragger::finishCB(void *, SoDragger *d)
|
||||
{
|
||||
RDragger *sudoThis = static_cast<RDragger *>(d);
|
||||
auto sudoThis = static_cast<RDragger *>(d);
|
||||
sudoThis->dragFinish();
|
||||
}
|
||||
|
||||
void RDragger::fieldSensorCB(void *f, SoSensor *)
|
||||
{
|
||||
RDragger *sudoThis = static_cast<RDragger *>(f);
|
||||
auto sudoThis = static_cast<RDragger *>(f);
|
||||
|
||||
SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft
|
||||
sudoThis->workFieldsIntoTransform(matrix);
|
||||
@@ -495,7 +495,7 @@ void RDragger::fieldSensorCB(void *f, SoSensor *)
|
||||
|
||||
void RDragger::valueChangedCB(void *, SoDragger *d)
|
||||
{
|
||||
RDragger *sudoThis = dynamic_cast<RDragger *>(d);
|
||||
auto sudoThis = dynamic_cast<RDragger *>(d);
|
||||
assert(sudoThis);
|
||||
SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft
|
||||
|
||||
@@ -615,7 +615,7 @@ int RDragger::roundIncrement(const float &radiansIn)
|
||||
{
|
||||
int rCount = 0;
|
||||
|
||||
float increment = static_cast<float>(rotationIncrement.getValue());
|
||||
auto increment = static_cast<float>(rotationIncrement.getValue());
|
||||
if (fabs(radiansIn) > (increment / 2.0))
|
||||
{
|
||||
rCount = static_cast<int>(radiansIn / increment);
|
||||
@@ -758,7 +758,7 @@ SoFCCSysDragger::SoFCCSysDragger()
|
||||
|
||||
SoRotation *localRotation;
|
||||
SbRotation tempRotation;
|
||||
float angle = static_cast<float>(M_PI / 2.0);
|
||||
auto angle = static_cast<float>(M_PI / 2.0);
|
||||
localRotation = SO_GET_ANY_PART(this, "xTranslatorRotation", SoRotation);
|
||||
localRotation->rotation.setValue(SbVec3f(0.0, 0.0, -1.0), angle);
|
||||
localRotation = SO_GET_ANY_PART(this, "yTranslatorRotation", SoRotation);
|
||||
@@ -781,7 +781,7 @@ SoFCCSysDragger::SoFCCSysDragger()
|
||||
|
||||
//this is for non-autoscale mode. this will be disconnected for autoscale
|
||||
//and won't be used. see setUpAutoScale.
|
||||
SoComposeVec3f *scaleEngine = new SoComposeVec3f(); //uses coin ref scheme.
|
||||
auto scaleEngine = new SoComposeVec3f(); //uses coin ref scheme.
|
||||
scaleEngine->x.connectFrom(&draggerSize);
|
||||
scaleEngine->y.connectFrom(&draggerSize);
|
||||
scaleEngine->z.connectFrom(&draggerSize);
|
||||
@@ -868,7 +868,7 @@ SbBool SoFCCSysDragger::setUpConnections(SbBool onoff, SbBool doitalways)
|
||||
|
||||
void SoFCCSysDragger::translationSensorCB(void *f, SoSensor *)
|
||||
{
|
||||
SoFCCSysDragger *sudoThis = static_cast<SoFCCSysDragger *>(f);
|
||||
auto sudoThis = static_cast<SoFCCSysDragger *>(f);
|
||||
|
||||
SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft
|
||||
sudoThis->workFieldsIntoTransform(matrix);
|
||||
@@ -877,7 +877,7 @@ void SoFCCSysDragger::translationSensorCB(void *f, SoSensor *)
|
||||
|
||||
void SoFCCSysDragger::rotationSensorCB(void *f, SoSensor *)
|
||||
{
|
||||
SoFCCSysDragger *sudoThis = static_cast<SoFCCSysDragger *>(f);
|
||||
auto sudoThis = static_cast<SoFCCSysDragger *>(f);
|
||||
|
||||
SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft
|
||||
sudoThis->workFieldsIntoTransform(matrix);
|
||||
@@ -886,7 +886,7 @@ void SoFCCSysDragger::rotationSensorCB(void *f, SoSensor *)
|
||||
|
||||
void SoFCCSysDragger::valueChangedCB(void *, SoDragger *d)
|
||||
{
|
||||
SoFCCSysDragger *sudoThis = dynamic_cast<SoFCCSysDragger *>(d);
|
||||
auto sudoThis = dynamic_cast<SoFCCSysDragger *>(d);
|
||||
assert(sudoThis);
|
||||
SbMatrix matrix = sudoThis->getMotionMatrix(); // clazy:exclude=rule-of-two-soft
|
||||
|
||||
@@ -913,7 +913,7 @@ void SoFCCSysDragger::setUpAutoScale(SoCamera *cameraIn)
|
||||
//checking current attachment state.
|
||||
if (cameraIn->getTypeId() == SoOrthographicCamera::getClassTypeId())
|
||||
{
|
||||
SoOrthographicCamera *localCamera = dynamic_cast<SoOrthographicCamera *>(cameraIn);
|
||||
auto localCamera = dynamic_cast<SoOrthographicCamera *>(cameraIn);
|
||||
assert(localCamera);
|
||||
cameraSensor.attach(&localCamera->height);
|
||||
SoScale *localScaleNode = SO_GET_ANY_PART(this, "scaleNode", SoScale);
|
||||
@@ -923,7 +923,7 @@ void SoFCCSysDragger::setUpAutoScale(SoCamera *cameraIn)
|
||||
}
|
||||
else if (cameraIn->getTypeId() == SoPerspectiveCamera::getClassTypeId())
|
||||
{
|
||||
SoPerspectiveCamera *localCamera = dynamic_cast<SoPerspectiveCamera *>(cameraIn);
|
||||
auto localCamera = dynamic_cast<SoPerspectiveCamera *>(cameraIn);
|
||||
assert(localCamera);
|
||||
cameraSensor.attach(&localCamera->position);
|
||||
SoScale *localScaleNode = SO_GET_ANY_PART(this, "scaleNode", SoScale);
|
||||
@@ -935,7 +935,7 @@ void SoFCCSysDragger::setUpAutoScale(SoCamera *cameraIn)
|
||||
|
||||
void SoFCCSysDragger::cameraCB(void *data, SoSensor *)
|
||||
{
|
||||
SoFCCSysDragger *sudoThis = static_cast<SoFCCSysDragger *>(data);
|
||||
auto sudoThis = static_cast<SoFCCSysDragger *>(data);
|
||||
if (!sudoThis->idleSensor.isScheduled())
|
||||
sudoThis->idleSensor.schedule();
|
||||
}
|
||||
@@ -980,11 +980,11 @@ void SoFCCSysDragger::handleEvent(SoHandleEventAction * action)
|
||||
|
||||
void SoFCCSysDragger::idleCB(void *data, SoSensor *)
|
||||
{
|
||||
SoFCCSysDragger *sudoThis = static_cast<SoFCCSysDragger *>(data);
|
||||
auto sudoThis = static_cast<SoFCCSysDragger *>(data);
|
||||
SoField* field = sudoThis->cameraSensor.getAttachedField();
|
||||
if (field)
|
||||
{
|
||||
SoCamera* camera = static_cast<SoCamera*>(field->getContainer());
|
||||
auto camera = static_cast<SoCamera*>(field->getContainer());
|
||||
SbMatrix localToWorld = sudoThis->getLocalToWorldMatrix();
|
||||
SbVec3f origin;
|
||||
localToWorld.multVecMatrix(SbVec3f(0.0, 0.0, 0.0), origin);
|
||||
@@ -1003,7 +1003,7 @@ void SoFCCSysDragger::idleCB(void *data, SoSensor *)
|
||||
|
||||
void SoFCCSysDragger::finishDragCB(void *data, SoDragger *)
|
||||
{
|
||||
SoFCCSysDragger *sudoThis = static_cast<SoFCCSysDragger *>(data);
|
||||
auto sudoThis = static_cast<SoFCCSysDragger *>(data);
|
||||
|
||||
// note: when creating a second view of the document and then closing
|
||||
// the first viewer it deletes the camera. However, the attached field
|
||||
@@ -1011,7 +1011,7 @@ void SoFCCSysDragger::finishDragCB(void *data, SoDragger *)
|
||||
SoField* field = sudoThis->cameraSensor.getAttachedField();
|
||||
if (field)
|
||||
{
|
||||
SoCamera* camera = static_cast<SoCamera*>(field->getContainer());
|
||||
auto camera = static_cast<SoCamera*>(field->getContainer());
|
||||
if (camera->getTypeId() == SoPerspectiveCamera::getClassTypeId())
|
||||
cameraCB(sudoThis, nullptr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user