Skip to content

Commit

Permalink
Merge branch 'master' into addImportExportRecentFilesPrefs
Browse files Browse the repository at this point in the history
  • Loading branch information
kkremitzki committed Jan 30, 2021
2 parents 70d81c0 + 4db83a4 commit ce8b96b
Show file tree
Hide file tree
Showing 32 changed files with 1,884 additions and 26,047 deletions.
14 changes: 7 additions & 7 deletions src/Gui/Inventor/MarkerBitmaps.cpp
Expand Up @@ -345,12 +345,12 @@ const char circleLine11_marker[CIRCLE_LINE11_WIDTH * CIRCLE_LINE11_HEIGHT + 1] =
" "
" xxxxxx "
" xxxxxxxx "
" xx xx "
" xxx xxx"
" xx xx"
" xx xx"
" xx xx"
" xx xx"
" xx xx "
" xxx xxx"
" xxxxxxxx "
" xxxxxx "};

Expand Down Expand Up @@ -381,7 +381,7 @@ const char circleLine15_marker[CIRCLE_LINE15_WIDTH * CIRCLE_LINE15_HEIGHT + 1] =
" "
" xxxxxx "
" xxxxxxxxxx "
" xx xx "
" xxx xxx "
" xx xx "
" xx xx"
" xx xx"
Expand All @@ -390,7 +390,7 @@ const char circleLine15_marker[CIRCLE_LINE15_WIDTH * CIRCLE_LINE15_HEIGHT + 1] =
" xx xx"
" xx xx"
" xx xx "
" xx xxxx"
" xxx xxx "
" xxxxxxxxxx "
" xxxxxx "};

Expand All @@ -401,12 +401,12 @@ const char circleFilled11_marker[CIRCLE_FILLED11_WIDTH * CIRCLE_FILLED11_HEIGHT
" "
" xxxxxx "
" xxxxxxxx "
" xxxxxxxx "
" xxxxxxxxxx"
" xxxxxxxxxx"
" xxxxxxxxxx"
" xxxxxxxxxx"
" xxxxxxxx "
" xxxxxxxxxx"
" xxxxxxxxxx"
" xxxxxxxx "
" xxxxxx "};

Expand Down Expand Up @@ -446,7 +446,7 @@ const char circleFilled15_marker[CIRCLE_FILLED15_WIDTH * CIRCLE_FILLED15_HEIGHT
" xxxxxxxxxxxxxx"
" xxxxxxxxxxxxxx"
" xxxxxxxxxxxx "
" xxxxxxxxxxxx"
" xxxxxxxxxxxx "
" xxxxxxxxxx "
" xxxxxx "};

Expand Down
54 changes: 30 additions & 24 deletions src/Gui/View3DInventor.cpp
Expand Up @@ -774,47 +774,53 @@ bool View3DInventor::setCamera(const char* pCamera)
SoNode * Cam;
SoDB::read(&in,Cam);

