here the prototype https://youtu.be/CmhZlU1V46Ytriplus wrote: P.S. Looking forward to test the BSpline editor!
Code: Select all
# version 0.1 from PySide import QtGui from PySide import QtCore import FreeCAD,Draft import nurbswb.needle from nurbswb.needle import npa2ssa,ssa2npa draftPts =  def updateSS(ss,curve): '''update curve data into spreadsheet''' ss.clearAll() npa2ssa(curve,ss,2,3,(1.0,1.0,0.5)) ss.set('B1',str(len(curve))) App.activeDocument().recompute() def updateDraft(ss,obj): '''update Draft Bspline object points from spreadsheet ss''' global points cl=int(ss.get('B1')) curve=ssa2npa(ss,2,3,4,3+cl-1) obj.Points=[FreeCAD.Vector(c) for c in curve] points = obj.Points global writeBack,ss,obj2,points def writeBack(): global ss global obj2 updateDraft(ss,obj2) App.activeDocument().recompute() Gui.SendMsgToActiveView("ViewFit") def onApply(): writeBack() for i in draftPts: App.activeDocument().removeObject(i.Name) del draftPts[:] for i in points: point = Draft.makePoint(i + obj2.Placement.Base) draftPts.append(point) def onUpdate(): pts =  for i in draftPts: pts.append(i.Shape.Point) updateSS(ss, pts) onApply() btnApply = QtGui.QPushButton("Apply") btnApply.clicked.connect(onApply) btnUpdate = QtGui.QPushButton("Update") btnUpdate.clicked.connect(onUpdate) def pressed(index): pass def clicked(): pass def undock(ss): ''' open the data spreadsheet as top level window''' label=ss.Label mw=FreeCADGui.getMainWindow() mdiarea=mw.findChild(QtGui.QMdiArea) ss.ViewObject.startEditing(0) subw=mdiarea.subWindowList() for i in subw: if i.widget().metaObject().className() == "SpreadsheetGui::SheetView": sheet = i.widget() table=sheet.findChild(QtGui.QTableView) print "table found" break # table.clicked.connect(clicked) table.pressed.connect(pressed) sws=mdiarea.subWindowList() print "windows ..." for w2 in sws: print str(w2.windowTitle()) if str(w2.windowTitle()).startswith(label): sw=w2 print "found" bl=w2.children() blcc=bl.children().children() w=QtGui.QWidget() w.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) buttons = QtGui.QHBoxLayout() buttons.addStretch(0) buttons.addWidget(btnUpdate) buttons.addWidget(btnApply) box = QtGui.QVBoxLayout() w.setLayout(box) ss=blcc box.addWidget(ss) box.insertLayout(1, buttons) w.setGeometry(50, 30, 650, 350) w.show() sw.close() return w # test case #create the Bspline p1 = FreeCAD.Vector(0,0,0) p2 = FreeCAD.Vector(1,1,0) p3 = FreeCAD.Vector(0,2,0) p4 = FreeCAD.Vector(-1,1,0) Draft.makeBSpline([p1,p2,p3,p4],closed=True) # extract the data obj=App.ActiveDocument.ActiveObject bc=obj.Shape.Edge1.Curve poles=bc.getPoles() knots=bc.getKnots() we=bc.getWeights() mults=bc.getMultiplicities() pts=obj.Points poles knots we mults # create a d fill the spreadsheet ss = App.activeDocument().addObject('Spreadsheet::Sheet','Spreadsheet') updateSS(ss,pts) # create an other Draft BSpline p1 = FreeCAD.Vector(0,0,0) p2 = FreeCAD.Vector(10,1,0) p3 = FreeCAD.Vector(0,2,0) Draft.makeBSpline([p1,p2,p3],closed=True) obj2=App.ActiveDocument.ActiveObject Gui.SendMsgToActiveView("ViewFit") # write Points back updateDraft(ss,obj2) # open Spreadsheet w=undock(ss) onApply()
Yes, its not forgotten - I have alredy the "move commands" x y z t n d r as candidates and the workflow then can be pie menu -> direction select -> mouse move for distance and click to commit.triplus wrote:@microelly2
I remembered how we where discussing on how to use PieMenu for Nurbs editor purposes. Curve editor clearly shows how that can be achieved. If you would in addition make a few standalone commands on the toolbar like:
Such commands can easily be added to PieMenu and the interaction becomes really fast. And as a bonus at the same time current FreeCAD UX interaction paradigm is preserved as the solution doesn't have to be tailored just for PieMenu.
- Edit curve (exposes selected curve points)
- Toggle poles/knot curve points
- Move curve point command (select base point and point on a curve)
https://github.com/microelly2/freecad-nurbsKonstantin wrote:Hello. It's all impressive, but where can I get this NURBS editor to play with it? I'm lost in this thread and all of it's links
It is possible to approximate or interpolate data but the result is not unique
And a litle/huge feature request for the future. (Or, maybe explain to me why nobody does it)
I want not NURBS surface, which approximates surface somewhere inbetween control points, I want surface to go strictly thru control points.
Is it so useless, or is it so hard to implement, so nobody does it?
Which reminds me I must get back to development of Importing Rhino 3DM files. Been 3 months since last commitmicroelly2 wrote:https://github.com/microelly2/freecad-nurbsKonstantin wrote:Hello. It's all impressive, but where can I get this NURBS editor to play with it? I'm lost in this thread and all of it's links