On 06/07/2015 at 03:31, xxxxxxxx wrote:
Hi,
Well, I have no code relevant to this bug?, but if you mean code to test the bug? out, here you go:
case DLG_BUTTON_SET:
{
BaseDocument *doc = GetActiveDocument();
doc->StartUndo();
Float posX; this->GetFloat(DLG_EDITNUMBER_X, posX);
Float posY; this->GetFloat(DLG_EDITNUMBER_Y, posY);
Float posZ; this->GetFloat(DLG_EDITNUMBER_Z, posZ);
Vector newPosition = Vector(posX, posY, posZ);
Int32 setAxis; this->GetInt32(DLG_RADIOGROUP_AXIS_SET, setAxis);
Bool setX; this->GetBool(DLG_CHECKBOX_SET_X, setX);
Bool setY; this->GetBool(DLG_CHECKBOX_SET_Y, setY);
Bool setZ; this->GetBool(DLG_CHECKBOX_SET_Z, setZ);
Int32 modelModeSet = doc->GetMode();
....
else if (modelModeSet == Mpoints)
{
AutoAlloc<AtomArray> selection;
if (!selection)
return false;
if (doc)
{
doc->GetActiveObjects(*selection, GETACTIVEOBJECTFLAGS_0);
op = doc->GetActiveObject();
}
if (selection->GetCount() > 1)
{
Vector globalModelingAxis = doc->GetHelperAxis()->GetMg().off;
for (Int32 x = 0; x < selection->GetCount(); x++)
{
Matrix objectAxis = static_cast<BaseObject*>(selection->GetIndex(x))->GetMg();
PointObject *opPoint = static_cast<PointObject*>(selection->GetIndex(x));
if (!opPoint) return false;
Matrix modelingAxis = opPoint->GetModelingAxis(doc);
doc->AddUndo(UNDOTYPE_CHANGE, opPoint);
Vector *points = opPoint->GetPointW();
if (!points) return false;
BaseSelect *bs = opPoint->GetPointS();
if (!bs) return false;
for (Int32 y = 0; y < opPoint->GetPointCount(); y++)
{
if (bs->IsSelected(y))
{
if (setAxis == DLG_RADIOGROUP_AXIS_SET_GLOBAL)
{
Vector projection = newPosition;
if (setX == true)
projection.x = newPosition.x - globalModelingAxis.x;
if (setY == true)
projection.y = newPosition.y - globalModelingAxis.y;
if (setZ == true)
projection.z = newPosition.z - globalModelingAxis.z;
points[y] = points[y] + projection;
}
else if (setAxis == DLG_RADIOGROUP_AXIS_SET_LOCAL)
{
Vector projection = newPosition;
if (setX == true)
projection.x = newPosition.x - modelingAxis.off.x + objectAxis.off.x;
if (setY == true)
projection.y = newPosition.y - modelingAxis.off.y + objectAxis.off.y;
if (setZ == true)
projection.z = newPosition.z - modelingAxis.off.z + objectAxis.off.z;
points[y] = points[y] + projection;
}
}
}
opPoint->Message(MSG_UPDATE);
}
}
else if (selection->GetCount() == 1)
{
Matrix modelingAxis = op->GetModelingAxis(doc);
Matrix objectAxis = op->GetMg();
PointObject *opPoint = (PointObject* )op;
if (!opPoint) return false;
doc->AddUndo(UNDOTYPE_CHANGE, opPoint);
Int32 pointCount = opPoint->GetPointCount();
Vector *points = opPoint->GetPointW();
BaseSelect *bs = opPoint->GetPointS();
Int32 i;
for (i = 0; i < pointCount; i++)
{
if (bs->IsSelected(i))
{
if (setAxis == DLG_RADIOGROUP_AXIS_SET_GLOBAL)
{
Vector projection = newPosition;
if (setX == true)
projection.x = newPosition.x - modelingAxis.off.x;
if (setY == true)
projection.y = newPosition.y - modelingAxis.off.y;
if (setZ == true)
projection.z = newPosition.z - modelingAxis.off.z;
points[i] = points[i] + projection;
}
else if (setAxis == DLG_RADIOGROUP_AXIS_SET_LOCAL)
{
Vector projection = newPosition;
if (setX == true)
projection.x = newPosition.x - modelingAxis.off.x + objectAxis.off.x;
if (setY == true)
projection.y = newPosition.y - modelingAxis.off.y + objectAxis.off.y;
if (setZ == true)
projection.z = newPosition.z - modelingAxis.off.z + objectAxis.off.z;
points[i] = points[i] + projection;
}
}
op->Message(MSG_UPDATE);
}
}
else
{
MessageDialog(String("There is no object selected."));
}
}
And the relevant layout:
GroupBegin(DLG_EDITNUMBER_GROUP, BFH_LEFT, 0, 3, "", false);
AddEditNumber(DLG_EDITNUMBER_X, BFH_LEFT, 160);
AddEditNumber(DLG_EDITNUMBER_Y, BFH_LEFT, 160);
AddEditNumber(DLG_EDITNUMBER_Z, BFH_LEFT, 160);
GroupEnd();
AddSeparatorV(20);
GroupBegin(DLG_CHECKBOX_GROUP_SET, BFH_LEFT, 0, 3, "", false);
AddCheckbox(DLG_CHECKBOX_SET_X, BFH_LEFT | BFV_SCALEFIT, 0, 0, "X");
AddCheckbox(DLG_CHECKBOX_SET_Y, BFH_LEFT | BFV_SCALEFIT, 0, 0, "Y");
AddCheckbox(DLG_CHECKBOX_SET_Z, BFH_LEFT | BFV_SCALEFIT, 0, 0, "Z");
GroupEnd();
AddSeparatorV(20);
AddComboBox(DLG_RADIOGROUP_AXIS_SET, BFH_CENTER);
AddChild(DLG_RADIOGROUP_AXIS_SET, DLG_RADIOGROUP_AXIS_SET_GLOBAL, "Global");
AddChild(DLG_RADIOGROUP_AXIS_SET, DLG_RADIOGROUP_AXIS_SET_LOCAL, "Local");
AddSeparatorV(20);
AddButton(DLG_BUTTON_SET, BFH_LEFT, 0, 0, "SET");
GroupEnd();
I hope this is enough information, if not, just ask more.
Also I think this problem has nothing to do with my code, so testing it with simpler code may be easier.
Thanks in advance for your help and time!
Greetings,
Casimir Smets