[TD]fix StackTop and StackBottom
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
#include <boost/signals2/connection.hpp>
|
||||
#endif
|
||||
|
||||
#include <climits>
|
||||
|
||||
#include <App/DocumentObject.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Tools.h>
|
||||
@@ -347,40 +349,73 @@ void ViewProviderDrawingView::stackDown()
|
||||
|
||||
void ViewProviderDrawingView::stackTop()
|
||||
{
|
||||
Gui::Document* gDoc = getDocument();
|
||||
std::vector<ViewProvider*> vps = gDoc->getViewProvidersOfType(TechDrawGui::ViewProviderDrawingView::getClassTypeId());
|
||||
int maxZ = 0;
|
||||
for (auto& vp: vps) {
|
||||
ViewProviderDrawingView* vpdv = static_cast<ViewProviderDrawingView*>(vp);
|
||||
int z = vpdv->StackOrder.getValue();
|
||||
if (z > maxZ) {
|
||||
maxZ = z;
|
||||
QGIView* qView = getQView();
|
||||
if (!qView || !getViewProviderPage()) {
|
||||
//no view, nothing to stack
|
||||
return;
|
||||
}
|
||||
int maxZ = INT_MIN;
|
||||
auto parent = qView->parentItem();
|
||||
if (parent) {
|
||||
//if we have a parentItem, we have to stack within the parentItem, not within the page
|
||||
auto siblings = parent->childItems();
|
||||
for (auto& child : siblings) {
|
||||
if (child->zValue() > maxZ) {
|
||||
maxZ = child->zValue();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//if we have no parentItem, we are a top level QGIView and we need to stack
|
||||
//with respect to the other top level views on this page
|
||||
std::vector<App::DocumentObject*> peerObjects = getViewProviderPage()->claimChildren();
|
||||
Gui::Document* gDoc = getDocument();
|
||||
for (auto& peer: peerObjects) {
|
||||
auto vpPeer = gDoc->getViewProvider(peer);
|
||||
ViewProviderDrawingView* vpdv = static_cast<ViewProviderDrawingView*>(vpPeer);
|
||||
int z = vpdv->StackOrder.getValue();
|
||||
if (z > maxZ) {
|
||||
maxZ = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
StackOrder.setValue(maxZ + 1);
|
||||
QGIView* v = getQView();
|
||||
if (v) {
|
||||
v->setStack(maxZ + 1);
|
||||
}
|
||||
qView->setStack(maxZ + 1);
|
||||
}
|
||||
|
||||
void ViewProviderDrawingView::stackBottom()
|
||||
{
|
||||
Gui::Document* gDoc = getDocument();
|
||||
std::vector<ViewProvider*> vps = gDoc->getViewProvidersOfType(TechDrawGui::ViewProviderDrawingView::getClassTypeId());
|
||||
int minZ = 0;
|
||||
for (auto& vp: vps) {
|
||||
ViewProviderDrawingView* vpdv = static_cast<ViewProviderDrawingView*>(vp);
|
||||
int z = vpdv->StackOrder.getValue();
|
||||
if (z < minZ) {
|
||||
minZ = z;
|
||||
QGIView* qView = getQView();
|
||||
if (!qView || !getViewProviderPage()) {
|
||||
//no view, nothing to stack
|
||||
return;
|
||||
}
|
||||
int minZ = INT_MAX;
|
||||
auto parent = qView->parentItem();
|
||||
if (parent) {
|
||||
//if we have a parentItem, we have to stack within the parentItem, not within the page
|
||||
auto siblings = parent->childItems();
|
||||
for (auto& child : siblings) {
|
||||
if (child->zValue() < minZ) {
|
||||
minZ = child->zValue();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//TODO: need to special case DPGI or any other member of a collection
|
||||
//if we have no parentItem, we are a top level QGIView and we need to stack
|
||||
//with respect to the other top level views on this page
|
||||
std::vector<App::DocumentObject*> peerObjects = getViewProviderPage()->claimChildren();
|
||||
Gui::Document* gDoc = getDocument();
|
||||
for (auto& peer: peerObjects) {
|
||||
auto vpPeer = gDoc->getViewProvider(peer);
|
||||
ViewProviderDrawingView* vpdv = static_cast<ViewProviderDrawingView*>(vpPeer);
|
||||
int z = vpdv->StackOrder.getValue();
|
||||
if (z < minZ) {
|
||||
minZ = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
StackOrder.setValue(minZ - 1);
|
||||
QGIView* v = getQView();
|
||||
if (v) {
|
||||
v->setStack(minZ - 1);
|
||||
}
|
||||
qView->setStack(minZ - 1);
|
||||
}
|
||||
|
||||
TechDraw::DrawView* ViewProviderDrawingView::getViewObject() const
|
||||
|
||||
Reference in New Issue
Block a user