[TD]DPG spacing for oblique views
This commit is contained in:
@@ -663,16 +663,8 @@ Base::Vector3d DrawProjGroup::getXYPosition(const char *viewTypeCStr)
|
||||
//TODO: bounding boxes do not take view orientation into account
|
||||
// i.e. X&Y widths might be swapped on page
|
||||
|
||||
// if (AutoDistribute.getValue()) {
|
||||
if (true) {
|
||||
if (AutoDistribute.getValue()) {
|
||||
std::vector<Base::Vector3d> position(idxCount);
|
||||
int idx = 0;
|
||||
for (;idx < idxCount; idx++) {
|
||||
if (viewPtrs[idx]) {
|
||||
position[idx].x = viewPtrs[idx]->X.getValue();
|
||||
position[idx].y = viewPtrs[idx]->Y.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate bounding boxes for each displayed view
|
||||
Base::BoundBox3d bboxes[10];
|
||||
@@ -681,87 +673,136 @@ Base::Vector3d DrawProjGroup::getXYPosition(const char *viewTypeCStr)
|
||||
double xSpacing = spacingX.getValue(); //in mm, no scale
|
||||
double ySpacing = spacingY.getValue(); //in mm, no scale
|
||||
|
||||
std::vector<double> xOff;
|
||||
std::vector<double> yOff;
|
||||
double bigRow = 0.0;
|
||||
double bigCol = 0.0;
|
||||
int ibbx = 0;
|
||||
for (auto& b: bboxes) { //space based on width/height of biggest view
|
||||
if (!b.IsValid()) {
|
||||
Base::Console().Message("DVP::getXYPos - bbox %d is not valid!\n");
|
||||
continue;
|
||||
}
|
||||
double xOffset = -( (b.LengthX() / 2.0) + b.MinX ); //scaled distance to move to zero
|
||||
double yOffset = -( (b.LengthY() / 2.0) + b.MinY );
|
||||
xOff.push_back(xOffset);
|
||||
yOff.push_back(yOffset);
|
||||
if (b.LengthX() > bigCol) {
|
||||
bigCol = b.LengthX();
|
||||
}
|
||||
if (b.LengthY() > bigRow) {
|
||||
bigRow = b.LengthY();
|
||||
}
|
||||
ibbx++;
|
||||
}
|
||||
|
||||
double xOffFront = -( (bboxes[4].LengthX() / 2.0) + bboxes[4].MinX );
|
||||
double yOffFront = -( (bboxes[4].LengthY() / 2.0) + bboxes[4].MinY );
|
||||
|
||||
//if we have iso's, make sure they fit the grid.
|
||||
if (viewPtrs[0] || viewPtrs[2] || viewPtrs[7] || viewPtrs[9]) {
|
||||
bigCol = std::max(bigCol,bigRow);
|
||||
bigRow = bigCol;
|
||||
}
|
||||
//TODO: find biggest for each row/column and adjust calculation to use bigCol[i], bigRow[j] ?????
|
||||
|
||||
if (viewPtrs[0] && //iso
|
||||
bboxes[0].IsValid()) {
|
||||
position[0].x = -bigCol - xSpacing;
|
||||
position[0].y = bigRow + ySpacing;
|
||||
}
|
||||
if (viewPtrs[1] && // T/B
|
||||
bboxes[1].IsValid()) {
|
||||
position[1].x = 0.0;
|
||||
position[1].y = bigRow + ySpacing;
|
||||
}
|
||||
if (viewPtrs[2] && //iso
|
||||
bboxes[2].IsValid()) {
|
||||
position[2].x = bigCol + xSpacing;
|
||||
position[2].y = bigRow + ySpacing;
|
||||
}
|
||||
if (viewPtrs[3] && // L/R
|
||||
bboxes[3].IsValid() &&
|
||||
bboxes[4].IsValid()) {
|
||||
position[3].x = -bigCol - xSpacing;
|
||||
position[3].y = 0.0;
|
||||
}
|
||||
if (viewPtrs[4] && //Front
|
||||
bboxes[4].IsValid()) {
|
||||
position[4].x = 0.0;
|
||||
position[4].y = 0.0;
|
||||
}
|
||||
if (viewPtrs[5] && // R/L
|
||||
|
||||
if (viewPtrs[3] && // L/R (third/first)
|
||||
bboxes[3].IsValid() &&
|
||||
bboxes[4].IsValid()) {
|
||||
double netOffset = xOff[3] - xOffFront;
|
||||
double xOffBig = -(bigCol - bboxes[3].LengthX()) / 2.0;
|
||||
position[3].x = -bigCol - xSpacing + netOffset - xOffBig;
|
||||
position[3].y = 0.0;
|
||||
}
|
||||
|
||||
if (viewPtrs[5] && // R/L (third/first)
|
||||
bboxes[5].IsValid() &&
|
||||
bboxes[4].IsValid()) {
|
||||
position[5].x = bigCol + xSpacing;
|
||||
double netOffset = xOff[5] - xOffFront;
|
||||
double xOffBig = -(bigCol - bboxes[5].LengthX()) / 2.0;
|
||||
position[5].x = bigCol + xSpacing + netOffset + xOffBig;
|
||||
position[5].y = 0.0;
|
||||
}
|
||||
|
||||
if (viewPtrs[6] &&
|
||||
bboxes[6].IsValid()) { //"Rear"
|
||||
if (viewPtrs[5] &&
|
||||
bboxes[5].IsValid()) {
|
||||
position[6].x = position[5].x + bigCol + xSpacing;
|
||||
double netOffset = xOff[5] - xOff[6];
|
||||
position[6].x = position[5].x + bigCol + xSpacing - netOffset;
|
||||
position[6].y = 0.0;
|
||||
}else if (viewPtrs[4] &&
|
||||
} else if (viewPtrs[4] &&
|
||||
bboxes[4].IsValid()) {
|
||||
position[6].x = bigCol + xSpacing;
|
||||
double netOffset = xOff[6] - xOff[5];
|
||||
double xOffBig = -(bigCol - bboxes[6].LengthX()) / 2.0;
|
||||
position[6].x = bigCol + xSpacing + netOffset + xOffBig;
|
||||
position[6].y = 0.0;
|
||||
}
|
||||
}
|
||||
if (viewPtrs[7] &&
|
||||
bboxes[7].IsValid()) { //iso
|
||||
position[7].x = -bigCol - xSpacing;
|
||||
position[7].y = -bigRow - ySpacing;
|
||||
|
||||
if (viewPtrs[1] && // T/B (third/first)
|
||||
bboxes[1].IsValid() &&
|
||||
bboxes[4].IsValid()) {
|
||||
double netOffset = -yOff[1] + yOffFront;
|
||||
double yOffBig = -(bigRow - bboxes[1].LengthY()) / 2.0;
|
||||
position[1].x = 0.0;
|
||||
position[1].y = bigRow + ySpacing + netOffset + yOffBig;
|
||||
}
|
||||
if (viewPtrs[8] && // B/T
|
||||
|
||||
if (viewPtrs[8] && // B/T (third/first)
|
||||
bboxes[8].IsValid() &&
|
||||
bboxes[4].IsValid()) {
|
||||
double netOffset = -yOff[8] + yOffFront;
|
||||
double yOffBig = -(bigRow - bboxes[8].LengthY()) / 2.0;
|
||||
position[8].x = 0.0;
|
||||
position[8].y = -bigRow - ySpacing;
|
||||
position[8].y = -bigRow - ySpacing + netOffset + yOffBig;
|
||||
}
|
||||
if (viewPtrs[9] && //iso
|
||||
|
||||
if (viewPtrs[0] &&
|
||||
bboxes[0].IsValid()) {
|
||||
double netOffset = xOff[0] - xOffFront;
|
||||
double xOffBig = -(bigCol - bboxes[0].LengthX()) / 2.0;
|
||||
position[0].x = -bigCol - xSpacing + netOffset - xOffBig;
|
||||
netOffset = -yOff[0] + yOffFront;
|
||||
double yOffBig = -(bigRow - bboxes[0].LengthY()) / 2.0;
|
||||
position[0].y = bigRow + ySpacing + netOffset + yOffBig;
|
||||
}
|
||||
|
||||
if (viewPtrs[2] &&
|
||||
bboxes[2].IsValid()) {
|
||||
double netOffset = xOff[2] - xOffFront;
|
||||
double xOffBig = -(bigCol - bboxes[2].LengthX()) / 2.0;
|
||||
position[2].x = bigCol + xSpacing + netOffset + xOffBig;
|
||||
netOffset = -yOff[2] + yOffFront;
|
||||
double yOffBig = -(bigRow - bboxes[2].LengthY()) / 2.0;
|
||||
position[2].y = bigRow + ySpacing + netOffset + yOffBig;
|
||||
}
|
||||
|
||||
if (viewPtrs[7] &&
|
||||
bboxes[7].IsValid()) {
|
||||
double netOffset = xOff[7] - xOffFront;
|
||||
double xOffBig = -(bigCol - bboxes[7].LengthX()) / 2.0;
|
||||
position[7].x = - bigCol - xSpacing + netOffset - xOffBig;
|
||||
netOffset = -yOff[7] + yOffFront;
|
||||
double yOffBig = -(bigRow - bboxes[7].LengthY()) / 2.0;
|
||||
position[7].y = -bigRow - ySpacing + netOffset + yOffBig;
|
||||
}
|
||||
|
||||
if (viewPtrs[9] &&
|
||||
bboxes[9].IsValid()) {
|
||||
position[9].x = bigCol + xSpacing;
|
||||
position[9].y = -bigRow - ySpacing;
|
||||
double netOffset = xOff[9] - xOffFront;
|
||||
double xOffBig = -(bigCol - bboxes[9].LengthX()) / 2.0;
|
||||
position[9].x = bigCol + xSpacing + netOffset + xOffBig;
|
||||
netOffset = -yOff[9] + yOffFront;
|
||||
double yOffBig = -(bigRow - bboxes[9].LengthY()) / 2.0;
|
||||
position[9].y = -bigRow - ySpacing + netOffset + yOffBig;
|
||||
}
|
||||
|
||||
result.x = position[viewIndex].x;
|
||||
result.y = position[viewIndex].y;
|
||||
} else {
|
||||
@@ -918,6 +959,7 @@ void DrawProjGroup::makeViewBbs(DrawProjGroupItem *viewPtrs[10],
|
||||
bboxes[i] = empty;
|
||||
if (viewPtrs[i]) {
|
||||
bboxes[i] = viewPtrs[i]->getBoundingBox();
|
||||
// bboxes[i] = viewPtrs[i]->getBoundingBox(viewPtrs[i]->getProjectionCS(Base::Vector3d(0.0, 0.0, 0.0)));
|
||||
if (!documentScale) {
|
||||
double scale = 1.0 / viewPtrs[i]->getScale(); //convert bbx to 1:1 scale
|
||||
bboxes[i].ScaleX(scale);
|
||||
|
||||
Reference in New Issue
Block a user