TechDraw - Balloon updates
This commit is contained in:
@@ -94,7 +94,11 @@
|
||||
#include "TaskActiveView.h"
|
||||
#include "TaskDetail.h"
|
||||
#include "ViewProviderPage.h"
|
||||
#include "ViewProviderViewPart.h"
|
||||
#include "QGIViewPart.h"
|
||||
#include "Rez.h"
|
||||
|
||||
class Vertex;
|
||||
using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
using namespace std;
|
||||
@@ -801,6 +805,34 @@ bool _checkDrawViewPartBalloon(Gui::Command* cmd) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _checkDirectPlacement(const QGIViewPart *viewPart, const std::vector<std::string> &subNames, QPointF &placement)
|
||||
{
|
||||
if (subNames.size() != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string geoType = TechDraw::DrawUtil::getGeomTypeFromName(subNames[0]);
|
||||
if (geoType == "Vertex") {
|
||||
int index = TechDraw::DrawUtil::getIndexFromName(subNames[0]);
|
||||
TechDraw::Vertex *vertex = static_cast<DrawViewPart *>(viewPart->getViewObject())->getProjVertexByIndex(index);
|
||||
if (vertex) {
|
||||
placement = viewPart->mapToScene(Rez::guiX(vertex->x()), Rez::guiX(vertex->y()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (geoType == "Edge") {
|
||||
int index = TechDraw::DrawUtil::getIndexFromName(subNames[0]);
|
||||
TechDraw::BaseGeom *geo = static_cast<DrawViewPart *>(viewPart->getViewObject())->getGeomByIndex(index);
|
||||
if (geo) {
|
||||
Base::Vector3d midPoint(Rez::guiX(geo->getMidPoint()));
|
||||
placement = viewPart->mapToScene(midPoint.x, midPoint.y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdTechDrawBalloon)
|
||||
|
||||
CmdTechDrawBalloon::CmdTechDrawBalloon()
|
||||
@@ -826,6 +858,7 @@ void CmdTechDrawBalloon::activated(int iMsg)
|
||||
return;
|
||||
|
||||
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
|
||||
|
||||
auto objFeat( dynamic_cast<TechDraw::DrawViewPart *>(selection[0].getObject()) );
|
||||
if( objFeat == nullptr ) {
|
||||
return;
|
||||
@@ -833,10 +866,25 @@ void CmdTechDrawBalloon::activated(int iMsg)
|
||||
|
||||
TechDraw::DrawPage* page = objFeat->findParentPage();
|
||||
std::string PageName = page->getNameInDocument();
|
||||
|
||||
page->balloonParent = objFeat;
|
||||
page->balloonPlacing = true;
|
||||
|
||||
page->balloonParent = objFeat;
|
||||
|
||||
Gui::Document *guiDoc = Gui::Application::Instance->getDocument(page->getDocument());
|
||||
ViewProviderPage *pageVP = dynamic_cast<ViewProviderPage *>(guiDoc->getViewProvider(page));
|
||||
ViewProviderViewPart *partVP = dynamic_cast<ViewProviderViewPart *>(guiDoc->getViewProvider(objFeat));
|
||||
|
||||
if (pageVP && partVP) {
|
||||
QGVPage *viewPage = pageVP->getGraphicsView();
|
||||
if (viewPage) {
|
||||
viewPage->startBalloonPlacing();
|
||||
|
||||
QGIViewPart *viewPart = dynamic_cast<QGIViewPart *>(partVP->getQView());
|
||||
QPointF placement;
|
||||
if (viewPart && _checkDirectPlacement(viewPart, selection[0].getSubNames(), placement)) {
|
||||
viewPage->createBalloon(placement, objFeat);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CmdTechDrawBalloon::isActive(void)
|
||||
|
||||
Reference in New Issue
Block a user