MOD: TECHDRAW (Removed unused functions)
Unused functions removed.
This commit is contained in:
@@ -70,26 +70,6 @@ TechDraw::DrawView* CommandHelpers::firstViewInSelection(Gui::Command* cmd)
|
||||
return baseView;
|
||||
}
|
||||
|
||||
//! find the first DrawView in the current selection for use as a base view (owner)
|
||||
TechDraw::DrawView* CommandHelpers::firstNonSpreadsheetInSelection(Gui::Command* cmd)
|
||||
{
|
||||
std::vector<Gui::SelectionObject> selection = cmd->getSelection().getSelectionEx();
|
||||
TechDraw::DrawView* baseView{nullptr};
|
||||
if (!selection.empty()) {
|
||||
for (auto& selobj : selection) {
|
||||
if (selobj.getObject()->isDerivedFrom<DrawViewSpreadsheet>()) {
|
||||
continue;
|
||||
} else {
|
||||
auto docobj = selobj.getObject();
|
||||
baseView = static_cast<TechDraw::DrawView *>(docobj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return baseView;
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> CommandHelpers::getSelectedSubElements(Gui::Command* cmd,
|
||||
TechDraw::DrawViewPart* &dvp,
|
||||
std::string subType)
|
||||
@@ -129,83 +109,6 @@ std::vector<std::string> CommandHelpers::getSelectedSubElements(Gui::Command* cm
|
||||
return selectedSubs;
|
||||
}
|
||||
|
||||
//! extract the selected shapes and xShapes and determine if a face has been
|
||||
//! selected to define the projection direction
|
||||
void CommandHelpers::getSelectedShapes(Gui::Command* cmd,
|
||||
std::vector<App::DocumentObject*>& shapes,
|
||||
std::vector<App::DocumentObject*>& xShapes,
|
||||
App::DocumentObject* faceObj,
|
||||
std::string& faceName)
|
||||
{
|
||||
auto resolve = Gui::ResolveMode::OldStyleElement;
|
||||
bool single = false;
|
||||
auto selection = cmd->getSelection().getSelectionEx(nullptr, App::DocumentObject::getClassTypeId(),
|
||||
resolve, single);
|
||||
for (auto& sel : selection) {
|
||||
bool is_linked = false;
|
||||
auto obj = sel.getObject();
|
||||
if (obj->isDerivedFrom<TechDraw::DrawPage>()) {
|
||||
continue;
|
||||
}
|
||||
if (obj->isDerivedFrom<App::LinkElement>()
|
||||
|| obj->isDerivedFrom<App::LinkGroup>()
|
||||
|| obj->isDerivedFrom<App::Link>()) {
|
||||
is_linked = true;
|
||||
}
|
||||
// If parent of the obj is a link to another document, we possibly need to treat non-link obj as linked, too
|
||||
// 1st, is obj in another document?
|
||||
if (obj->getDocument() != cmd->getDocument()) {
|
||||
std::set<App::DocumentObject*> parents = obj->getInListEx(true);
|
||||
for (auto& parent : parents) {
|
||||
// Only consider parents in the current document, i.e. possible links in this View's document
|
||||
if (parent->getDocument() != cmd->getDocument()) {
|
||||
continue;
|
||||
}
|
||||
// 2nd, do we really have a link to obj?
|
||||
if (parent->isDerivedFrom<App::LinkElement>()
|
||||
|| parent->isDerivedFrom<App::LinkGroup>()
|
||||
|| parent->isDerivedFrom<App::Link>()) {
|
||||
// We have a link chain from this document to obj, and obj is in another document -> it is an XLink target
|
||||
is_linked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_linked) {
|
||||
xShapes.push_back(obj);
|
||||
continue;
|
||||
}
|
||||
//not a Link and not null. assume to be drawable. Undrawables will be
|
||||
// skipped later.
|
||||
shapes.push_back(obj);
|
||||
if (faceObj) {
|
||||
continue;
|
||||
}
|
||||
//don't know if this works for an XLink
|
||||
for (auto& sub : sel.getSubNames()) {
|
||||
if (TechDraw::DrawUtil::getGeomTypeFromName(sub) == "Face") {
|
||||
faceName = sub;
|
||||
//
|
||||
faceObj = obj;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::pair<Base::Vector3d, Base::Vector3d> CommandHelpers::viewDirection()
|
||||
{
|
||||
if (!Preferences::useCameraDirection()) {
|
||||
return { Base::Vector3d(0, -1, 0), Base::Vector3d(1, 0, 0) };
|
||||
}
|
||||
|
||||
auto faceInfo = faceFromSelection();
|
||||
if (faceInfo.first) {
|
||||
return DrawGuiUtil::getProjDirFromFace(faceInfo.first, faceInfo.second);
|
||||
}
|
||||
|
||||
return DrawGuiUtil::get3DDirAndRot();
|
||||
}
|
||||
|
||||
std::pair<App::DocumentObject*, std::string> CommandHelpers::faceFromSelection()
|
||||
{
|
||||
|
||||
@@ -47,7 +47,6 @@ class DrawView;
|
||||
class DrawViewPart;
|
||||
|
||||
namespace CommandHelpers {
|
||||
|
||||
TechDraw::DrawView* firstViewInSelection(Gui::Command* cmd);
|
||||
TechDraw::DrawView* firstNonSpreadsheetInSelection(Gui::Command* cmd);
|
||||
|
||||
@@ -55,14 +54,8 @@ std::vector<std::string> getSelectedSubElements(Gui::Command* cmd,
|
||||
TechDraw::DrawViewPart* &dvp,
|
||||
std::string subType = "Edge");
|
||||
|
||||
void getSelectedShapes(Gui::Command* cmd,
|
||||
std::vector<App::DocumentObject*>& shapes,
|
||||
std::vector<App::DocumentObject*>& xShapes,
|
||||
App::DocumentObject* faceObj,
|
||||
std::string& faceName);
|
||||
|
||||
std::pair<App::DocumentObject*, std::string> faceFromSelection();
|
||||
std::pair<Base::Vector3d, Base::Vector3d> viewDirection();
|
||||
|
||||
|
||||
} // end namespace CommandHelpers
|
||||
|
||||
@@ -115,37 +115,6 @@ QGraphicsPathItem* PATPathMaker::simpleLine(TechDraw::BaseGeomPtr base)
|
||||
}
|
||||
|
||||
|
||||
//! make a fragment (length = remain) of a dashed line, with pattern starting at +offset
|
||||
QGraphicsPathItem* PATPathMaker::geomToStubbyLine(TechDraw::BaseGeomPtr base, double remain, LineSet& ls)
|
||||
{
|
||||
QGraphicsPathItem* fillItem = new QGraphicsPathItem(m_parent);
|
||||
Base::Vector3d start(base->getStartPoint().x,
|
||||
base->getStartPoint().y,
|
||||
0.0);
|
||||
Base::Vector3d end(base->getEndPoint().x,
|
||||
base->getEndPoint().y,
|
||||
0.0);
|
||||
double origLen = (end - start).Length();
|
||||
|
||||
double appRemain = Rez::appX(remain);
|
||||
Base::Vector3d newEnd = start + (ls.getUnitDir() * appRemain);
|
||||
|
||||
double newLen = (newEnd - start).Length();
|
||||
|
||||
if (newLen > origLen) {
|
||||
newEnd = end;
|
||||
}
|
||||
|
||||
double offset = Rez::guiX(m_fillScale * ls.getDashSpec().length()) - remain;
|
||||
|
||||
fillItem->setPath(dashedPPath(offsetDash(decodeDashSpec(ls.getDashSpec()), offset),
|
||||
Rez::guiX(start),
|
||||
Rez::guiX(newEnd)));
|
||||
m_fillItems.push_back(fillItem);
|
||||
return fillItem;
|
||||
}
|
||||
|
||||
|
||||
//! convert from mm to scene units
|
||||
std::vector<double> PATPathMaker::decodeDashSpec(DashSpec patDash)
|
||||
{
|
||||
@@ -257,18 +226,3 @@ std::vector<double> PATPathMaker::offsetDash(const std::vector<double> dashPatte
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//! find remaining length of a dash pattern after offset
|
||||
double PATPathMaker::dashRemain(const std::vector<double> dashPattern, const double offset)
|
||||
{
|
||||
double length = 0.0;
|
||||
for (auto& d: dashPattern) {
|
||||
length += fabs(d);
|
||||
}
|
||||
if (offset > length) {
|
||||
return 0.0;
|
||||
}
|
||||
return length - offset;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -45,17 +45,15 @@ public:
|
||||
void setPen(QPen pen) { m_pen = pen; }
|
||||
QPen getPen() { return m_pen; }
|
||||
void setParent(QGraphicsItem* parent) { m_parent = parent; }
|
||||
|
||||
|
||||
void lineSetToFillItems(TechDraw::LineSet& ls);
|
||||
|
||||
protected:
|
||||
QGraphicsPathItem* geomToLine(TechDraw::BaseGeomPtr base, TechDraw::LineSet& ls);
|
||||
QGraphicsPathItem* simpleLine(TechDraw::BaseGeomPtr base);
|
||||
QGraphicsPathItem* geomToStubbyLine(TechDraw::BaseGeomPtr base, double offset, TechDraw::LineSet& ls);
|
||||
QGraphicsPathItem* lineFromPoints(Base::Vector3d start, Base::Vector3d end, TechDraw::DashSpec ds);
|
||||
std::vector<double> offsetDash(const std::vector<double> dv, const double offset);
|
||||
QPainterPath dashedPPath(const std::vector<double> dv, const Base::Vector3d start, const Base::Vector3d end);
|
||||
double dashRemain(const std::vector<double> dv, const double offset);
|
||||
double calcOffset(TechDraw::BaseGeomPtr g, TechDraw::LineSet ls);
|
||||
std::vector<double> decodeDashSpec(TechDraw::DashSpec d);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user