[TechDraw] Simplify return logic
Normal warmup
This commit is contained in:
committed by
WandererFan
parent
6df0a20214
commit
a93060c6b9
@@ -85,16 +85,14 @@ std::string CosmeticExtension::addCosmeticVertex(Base::Vector3d pos)
|
||||
TechDraw::CosmeticVertex* CosmeticExtension::getCosmeticVertex(std::string tagString) const
|
||||
{
|
||||
// Base::Console().Message("CEx::getCosmeticVertex(%s)\n", tagString.c_str());
|
||||
CosmeticVertex* result = nullptr;
|
||||
const std::vector<TechDraw::CosmeticVertex*> verts = CosmeticVertexes.getValues();
|
||||
for (auto& cv: verts) {
|
||||
std::string cvTag = cv->getTagAsString();
|
||||
if (cvTag == tagString) {
|
||||
result = cv;
|
||||
break;
|
||||
return cv;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// find the cosmetic vertex corresponding to selection name (Vertex5)
|
||||
@@ -102,18 +100,17 @@ TechDraw::CosmeticVertex* CosmeticExtension::getCosmeticVertex(std::string tagSt
|
||||
TechDraw::CosmeticVertex* CosmeticExtension::getCosmeticVertexBySelection(std::string name) const
|
||||
{
|
||||
// Base::Console().Message("CEx::getCVBySelection(%s)\n", name.c_str());
|
||||
CosmeticVertex* result = nullptr;
|
||||
App::DocumentObject* extObj = const_cast<App::DocumentObject*> (getExtendedObject());
|
||||
TechDraw::DrawViewPart* dvp = dynamic_cast<TechDraw::DrawViewPart*>(extObj);
|
||||
if (!dvp)
|
||||
return result;
|
||||
if (!dvp) {
|
||||
return nullptr;
|
||||
}
|
||||
int idx = DrawUtil::getIndexFromName(name);
|
||||
TechDraw::VertexPtr v = dvp->getProjVertexByIndex(idx);
|
||||
if (!v)
|
||||
return result;
|
||||
if (!v->getCosmeticTag().empty())
|
||||
result = getCosmeticVertex(v->getCosmeticTag());
|
||||
return result;
|
||||
if (!v || v->getCosmeticTag().empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
return getCosmeticVertex(v->getCosmeticTag());
|
||||
}
|
||||
|
||||
//overload for index only
|
||||
@@ -175,21 +172,17 @@ std::string CosmeticExtension::addCosmeticEdge(TechDraw::BaseGeomPtr bg)
|
||||
TechDraw::CosmeticEdge* CosmeticExtension::getCosmeticEdge(std::string tagString) const
|
||||
{
|
||||
// Base::Console().Message("CEx::getCosmeticEdge(%s)\n", tagString.c_str());
|
||||
CosmeticEdge* result = nullptr;
|
||||
bool found = false;
|
||||
const std::vector<TechDraw::CosmeticEdge*> edges = CosmeticEdges.getValues();
|
||||
for (auto& ce: edges) {
|
||||
std::string ceTag = ce->getTagAsString();
|
||||
if (ceTag == tagString) {
|
||||
result = ce;
|
||||
found = true;
|
||||
break;
|
||||
return ce;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
Base::Console().Message("CEx::getCosmeticEdge - CE for tag: %s not found.\n", tagString.c_str());
|
||||
}
|
||||
return result;
|
||||
|
||||
// None found
|
||||
Base::Console().Message("CEx::getCosmeticEdge - CE for tag: %s not found.\n", tagString.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// find the cosmetic edge corresponding to selection name (Edge5)
|
||||
@@ -197,29 +190,27 @@ TechDraw::CosmeticEdge* CosmeticExtension::getCosmeticEdge(std::string tagString
|
||||
TechDraw::CosmeticEdge* CosmeticExtension::getCosmeticEdgeBySelection(std::string name) const
|
||||
{
|
||||
// Base::Console().Message("CEx::getCEBySelection(%s)\n", name.c_str());
|
||||
CosmeticEdge* result = nullptr;
|
||||
App::DocumentObject* extObj = const_cast<App::DocumentObject*> (getExtendedObject());
|
||||
TechDraw::DrawViewPart* dvp = dynamic_cast<TechDraw::DrawViewPart*>(extObj);
|
||||
if (!dvp)
|
||||
return result;
|
||||
if (!dvp) {
|
||||
return nullptr;
|
||||
}
|
||||
int idx = DrawUtil::getIndexFromName(name);
|
||||
TechDraw::BaseGeomPtr base = dvp->getGeomByIndex(idx);
|
||||
if (!base)
|
||||
return result;
|
||||
if (!base || base->getCosmeticTag().empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!base->getCosmeticTag().empty())
|
||||
result = getCosmeticEdge(base->getCosmeticTag());
|
||||
return result;
|
||||
return getCosmeticEdge(base->getCosmeticTag());
|
||||
}
|
||||
|
||||
//overload for index only
|
||||
TechDraw::CosmeticEdge* CosmeticExtension::getCosmeticEdgeBySelection(int i) const
|
||||
{
|
||||
// Base::Console().Message("CEx::getCEBySelection(%d)\n", i);
|
||||
std::stringstream ss;
|
||||
ss << "Edge" << i;
|
||||
std::string eName = ss.str();
|
||||
return getCosmeticEdgeBySelection(eName);
|
||||
std::stringstream edgeName;
|
||||
edgeName << "Edge" << i;
|
||||
return getCosmeticEdgeBySelection(edgeName.str());
|
||||
}
|
||||
|
||||
void CosmeticExtension::removeCosmeticEdge(std::string delTag)
|
||||
@@ -284,16 +275,14 @@ std::string CosmeticExtension::addCenterLine(TechDraw::BaseGeomPtr bg)
|
||||
TechDraw::CenterLine* CosmeticExtension::getCenterLine(std::string tagString) const
|
||||
{
|
||||
// Base::Console().Message("CEx::getCenterLine(%s)\n", tagString.c_str());
|
||||
CenterLine* result = nullptr;
|
||||
const std::vector<TechDraw::CenterLine*> cLines = CenterLines.getValues();
|
||||
for (auto& cl: cLines) {
|
||||
std::string clTag = cl->getTagAsString();
|
||||
if (clTag == tagString) {
|
||||
result = cl;
|
||||
break;
|
||||
return cl;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// find the center line corresponding to selection name (Edge5)
|
||||
@@ -301,28 +290,26 @@ TechDraw::CenterLine* CosmeticExtension::getCenterLine(std::string tagString) co
|
||||
TechDraw::CenterLine* CosmeticExtension::getCenterLineBySelection(std::string name) const
|
||||
{
|
||||
// Base::Console().Message("CEx::getCLBySelection(%s)\n", name.c_str());
|
||||
CenterLine* result = nullptr;
|
||||
App::DocumentObject* extObj = const_cast<App::DocumentObject*> (getExtendedObject());
|
||||
TechDraw::DrawViewPart* dvp = dynamic_cast<TechDraw::DrawViewPart*>(extObj);
|
||||
if (!dvp)
|
||||
return result;
|
||||
if (!dvp) {
|
||||
return nullptr;
|
||||
}
|
||||
int idx = DrawUtil::getIndexFromName(name);
|
||||
TechDraw::BaseGeomPtr base = dvp->getGeomByIndex(idx);
|
||||
if (!base)
|
||||
return result;
|
||||
if (!base->getCosmeticTag().empty())
|
||||
result = getCenterLine(base->getCosmeticTag());
|
||||
return result;
|
||||
if (!base || base->getCosmeticTag().empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
return getCenterLine(base->getCosmeticTag());
|
||||
}
|
||||
|
||||
//overload for index only
|
||||
TechDraw::CenterLine* CosmeticExtension::getCenterLineBySelection(int i) const
|
||||
{
|
||||
// Base::Console().Message("CEx::getCLBySelection(%d)\n", i);
|
||||
std::stringstream ss;
|
||||
ss << "Edge" << i;
|
||||
std::string eName = ss.str();
|
||||
return getCenterLineBySelection(eName);
|
||||
std::stringstream edgeName;
|
||||
edgeName << "Edge" << i;
|
||||
return getCenterLineBySelection(edgeName.str());
|
||||
}
|
||||
|
||||
void CosmeticExtension::removeCenterLine(std::string delTag)
|
||||
@@ -364,16 +351,16 @@ std::string CosmeticExtension::addGeomFormat(TechDraw::GeomFormat* gf)
|
||||
TechDraw::GeomFormat* CosmeticExtension::getGeomFormat(std::string tagString) const
|
||||
{
|
||||
// Base::Console().Message("CEx::getGeomFormat(%s)\n", tagString.c_str());
|
||||
GeomFormat* result = nullptr;
|
||||
const std::vector<TechDraw::GeomFormat*> formats = GeomFormats.getValues();
|
||||
for (auto& gf: formats) {
|
||||
std::string gfTag = gf->getTagAsString();
|
||||
if (gfTag == tagString) {
|
||||
result = gf;
|
||||
break;
|
||||
return gf;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
// Nothing found
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// find the cosmetic edge corresponding to selection name (Edge5)
|
||||
@@ -381,20 +368,21 @@ TechDraw::GeomFormat* CosmeticExtension::getGeomFormat(std::string tagString) co
|
||||
TechDraw::GeomFormat* CosmeticExtension::getGeomFormatBySelection(std::string name) const
|
||||
{
|
||||
// Base::Console().Message("CEx::getCEBySelection(%s)\n", name.c_str());
|
||||
GeomFormat* result = nullptr;
|
||||
App::DocumentObject* extObj = const_cast<App::DocumentObject*> (getExtendedObject());
|
||||
TechDraw::DrawViewPart* dvp = dynamic_cast<TechDraw::DrawViewPart*>(extObj);
|
||||
if (!dvp)
|
||||
return result;
|
||||
if (!dvp) {
|
||||
return nullptr;
|
||||
}
|
||||
int idx = DrawUtil::getIndexFromName(name);
|
||||
const std::vector<TechDraw::GeomFormat*> formats = GeomFormats.getValues();
|
||||
for (auto& gf: formats) {
|
||||
if (gf->m_geomIndex == idx) {
|
||||
result = gf;
|
||||
break;
|
||||
return gf;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
// Nothing found
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//overload for index only
|
||||
|
||||
@@ -97,7 +97,6 @@ bool DrawProjGroupItem::isLocked(void) const
|
||||
|
||||
bool DrawProjGroupItem::showLock(void) const
|
||||
{
|
||||
bool result = DrawView::showLock();
|
||||
DrawProjGroup* parent = getPGroup();
|
||||
bool parentLock = false;
|
||||
if (parent) {
|
||||
@@ -106,10 +105,10 @@ bool DrawProjGroupItem::showLock(void) const
|
||||
|
||||
if (isAnchor() && //don't show lock for Front if DPG is not locked
|
||||
!parentLock) {
|
||||
result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return result;
|
||||
return DrawView::showLock();
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *DrawProjGroupItem::execute(void)
|
||||
@@ -181,15 +180,14 @@ void DrawProjGroupItem::onDocumentRestored()
|
||||
|
||||
DrawProjGroup* DrawProjGroupItem::getPGroup() const
|
||||
{
|
||||
DrawProjGroup* result = nullptr;
|
||||
std::vector<App::DocumentObject*> parent = getInList();
|
||||
for (std::vector<App::DocumentObject*>::iterator it = parent.begin(); it != parent.end(); ++it) {
|
||||
if ((*it)->getTypeId().isDerivedFrom(DrawProjGroup::getClassTypeId())) {
|
||||
result = dynamic_cast<TechDraw::DrawProjGroup *>(*it);
|
||||
break;
|
||||
DrawProjGroup* result = dynamic_cast<TechDraw::DrawProjGroup *>(*it);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool DrawProjGroupItem::isAnchor(void) const
|
||||
|
||||
@@ -207,13 +207,11 @@ void DrawView::handleXYLock()
|
||||
|
||||
short DrawView::mustExecute() const
|
||||
{
|
||||
short result = 0;
|
||||
if (!isRestoring()) {
|
||||
result = (Scale.isTouched() ||
|
||||
ScaleType.isTouched());
|
||||
}
|
||||
if ((bool) result) {
|
||||
return result;
|
||||
if (Scale.isTouched() ||
|
||||
ScaleType.isTouched()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return App::DocumentObject::mustExecute();
|
||||
}
|
||||
@@ -357,16 +355,15 @@ DrawViewClip* DrawView::getClipGroup()
|
||||
{
|
||||
std::vector<App::DocumentObject*> parent = getInList();
|
||||
App::DocumentObject* obj = nullptr;
|
||||
DrawViewClip* result = nullptr;
|
||||
for (std::vector<App::DocumentObject*>::iterator it = parent.begin(); it != parent.end(); ++it) {
|
||||
if ((*it)->getTypeId().isDerivedFrom(DrawViewClip::getClassTypeId())) {
|
||||
obj = (*it);
|
||||
result = dynamic_cast<DrawViewClip*>(obj);
|
||||
break;
|
||||
DrawViewClip* result = dynamic_cast<DrawViewClip*>(obj);
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
double DrawView::autoScale() const
|
||||
|
||||
@@ -1283,13 +1283,12 @@ void DrawViewPart::unsetupObject()
|
||||
//! is this an Isometric projection?
|
||||
bool DrawViewPart::isIso() const
|
||||
{
|
||||
bool result = false;
|
||||
Base::Vector3d dir = Direction.getValue();
|
||||
if (DrawUtil::fpCompare(fabs(dir.x), fabs(dir.y))
|
||||
&& DrawUtil::fpCompare(fabs(dir.x), fabs(dir.z))) {
|
||||
result = true;
|
||||
return true;
|
||||
}
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DrawViewPart::checkXDirection() const
|
||||
|
||||
@@ -1066,22 +1066,22 @@ TopoDS_Face DrawViewSection::getSectionTopoDSFace(int i)
|
||||
|
||||
TechDraw::DrawViewPart* DrawViewSection::getBaseDVP() const
|
||||
{
|
||||
TechDraw::DrawViewPart* baseDVP = nullptr;
|
||||
App::DocumentObject* base = BaseView.getValue();
|
||||
if (base && base->getTypeId().isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
|
||||
baseDVP = static_cast<TechDraw::DrawViewPart*>(base);
|
||||
TechDraw::DrawViewPart* baseDVP = static_cast<TechDraw::DrawViewPart*>(base);
|
||||
return baseDVP;
|
||||
}
|
||||
return baseDVP;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TechDraw::DrawProjGroupItem* DrawViewSection::getBaseDPGI() const
|
||||
{
|
||||
TechDraw::DrawProjGroupItem* baseDPGI = nullptr;
|
||||
App::DocumentObject* base = BaseView.getValue();
|
||||
if (base && base->getTypeId().isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) {
|
||||
baseDPGI = static_cast<TechDraw::DrawProjGroupItem*>(base);
|
||||
TechDraw::DrawProjGroupItem* baseDPGI = static_cast<TechDraw::DrawProjGroupItem*>(base);
|
||||
return baseDPGI;
|
||||
}
|
||||
return baseDPGI;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// setup / tear down routines
|
||||
|
||||
@@ -290,10 +290,8 @@ void GeometryObject::makeTDGeometry()
|
||||
//mirror a shape thru XZ plane for Qt's inverted Y coordinate
|
||||
TopoDS_Shape GeometryObject::invertGeometry(const TopoDS_Shape s)
|
||||
{
|
||||
TopoDS_Shape result;
|
||||
if (s.IsNull()) {
|
||||
result = s;
|
||||
return result;
|
||||
return s;
|
||||
}
|
||||
|
||||
gp_Trsf mirrorY;
|
||||
@@ -302,8 +300,7 @@ TopoDS_Shape GeometryObject::invertGeometry(const TopoDS_Shape s)
|
||||
gp_Ax2 mirrorPlane(org, Y);
|
||||
mirrorY.SetMirror(mirrorPlane);
|
||||
BRepBuilderAPI_Transform mkTrf(s, mirrorY, true);
|
||||
result = mkTrf.Shape();
|
||||
return result;
|
||||
return mkTrf.Shape();
|
||||
}
|
||||
|
||||
//!set up a hidden line remover and project a shape with it
|
||||
@@ -760,14 +757,11 @@ void GeometryObject::addFaceGeom(FacePtr f) { faceGeom.push_back(f); }
|
||||
|
||||
TechDraw::DrawViewDetail* GeometryObject::isParentDetail()
|
||||
{
|
||||
TechDraw::DrawViewDetail* result = nullptr;
|
||||
if (m_parent) {
|
||||
TechDraw::DrawViewDetail* detail = dynamic_cast<TechDraw::DrawViewDetail*>(m_parent);
|
||||
if (detail) {
|
||||
result = detail;
|
||||
}
|
||||
if (!m_parent) {
|
||||
return nullptr;
|
||||
}
|
||||
return result;
|
||||
TechDraw::DrawViewDetail* detail = dynamic_cast<TechDraw::DrawViewDetail*>(m_parent);
|
||||
return detail;
|
||||
}
|
||||
|
||||
|
||||
@@ -851,16 +845,14 @@ void GeometryObject::pruneVertexGeom(Base::Vector3d center, double radius)
|
||||
//! does this GeometryObject already have this vertex
|
||||
bool GeometryObject::findVertex(Base::Vector3d v)
|
||||
{
|
||||
bool found = false;
|
||||
std::vector<VertexPtr>::iterator it = vertexGeom.begin();
|
||||
for (; it != vertexGeom.end(); it++) {
|
||||
double dist = (v - (*it)->point()).Length();
|
||||
if (dist < Precision::Confusion()) {
|
||||
found = true;
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// utility non-class member functions
|
||||
@@ -904,10 +896,9 @@ gp_Ax2 TechDraw::getViewAxis(const Base::Vector3d origin, const Base::Vector3d&
|
||||
// Base::Console().Message("GO::getViewAxis() - 2\n");
|
||||
(void)flip;
|
||||
gp_Pnt inputCenter(origin.x, origin.y, origin.z);
|
||||
gp_Ax2 viewAxis;
|
||||
viewAxis = gp_Ax2(inputCenter, gp_Dir(direction.x, direction.y, direction.z),
|
||||
gp_Dir(xAxis.x, xAxis.y, xAxis.z));
|
||||
return viewAxis;
|
||||
return gp_Ax2(inputCenter,
|
||||
gp_Dir(direction.x, direction.y, direction.z),
|
||||
gp_Dir(xAxis.x, xAxis.y, xAxis.z));
|
||||
}
|
||||
|
||||
// was getViewAxis 1
|
||||
@@ -916,7 +907,6 @@ gp_Ax2 TechDraw::legacyViewAxis1(const Base::Vector3d origin, const Base::Vector
|
||||
const bool flip)
|
||||
{
|
||||
// Base::Console().Message("GO::legacyViewAxis1()\n");
|
||||
gp_Ax2 viewAxis;
|
||||
gp_Pnt inputCenter(origin.x, origin.y, origin.z);
|
||||
Base::Vector3d stdZ(0.0, 0.0, 1.0);
|
||||
Base::Vector3d stdOrg(0.0, 0.0, 0.0);
|
||||
@@ -935,12 +925,12 @@ gp_Ax2 TechDraw::legacyViewAxis1(const Base::Vector3d origin, const Base::Vector
|
||||
}
|
||||
|
||||
if (cross.IsEqual(stdOrg, FLT_EPSILON)) {
|
||||
viewAxis = gp_Ax2(inputCenter, gp_Dir(flipDirection.x, flipDirection.y, flipDirection.z));
|
||||
return viewAxis;
|
||||
return gp_Ax2(inputCenter, gp_Dir(flipDirection.x, flipDirection.y, flipDirection.z));
|
||||
}
|
||||
|
||||
viewAxis = gp_Ax2(inputCenter, gp_Dir(flipDirection.x, flipDirection.y, flipDirection.z),
|
||||
gp_Dir(cross.x, cross.y, cross.z));
|
||||
gp_Ax2 viewAxis = gp_Ax2(inputCenter,
|
||||
gp_Dir(flipDirection.x, flipDirection.y, flipDirection.z),
|
||||
gp_Dir(cross.x, cross.y, cross.z));
|
||||
|
||||
//this bit is to handle the old mirror Y logic, but it messes up
|
||||
//some old files.
|
||||
|
||||
@@ -298,26 +298,24 @@ void PATLineSpec::dump(const char* title)
|
||||
//static class methods
|
||||
std::vector<PATLineSpec> PATLineSpec::getSpecsForPattern(std::string& parmFile, std::string& parmName)
|
||||
{
|
||||
std::vector<PATLineSpec> result;
|
||||
std::vector<std::string> lineSpecs;
|
||||
Base::FileInfo fi(parmFile);
|
||||
Base::ifstream inFile;
|
||||
inFile.open (fi, std::ifstream::in);
|
||||
inFile.open(fi, std::ifstream::in);
|
||||
if(!inFile.is_open()) {
|
||||
Base::Console().Message( "Cannot open input file.\n");
|
||||
return result;
|
||||
Base::Console().Message("Cannot open input file.\n");
|
||||
return std::vector<PATLineSpec>();
|
||||
}
|
||||
|
||||
//get all the definition lines for this pattern
|
||||
bool status = findPatternStart(inFile, parmName);
|
||||
if (status) {
|
||||
lineSpecs = loadPatternDef(inFile);
|
||||
} else {
|
||||
//this can come up when changing PAT file or pattern name
|
||||
return result;
|
||||
if (!status) { // This can come up when changing PAT file or pattern name
|
||||
return std::vector<PATLineSpec>();
|
||||
}
|
||||
lineSpecs = loadPatternDef(inFile);
|
||||
|
||||
//decode definition lines into PATLineSpec objects
|
||||
std::vector<PATLineSpec> result;
|
||||
for (auto& l: lineSpecs) {
|
||||
PATLineSpec hl(l);
|
||||
result.push_back(hl);
|
||||
@@ -328,16 +326,15 @@ std::vector<PATLineSpec> PATLineSpec::getSpecsForPattern(std::string& parmFile,
|
||||
bool PATLineSpec::findPatternStart(std::ifstream& inFile, std::string& parmName)
|
||||
{
|
||||
// Base::Console().Message("HL::findPatternStart() - parmName: %s\n", parmName.c_str());
|
||||
bool result = false;
|
||||
while ( inFile.good() ){
|
||||
while (inFile.good() ){
|
||||
std::string line;
|
||||
std::getline(inFile, line);
|
||||
std::string nameTag = line.substr(0, 1);
|
||||
std::string patternName;
|
||||
std::size_t commaPos;
|
||||
if ((nameTag == ";") ||
|
||||
(nameTag == " ") ||
|
||||
(line.empty()) ) { //is cr/lf empty?
|
||||
if (nameTag == ";" ||
|
||||
nameTag == " " ||
|
||||
line.empty()) { //is cr/lf empty?
|
||||
continue;
|
||||
} else if (nameTag == "*") {
|
||||
commaPos = line.find(',',1);
|
||||
@@ -348,12 +345,11 @@ bool PATLineSpec::findPatternStart(std::ifstream& inFile, std::string& parmName
|
||||
}
|
||||
if (patternName == parmName) {
|
||||
//this is our pattern
|
||||
result = true;
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} //endwhile
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
//get the definition lines for this pattern
|
||||
|
||||
@@ -91,7 +91,6 @@ std::vector<TopoDS_Shape> ShapeExtractor::getShapes2d(const std::vector<App::Doc
|
||||
TopoDS_Shape ShapeExtractor::getShapes(const std::vector<App::DocumentObject*> links)
|
||||
{
|
||||
// Base::Console().Message("SE::getShapes() - links in: %d\n", links.size());
|
||||
TopoDS_Shape result;
|
||||
std::vector<TopoDS_Shape> sourceShapes;
|
||||
|
||||
for (auto& l:links) {
|
||||
@@ -125,25 +124,22 @@ TopoDS_Shape ShapeExtractor::getShapes(const std::vector<App::DocumentObject*> l
|
||||
TopoDS_Shape cleanShape = stripInfiniteShapes(s);
|
||||
if (!cleanShape.IsNull()) {
|
||||
builder.Add(comp, cleanShape);
|
||||
found = true;
|
||||
return comp;
|
||||
}
|
||||
} else if (Part::TopoShape(s).isInfinite()) {
|
||||
continue; //simple shape is infinite
|
||||
} else {
|
||||
//a simple shape - add to compound
|
||||
builder.Add(comp, s);
|
||||
found = true;
|
||||
return comp;
|
||||
}
|
||||
}
|
||||
//it appears that an empty compound is !IsNull(), so we need to check a different way
|
||||
//if we added anything to the compound.
|
||||
if (!found) {
|
||||
Base::Console().Error("ShapeExtractor failed to get shape.\n");
|
||||
} else {
|
||||
result = comp;
|
||||
}
|
||||
//Nothing found
|
||||
Base::Console().Error("ShapeExtractor failed to get shape.\n");
|
||||
// BRepTools::Write(result, "SEresult.brep"); //debug
|
||||
return result;
|
||||
return TopoDS_Shape();
|
||||
}
|
||||
|
||||
std::vector<TopoDS_Shape> ShapeExtractor::getXShapes(const App::Link* xLink)
|
||||
@@ -368,40 +364,37 @@ bool ShapeExtractor::isEdgeType(App::DocumentObject* obj)
|
||||
bool ShapeExtractor::isPointType(App::DocumentObject* obj)
|
||||
{
|
||||
// Base::Console().Message("SE::isPointType(%s)\n", obj->getNameInDocument());
|
||||
bool result = false;
|
||||
if (obj) {
|
||||
Base::Type t = obj->getTypeId();
|
||||
if (t.isDerivedFrom(Part::Vertex::getClassTypeId())) {
|
||||
result = true;
|
||||
return true;
|
||||
} else if (isDraftPoint(obj)) {
|
||||
result = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ShapeExtractor::isDraftPoint(App::DocumentObject* obj)
|
||||
{
|
||||
// Base::Console().Message("SE::isDraftPoint()\n");
|
||||
bool result = false;
|
||||
//if the docObj doesn't have a Proxy property, it definitely isn't a Draft point
|
||||
App::PropertyPythonObject* proxy = dynamic_cast<App::PropertyPythonObject*>(obj->getPropertyByName("Proxy"));
|
||||
if (proxy) {
|
||||
std::string pp = proxy->toString();
|
||||
// Base::Console().Message("SE::isDraftPoint - pp: %s\n", pp.c_str());
|
||||
if (pp.find("Point") != std::string::npos) {
|
||||
result = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
Base::Vector3d ShapeExtractor::getLocation3dFromFeat(App::DocumentObject* obj)
|
||||
{
|
||||
// Base::Console().Message("SE::getLocation3dFromFeat()\n");
|
||||
Base::Vector3d result(0.0, 0.0, 0.0);
|
||||
if (!isPointType(obj)) {
|
||||
return result;
|
||||
return Base::Vector3d(0.0, 0.0, 0.0);
|
||||
}
|
||||
// if (isDraftPoint(obj) {
|
||||
// //Draft Points are not necc. Part::PartFeature??
|
||||
@@ -414,13 +407,13 @@ Base::Vector3d ShapeExtractor::getLocation3dFromFeat(App::DocumentObject* obj)
|
||||
TopoDS_Shape ts = pts.getShape();
|
||||
if (ts.ShapeType() == TopAbs_VERTEX) {
|
||||
TopoDS_Vertex v = TopoDS::Vertex(ts);
|
||||
result = DrawUtil::vertex2Vector(v);
|
||||
return DrawUtil::vertex2Vector(v);
|
||||
}
|
||||
}
|
||||
|
||||
// Base::Console().Message("SE::getLocation3dFromFeat - returns: %s\n",
|
||||
// DrawUtil::formatVector(result).c_str());
|
||||
return result;
|
||||
return Base::Vector3d(0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
bool ShapeExtractor::prefAdd2d()
|
||||
|
||||
@@ -82,13 +82,12 @@ void DlgPageChooser::fillList(std::vector<std::string> labels, std::vector<std::
|
||||
|
||||
std::string DlgPageChooser::getSelection() const
|
||||
{
|
||||
std::string result;
|
||||
QList<QListWidgetItem*> sels = ui->lwPages->selectedItems();
|
||||
if (!sels.empty()) {
|
||||
QListWidgetItem* item = sels.front();
|
||||
result = item->data(Qt::UserRole).toByteArray().constData();
|
||||
return item->data(Qt::UserRole).toByteArray().constData();
|
||||
}
|
||||
return result;
|
||||
return std::string();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -317,35 +317,24 @@ double QGIArrow::getOverlapAdjust(int style, double size)
|
||||
// open circle sb = radius
|
||||
// NOTE: this may need to be adjusted to account for line thickness too.
|
||||
// Base::Console().Message("QGIA::getOverlapAdjust(%d, %.3f) \n", style, size);
|
||||
double result = 1.0;
|
||||
switch(style) {
|
||||
case FILLED_ARROW:
|
||||
result = 0.50 * size;
|
||||
break;
|
||||
return 0.50 * size;
|
||||
case OPEN_ARROW:
|
||||
result = 0.10 * size;
|
||||
break;
|
||||
return 0.10 * size;
|
||||
case TICK:
|
||||
result = 0.0;
|
||||
break;
|
||||
return 0.0;
|
||||
case DOT:
|
||||
result = 0.0;
|
||||
break;
|
||||
return 0.0;
|
||||
case OPEN_CIRCLE:
|
||||
//diameter is size/2 so radius is size/4
|
||||
result = 0.25 * size;
|
||||
break;
|
||||
return 0.25 * size;
|
||||
case FORK:
|
||||
result = 0.0;
|
||||
break;
|
||||
return 0.0;
|
||||
case FILLED_TRIANGLE:
|
||||
result = size;
|
||||
break;
|
||||
return size;
|
||||
case NONE:
|
||||
result = 0.0;
|
||||
break;
|
||||
default: //unknown
|
||||
result = 1.0;
|
||||
return 0.0;
|
||||
}
|
||||
return result;
|
||||
return 1.0; // Unknown
|
||||
}
|
||||
|
||||
@@ -456,17 +456,14 @@ std::vector<double> QGIFace::offsetDash(const std::vector<double> dv, const doub
|
||||
//! find remaining length of a dash pattern after offset
|
||||
double QGIFace::dashRemain(const std::vector<double> dv, const double offset)
|
||||
{
|
||||
double result;
|
||||
double length = 0.0;
|
||||
for (auto& d: dv) {
|
||||
length += fabs(d);
|
||||
}
|
||||
if (offset > length) {
|
||||
result = 0.0;
|
||||
} else {
|
||||
result = length - offset;
|
||||
return 0.0;
|
||||
}
|
||||
return result;
|
||||
return length - offset;
|
||||
}
|
||||
|
||||
//! get zoom level (scale) from QGraphicsView
|
||||
@@ -474,17 +471,16 @@ double QGIFace::dashRemain(const std::vector<double> dv, const double offset)
|
||||
double QGIFace::getXForm()
|
||||
{
|
||||
//try to keep the pattern the same when View scales
|
||||
double result = 1.0;
|
||||
auto s = scene();
|
||||
if (s) {
|
||||
auto vs = s->views(); //ptrs to views
|
||||
if (!vs.empty()) {
|
||||
auto v = vs.at(0);
|
||||
auto i = v->transform().inverted();
|
||||
result = i.m11();
|
||||
return i.m11();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
void QGIFace::clearFillItems()
|
||||
@@ -647,18 +643,17 @@ void QGIFace::buildPixHatch()
|
||||
//this isn't used currently
|
||||
QPixmap QGIFace::textureFromSvg(std::string fileSpec)
|
||||
{
|
||||
QPixmap result;
|
||||
QString qs(QString::fromStdString(fileSpec));
|
||||
QFileInfo ffi(qs);
|
||||
if (ffi.isReadable()) {
|
||||
QSvgRenderer renderer(qs);
|
||||
QPixmap pixMap(renderer.defaultSize());
|
||||
pixMap.fill(Qt::white); //try Qt::transparent?
|
||||
QPainter painter(&pixMap);
|
||||
renderer.render(&painter); //svg texture -> bitmap
|
||||
result = pixMap.scaled(m_fillScale, m_fillScale);
|
||||
} //else return empty pixmap
|
||||
return result;
|
||||
if (!ffi.isReadable()) {
|
||||
return QPixmap();
|
||||
}
|
||||
QSvgRenderer renderer(qs);
|
||||
QPixmap pixMap(renderer.defaultSize());
|
||||
pixMap.fill(Qt::white); //try Qt::transparent?
|
||||
QPainter painter(&pixMap);
|
||||
renderer.render(&painter); //svg texture -> bitmap
|
||||
return pixMap.scaled(m_fillScale, m_fillScale);
|
||||
}
|
||||
|
||||
void QGIFace::setHatchColor(App::Color c)
|
||||
|
||||
@@ -451,16 +451,14 @@ QPainterPath QGILeaderLine::makeLeaderPath(std::vector<QPointF> qPoints)
|
||||
QPointF QGILeaderLine::getAttachFromFeature()
|
||||
{
|
||||
// Base::Console().Message("QGILL::getAttachFromFeature()\n");
|
||||
QPointF result;
|
||||
TechDraw::DrawLeaderLine* featLeader = getFeature();
|
||||
if ((!featLeader)) {
|
||||
if (!featLeader) {
|
||||
Base::Console().Message("QGIL::getAttachFromLeader - no feature\n");
|
||||
return result;
|
||||
return QPointF();
|
||||
}
|
||||
double x = Rez::guiX(featLeader->X.getValue());
|
||||
double y = -Rez::guiX(featLeader->Y.getValue());
|
||||
result = QPointF(x, y);
|
||||
return result;
|
||||
return QPointF(x, y);
|
||||
}
|
||||
|
||||
std::vector<QPointF> QGILeaderLine::getWayPointsFromFeature()
|
||||
|
||||
@@ -146,12 +146,10 @@ void QGIPrimPath::setPrettySel() {
|
||||
//this always goes to parameter
|
||||
QColor QGIPrimPath::getNormalColor()
|
||||
{
|
||||
QColor result;
|
||||
QGIView *parent;
|
||||
|
||||
if (m_colOverride) {
|
||||
result = m_colNormal;
|
||||
return result;
|
||||
return m_colNormal;
|
||||
}
|
||||
|
||||
QGraphicsItem* qparent = parentItem();
|
||||
@@ -162,17 +160,13 @@ QColor QGIPrimPath::getNormalColor()
|
||||
}
|
||||
|
||||
if (parent) {
|
||||
result = parent->getNormalColor();
|
||||
} else {
|
||||
result = PreferencesGui::normalQColor();
|
||||
return parent->getNormalColor();
|
||||
}
|
||||
|
||||
return result;
|
||||
return PreferencesGui::normalQColor();
|
||||
}
|
||||
|
||||
QColor QGIPrimPath::getPreColor()
|
||||
{
|
||||
QColor result;
|
||||
QGIView *parent;
|
||||
QGraphicsItem* qparent = parentItem();
|
||||
if (!qparent) {
|
||||
@@ -182,16 +176,13 @@ QColor QGIPrimPath::getPreColor()
|
||||
}
|
||||
|
||||
if (parent) {
|
||||
result = parent->getPreColor();
|
||||
} else {
|
||||
result = PreferencesGui::preselectQColor();
|
||||
return parent->getPreColor();
|
||||
}
|
||||
return result;
|
||||
return PreferencesGui::preselectQColor();
|
||||
}
|
||||
|
||||
QColor QGIPrimPath::getSelectColor()
|
||||
{
|
||||
QColor result;
|
||||
QGIView *parent;
|
||||
QGraphicsItem* qparent = parentItem();
|
||||
if (!qparent) {
|
||||
@@ -201,11 +192,9 @@ QColor QGIPrimPath::getSelectColor()
|
||||
}
|
||||
|
||||
if (parent) {
|
||||
result = parent->getSelectColor();
|
||||
} else {
|
||||
result = PreferencesGui::selectQColor();
|
||||
return parent->getSelectColor();
|
||||
}
|
||||
return result;
|
||||
return PreferencesGui::selectQColor();
|
||||
}
|
||||
|
||||
void QGIPrimPath::setWidth(double w)
|
||||
|
||||
@@ -261,20 +261,21 @@ void QGIRichAnno::paint ( QPainter * painter, const QStyleOptionGraphicsItem * o
|
||||
|
||||
QPen QGIRichAnno::rectPen() const
|
||||
{
|
||||
QPen pen;
|
||||
const auto sym( dynamic_cast<TechDraw::DrawRichAnno*>(getViewObject()) );
|
||||
if (!sym)
|
||||
return pen;
|
||||
if (!sym) {
|
||||
return QPen();
|
||||
}
|
||||
auto vp = static_cast<ViewProviderRichAnno*>(getViewProvider(getViewObject()));
|
||||
if (!vp)
|
||||
return pen;
|
||||
if (!vp) {
|
||||
return QPen();
|
||||
}
|
||||
|
||||
double rectWeight = Rez::guiX(vp->LineWidth.getValue());
|
||||
Qt::PenStyle rectStyle = static_cast<Qt::PenStyle>(vp->LineStyle.getValue());
|
||||
App::Color temp = vp->LineColor.getValue();
|
||||
QColor rectColor = temp.asValue<QColor>();
|
||||
|
||||
pen = QPen(rectStyle);
|
||||
QPen pen = QPen(rectStyle);
|
||||
pen.setWidthF(rectWeight);
|
||||
pen.setColor(rectColor);
|
||||
return pen;
|
||||
|
||||
@@ -696,18 +696,15 @@ void QGIViewDimension::datumLabelDragFinished()
|
||||
//this is for formatting and finding centers, not display
|
||||
QString QGIViewDimension::getLabelText()
|
||||
{
|
||||
QString result;
|
||||
QString first = datumLabel->getDimText()->toPlainText();
|
||||
QString second = datumLabel->getTolTextOver()->toPlainText();
|
||||
QString third = datumLabel->getTolTextUnder()->toPlainText();
|
||||
if (second.length() > third.length()) {
|
||||
result = first + second;
|
||||
return first + second;
|
||||
}
|
||||
else {
|
||||
result = first + third;
|
||||
return first + third;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void QGIViewDimension::draw()
|
||||
@@ -2545,7 +2542,6 @@ Base::Vector3d QGIViewDimension::findIsoDir(Base::Vector3d ortho) const
|
||||
//! find the iso extension direction corresponding to an iso dist direction
|
||||
Base::Vector3d QGIViewDimension::findIsoExt(Base::Vector3d dir) const
|
||||
{
|
||||
Base::Vector3d dirExt(1, 0, 0);
|
||||
Base::Vector3d isoX(0.866, 0.5, 0.0); //iso X
|
||||
Base::Vector3d isoXr(-0.866, -0.5, 0.0);//iso -X
|
||||
Base::Vector3d isoY(-0.866, 0.5, 0.0); //iso -Y?
|
||||
@@ -2553,29 +2549,28 @@ Base::Vector3d QGIViewDimension::findIsoExt(Base::Vector3d dir) const
|
||||
Base::Vector3d isoZ(0.0, 1.0, 0.0); //iso Z
|
||||
Base::Vector3d isoZr(0.0, -1.0, 0.0); //iso -Z
|
||||
if (dir.IsEqual(isoX, FLT_EPSILON)) {
|
||||
dirExt = isoY;
|
||||
return isoY;
|
||||
}
|
||||
else if (dir.IsEqual(-isoX, FLT_EPSILON)) {
|
||||
dirExt = -isoY;
|
||||
return -isoY;
|
||||
}
|
||||
else if (dir.IsEqual(isoY, FLT_EPSILON)) {
|
||||
dirExt = isoZ;
|
||||
return isoZ;
|
||||
}
|
||||
else if (dir.IsEqual(-isoY, FLT_EPSILON)) {
|
||||
dirExt = -isoZ;
|
||||
return -isoZ;
|
||||
}
|
||||
else if (dir.IsEqual(isoZ, FLT_EPSILON)) {
|
||||
dirExt = isoX;
|
||||
return isoX;
|
||||
}
|
||||
else if (dir.IsEqual(-isoZ, FLT_EPSILON)) {
|
||||
dirExt = -isoX;
|
||||
return -isoX;
|
||||
}
|
||||
else {//tarfu
|
||||
Base::Console().Message("QGIVD::findIsoExt - %s - input is not iso axis\n",
|
||||
getViewObject()->getNameInDocument());
|
||||
}
|
||||
|
||||
return dirExt;
|
||||
|
||||
//tarfu
|
||||
Base::Console().Message("QGIVD::findIsoExt - %s - input is not iso axis\n",
|
||||
getViewObject()->getNameInDocument());
|
||||
return Base::Vector3d(1, 0, 0);
|
||||
}
|
||||
|
||||
void QGIViewDimension::onPrettyChanged(int state)
|
||||
|
||||
@@ -741,7 +741,6 @@ void MRichTextEdit::onSelectionChanged()
|
||||
bool MRichTextEdit::hasMultipleSizes()
|
||||
{
|
||||
// qDebug() << "MRTE::hasMultipleSizes()";
|
||||
bool result = false;
|
||||
QTextCursor cursor = f_textedit->textCursor();
|
||||
if (cursor.hasSelection()) {
|
||||
int begin = cursor.selectionStart();
|
||||
@@ -761,10 +760,10 @@ bool MRichTextEdit::hasMultipleSizes()
|
||||
}
|
||||
}
|
||||
if (countMap.size() > 1) {
|
||||
result = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
void MRichTextEdit::setDefFontSize(int fontSize)
|
||||
|
||||
Reference in New Issue
Block a user