if (!Cam){
if (!Cam || !Cam->isOfType(SoCamera::getClassTypeId())) {
throw Base::RuntimeError("Camera settings failed to read");
}

// this is to make sure to reliably delete the node
CoinPtr<SoNode> camPtr(Cam, true);

// toggle between perspective and orthographic camera
if (Cam->getTypeId() != CamViewer->getTypeId())
{
if (Cam->getTypeId() != CamViewer->getTypeId()) {
_viewer->setCameraType(Cam->getTypeId());
CamViewer = _viewer->getSoRenderManager()->getCamera();
}

SoPerspectiveCamera * CamViewerP = 0;
SoOrthographicCamera * CamViewerO = 0;
SoPerspectiveCamera * CamViewerP = nullptr;
SoOrthographicCamera * CamViewerO = nullptr;

if (CamViewer->getTypeId() == SoPerspectiveCamera::getClassTypeId()) {
CamViewerP = (SoPerspectiveCamera *)CamViewer; // safe downward cast, knows the type
} else if (CamViewer->getTypeId() == SoOrthographicCamera::getClassTypeId()) {
CamViewerO = (SoOrthographicCamera *)CamViewer; // safe downward cast, knows the type
CamViewerP = static_cast<SoPerspectiveCamera *>(CamViewer); // safe downward cast, knows the type
}
else if (CamViewer->getTypeId() == SoOrthographicCamera::getClassTypeId()) {
CamViewerO = static_cast<SoOrthographicCamera *>(CamViewer); // safe downward cast, knows the type
}

if (Cam->getTypeId() == SoPerspectiveCamera::getClassTypeId()) {
if (CamViewerP){
CamViewerP->position = ((SoPerspectiveCamera *)Cam)->position;
CamViewerP->orientation = ((SoPerspectiveCamera *)Cam)->orientation;
CamViewerP->nearDistance = ((SoPerspectiveCamera *)Cam)->nearDistance;
CamViewerP->farDistance = ((SoPerspectiveCamera *)Cam)->farDistance;
CamViewerP->focalDistance = ((SoPerspectiveCamera *)Cam)->focalDistance;
} else {
CamViewerP->position = static_cast<SoPerspectiveCamera *>(Cam)->position;
CamViewerP->orientation = static_cast<SoPerspectiveCamera *>(Cam)->orientation;
CamViewerP->nearDistance = static_cast<SoPerspectiveCamera *>(Cam)->nearDistance;
CamViewerP->farDistance = static_cast<SoPerspectiveCamera *>(Cam)->farDistance;
CamViewerP->focalDistance = static_cast<SoPerspectiveCamera *>(Cam)->focalDistance;
}
else {
throw Base::TypeError("Camera type mismatch");
}
} else if (Cam->getTypeId() == SoOrthographicCamera::getClassTypeId()) {
}
else if (Cam->getTypeId() == SoOrthographicCamera::getClassTypeId()) {
if (CamViewerO){
CamViewerO->viewportMapping = ((SoOrthographicCamera *)Cam)->viewportMapping;
CamViewerO->position = ((SoOrthographicCamera *)Cam)->position;
CamViewerO->orientation = ((SoOrthographicCamera *)Cam)->orientation;
CamViewerO->nearDistance = ((SoOrthographicCamera *)Cam)->nearDistance;
CamViewerO->farDistance = ((SoOrthographicCamera *)Cam)->farDistance;
CamViewerO->focalDistance = ((SoOrthographicCamera *)Cam)->focalDistance;
CamViewerO->aspectRatio = ((SoOrthographicCamera *)Cam)->aspectRatio ;
CamViewerO->height = ((SoOrthographicCamera *)Cam)->height;
} else {
CamViewerO->viewportMapping = static_cast<SoOrthographicCamera *>(Cam)->viewportMapping;
CamViewerO->position = static_cast<SoOrthographicCamera *>(Cam)->position;
CamViewerO->orientation = static_cast<SoOrthographicCamera *>(Cam)->orientation;
CamViewerO->nearDistance = static_cast<SoOrthographicCamera *>(Cam)->nearDistance;
CamViewerO->farDistance = static_cast<SoOrthographicCamera *>(Cam)->farDistance;
CamViewerO->focalDistance = static_cast<SoOrthographicCamera *>(Cam)->focalDistance;
CamViewerO->aspectRatio = static_cast<SoOrthographicCamera *>(Cam)->aspectRatio ;
CamViewerO->height = static_cast<SoOrthographicCamera *>(Cam)->height;
}
else {
throw Base::TypeError("Camera type mismatch");
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/Gui/ViewProviderLine.cpp
Expand Up @@ -68,13 +68,11 @@ void ViewProviderLine::attach ( App::DocumentObject *obj ) {
sep->addChild ( pCoords );

SoIndexedLineSet *pLines = new SoIndexedLineSet ();
pLines->ref();
pLines->coordIndex.setNum(3);
pLines->coordIndex.setValues(0, 3, lines);
sep->addChild ( pLines );

SoTranslation *textTranslation = new SoTranslation ();
textTranslation->ref ();
textTranslation->translation.setValue ( SbVec3f ( -size * 49. / 50., size / 30., 0 ) );
sep->addChild ( textTranslation );

Expand Down
2 changes: 0 additions & 2 deletions src/Gui/ViewProviderPlane.cpp
Expand Up @@ -70,13 +70,11 @@ void ViewProviderPlane::attach ( App::DocumentObject *obj ) {
sep->addChild ( pCoords );

SoIndexedLineSet *pLines = new SoIndexedLineSet ();
pLines->ref();
pLines->coordIndex.setNum(6);
pLines->coordIndex.setValues(0, 6, lines);
sep->addChild ( pLines );

SoTranslation *textTranslation = new SoTranslation ();
textTranslation->ref ();
textTranslation->translation.setValue ( SbVec3f ( -size * 49. / 50., size * 9./10., 0 ) );
sep->addChild ( textTranslation );

Expand Down
12 changes: 3 additions & 9 deletions src/Mod/Draft/draftguitools/gui_snapper.py
Expand Up @@ -410,14 +410,8 @@ def snapToObject(self, lastpoint, active, constrain,
if (not self.maxEdges) or (len(shape.Edges) <= self.maxEdges):
if "Edge" in comp:
# we are snapping to an edge
edge = None
if shape.ShapeType == "Edge":
edge = shape
else:
en = int(comp[4:])-1
if len(shape.Edges) > en:
edge = shape.Edges[en]
if edge:
snaps.extend(self.snapToEndpoints(edge))
snaps.extend(self.snapToMidpoint(edge))
snaps.extend(self.snapToPerpendicular(edge, lastpoint))
Expand All @@ -433,9 +427,9 @@ def snapToObject(self, lastpoint, active, constrain,
# extra ellipse options
snaps.extend(self.snapToCenter(edge))
elif "Face" in comp:
en = int(comp[4:])-1
if len(shape.Faces) > en:
face = shape.Faces[en]
# we are snapping to a face
if shape.ShapeType == "Face":
face = shape
snaps.extend(self.snapToFace(face))
elif "Vertex" in comp:
# directly snapped to a vertex
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Part/App/PropertyGeometryList.cpp
Expand Up @@ -226,7 +226,7 @@ void PropertyGeometryList::Restore(Base::XMLReader &reader)
reader.readEndElement("GeometryList");

// assignment
setValues(values);
setValues(std::move(values));
}

App::Property *PropertyGeometryList::Copy(void) const
Expand Down
5 changes: 4 additions & 1 deletion src/Mod/Part/Gui/ViewProviderExt.cpp
Expand Up @@ -1133,7 +1133,10 @@ void ViewProviderPartExt::updateVisual()
const TopoDS_Face &actFace = TopoDS::Face(faceMap(i));
// get the mesh of the shape
Handle (Poly_Triangulation) mesh = BRep_Tool::Triangulation(actFace,aLoc);
if (mesh.IsNull()) continue;
if (mesh.IsNull()) {
parts[ii] = 0;
continue;
}

// getting the transformation of the shape/face
gp_Trsf myTransf;
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathDressupTagGui.py
Expand Up @@ -419,7 +419,7 @@ def onDelete(self, arg1=None, arg2=None):
'''this makes sure that the base operation is added back to the job and visible'''
# pylint: disable=unused-argument
PathLog.track()
if self.obj.Base.ViewObject:
if self.obj.Base and self.obj.Base.ViewObject:
self.obj.Base.ViewObject.Visibility = True
job = PathUtils.findParentJob(self.obj)
if arg1.Object and arg1.Object.Base and job:
Expand Down
7 changes: 5 additions & 2 deletions src/Mod/Path/PathScripts/PathJobGui.py
Expand Up @@ -522,6 +522,7 @@ def setupUi(self, obj):
class StockFromExistingEdit(StockEdit):
Index = 3
StockType = PathStock.StockType.Unknown
StockLabelPrefix = 'Stock'

def editorFrame(self):
return self.form.stockFromExisting
Expand All @@ -530,7 +531,7 @@ def getFields(self, obj):
stock = self.form.stockExisting.itemData(self.form.stockExisting.currentIndex())
if not (hasattr(obj.Stock, 'Objects') and len(obj.Stock.Objects) == 1 and obj.Stock.Objects[0] == stock):
if stock:
stock = PathJob.createResourceClone(obj, stock, 'Stock', 'Stock')
stock = PathJob.createResourceClone(obj, stock, self.StockLabelPrefix , 'Stock')
stock.ViewObject.Visibility = True
PathStock.SetupStockObject(stock, PathStock.StockType.Unknown)
stock.Proxy.execute(stock)
Expand All @@ -556,7 +557,9 @@ def setFields(self, obj):
index = -1
for i, solid in enumerate(self.candidates(obj)):
self.form.stockExisting.addItem(solid.Label, solid)
if solid.Label == stockName:
label="{}-{}".format(self.StockLabelPrefix, solid.Label)

if label == stockName:
index = i
self.form.stockExisting.setCurrentIndex(index if index != -1 else 0)

Expand Down
3 changes: 1 addition & 2 deletions src/Mod/Path/PathScripts/PathSimpleCopy.py
Expand Up @@ -67,8 +67,7 @@ def Activated(self):

FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.addModule("PathScripts.PathCustom")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","' + selection[0].Name + '_SimpleCopy")')
FreeCADGui.doCommand('PathScripts.PathCustom.ObjectCustom(obj)')
FreeCADGui.doCommand('obj = PathScripts.PathCustom.Create("' + selection[0].Name + '_SimpleCopy")')
FreeCADGui.doCommand('obj.ViewObject.Proxy = 0')
FreeCADGui.doCommand('obj.Gcode = [c.toGCode() for c in srcpath.Commands]')
FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)')
Expand Down

2 comments on commit ce8b96b

@0penBrain
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kkremitzki really glad to see some more PR merging
However I think this commit and the next one 046aa8a are really weird to have in the commit history.
They actually show outdated diffs and make no real sense.
Eg if I compare this commit with the previous one, I get a partial changeset (compared to the one shown directly by the commit) : 4db83a4...ce8b96b
This changeset corresponds to the changes in the PR made by @chennes (which is correct though).
However the same changeset is merged a second time 3 commits later in ca346b9
Same happens with next commit to this one.
I absolutely have no clue of PR merging process in GH (and I'm far to be a git expert) but all this makes hard to follow the commit history.
PS : Also definitely don't want to discourage you to merge other PR :)

@kkremitzki
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sorry, I think I should have done a squash merge instead. I wonder why they don't have that as the default on GH.

Please sign in to comment.