[TD]correct alignment of Section & Detail with Base
This commit is contained in:
@@ -64,11 +64,12 @@ DrawProjGroupItem::DrawProjGroupItem(void)
|
||||
{
|
||||
Type.setEnums(TypeEnums);
|
||||
ADD_PROPERTY(Type, ((long)0));
|
||||
ADD_PROPERTY_TYPE(RotationVector ,(1.0,0.0,0.0) ,"Base",App::Prop_None,"Controls rotation of item in view. ");
|
||||
ADD_PROPERTY_TYPE(RotationVector ,(1.0,0.0,0.0) ,"Base",
|
||||
App::Prop_None,"Deprecated. Use XDirection.");
|
||||
|
||||
//projection group controls these
|
||||
// Direction.setStatus(App::Property::ReadOnly,true);
|
||||
// RotationVector.setStatus(App::Property::ReadOnly,true);
|
||||
RotationVector.setStatus(App::Property::ReadOnly,true); //Use XDirection
|
||||
ScaleType.setValue("Custom");
|
||||
Scale.setStatus(App::Property::Hidden,true);
|
||||
ScaleType.setStatus(App::Property::Hidden,true);
|
||||
@@ -83,7 +84,7 @@ short DrawProjGroupItem::mustExecute() const
|
||||
short result = 0;
|
||||
if (!isRestoring()) {
|
||||
result = (Direction.isTouched() ||
|
||||
RotationVector.isTouched() ||
|
||||
XDirection.isTouched() ||
|
||||
Source.isTouched() ||
|
||||
Scale.isTouched());
|
||||
}
|
||||
@@ -135,8 +136,8 @@ App::DocumentObjectExecReturn *DrawProjGroupItem::execute(void)
|
||||
{
|
||||
// Base::Console().Message("DPGI::execute(%s)\n",Label.getValue());
|
||||
if (DrawUtil::checkParallel(Direction.getValue(),
|
||||
RotationVector.getValue())) {
|
||||
return new App::DocumentObjectExecReturn("DPGI: Direction and RotationVector are parallel");
|
||||
getXDirection())) {
|
||||
return new App::DocumentObjectExecReturn("DPGI: Direction and XDirection are parallel");
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn* ret = DrawViewPart::execute();
|
||||
@@ -201,10 +202,11 @@ gp_Ax2 DrawProjGroupItem::getViewAxis(const Base::Vector3d& pt,
|
||||
const Base::Vector3d& axis,
|
||||
const bool flip) const
|
||||
{
|
||||
Base::Console().Message("DPGI::getViewAxis - deprecated. use getProjectionCS\n");
|
||||
(void) flip;
|
||||
gp_Ax2 viewAxis;
|
||||
Base::Vector3d projDir = Direction.getValue();
|
||||
Base::Vector3d rotVec = RotationVector.getValue();
|
||||
Base::Vector3d rotVec = getXDirection();
|
||||
|
||||
// mirror projDir through XZ plane
|
||||
Base::Vector3d yNorm(0.0,1.0,0.0);
|
||||
@@ -212,7 +214,7 @@ gp_Ax2 DrawProjGroupItem::getViewAxis(const Base::Vector3d& pt,
|
||||
rotVec = rotVec - (yNorm * 2.0) * (rotVec.Dot(yNorm));
|
||||
|
||||
if (DrawUtil::checkParallel(projDir,rotVec)) {
|
||||
Base::Console().Warning("DPGI::getVA - %s - Direction and RotationVector parallel. using defaults\n",
|
||||
Base::Console().Warning("DPGI::getVA - %s - Direction and XDirection parallel. using defaults\n",
|
||||
getNameInDocument());
|
||||
}
|
||||
try {
|
||||
@@ -229,19 +231,78 @@ gp_Ax2 DrawProjGroupItem::getViewAxis(const Base::Vector3d& pt,
|
||||
return viewAxis;
|
||||
}
|
||||
|
||||
Base::Vector3d DrawProjGroupItem::getXDirection(void) const
|
||||
{
|
||||
// Base::Console().Message("DPGI::getXDirection() - %s\n", Label.getValue());
|
||||
Base::Vector3d result(1.0, 0.0, 0.0); //default X
|
||||
App::Property* prop = getPropertyByName("XDirection");
|
||||
if (prop != nullptr) {
|
||||
Base::Vector3d propVal = XDirection.getValue();
|
||||
if (DrawUtil::fpCompare(propVal.Length(), 0.0)) { //have XDirection property, but not set
|
||||
prop = getPropertyByName("RotationVector");
|
||||
if (prop != nullptr) {
|
||||
result = RotationVector.getValue(); //use RotationVector if we have it
|
||||
} else {
|
||||
result = DrawViewPart::getXDirection(); //over complex.
|
||||
}
|
||||
} else {
|
||||
result = DrawViewPart::getXDirection();
|
||||
}
|
||||
} else { //not sure this branch can actually happen
|
||||
Base::Console().Message("DPGI::getXDirection - unexpected branch taken!\n");
|
||||
prop = getPropertyByName("RotationVector");
|
||||
if (prop != nullptr) {
|
||||
result = RotationVector.getValue();
|
||||
|
||||
} else {
|
||||
Base::Console().Message("DPGI::getXDirection - missing RotationVector and XDirection\n");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d DrawProjGroupItem::getLegacyX(const Base::Vector3d& pt,
|
||||
const Base::Vector3d& axis,
|
||||
const bool flip) const
|
||||
{
|
||||
// Base::Console().Message("DPGI::getLegacyX() - %s\n", Label.getValue());
|
||||
Base::Vector3d result(1.0, 0.0, 0.0);
|
||||
App::Property* prop = getPropertyByName("RotationVector");
|
||||
if (prop != nullptr) {
|
||||
result = RotationVector.getValue();
|
||||
if (DrawUtil::fpCompare(result.Length(), 0.0)) { //have RotationVector property, but not set
|
||||
gp_Ax2 va = getViewAxis(pt,
|
||||
axis,
|
||||
flip);
|
||||
gp_Dir gXDir = va.XDirection();
|
||||
result = Base::Vector3d(gXDir.X(),
|
||||
gXDir.Y(),
|
||||
gXDir.Z());
|
||||
}
|
||||
} else {
|
||||
gp_Ax2 va = getViewAxis(pt,
|
||||
axis,
|
||||
flip);
|
||||
gp_Dir gXDir = va.XDirection();
|
||||
result = Base::Vector3d(gXDir.X(),
|
||||
gXDir.Y(),
|
||||
gXDir.Z());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//get the angle between the current RotationVector vector and the original X dir angle
|
||||
double DrawProjGroupItem::getRotateAngle()
|
||||
{
|
||||
gp_Ax2 viewAxis;
|
||||
Base::Vector3d x = RotationVector.getValue(); //current rotation
|
||||
Base::Vector3d x = getXDirection(); //current rotation
|
||||
Base::Vector3d nx = x;
|
||||
nx.Normalize();
|
||||
Base::Vector3d na = Direction.getValue();
|
||||
na.Normalize();
|
||||
Base::Vector3d org(0.0,0.0,0.0);
|
||||
|
||||
viewAxis = TechDraw::getViewAxis(org,na,true); //default orientation
|
||||
|
||||
viewAxis = getProjectionCS(org);
|
||||
gp_Dir gxDir = viewAxis.XDirection();
|
||||
Base::Vector3d origX(gxDir.X(),gxDir.Y(),gxDir.Z());
|
||||
origX.Normalize();
|
||||
|
||||
Reference in New Issue
Block a user