DAGView

Discussion about the development of the Assembly workbench.
ickby
Posts: 2940
Joined: Wed Oct 05, 2011 7:36 am

Re: DAGView

Postby ickby » Tue Jun 09, 2015 5:35 pm

Hello, I was hoping you would chime in as we have had a similar conversation a little while ago.
Yes, but unfortunately my list of things to do in this branch is that long that I can't offer any coding help in this new view.

I don't really follow your example as it trying to use a datum plane from another body/part which part design rejects. Doesn't matter though because I have no doubt the problem you describe exists. My question to you about this is: Does this problem exist because a feature node/point isn't in the correct column? If the answer is yes, this leads back to the point of my original post.
I think your problem goes deeper than what you have described in your initial post. Have a look at the following picture:
dag.png
dag.png (110.08 KiB) Viewed 1472 times
There are two points:
1. Sketch002 is connected to origin: that is not true, there should be no line between them. origin should be left or right from the sketch/pad/body nodes and connect to part only. That is what i suspect you described n your first post. (the same happens for datum plane: it depends on Fillet, but not on Sketch, but for both connections exist)
2. Sketch002 depends on DatumPlane. This connection most likely exist, but pases through many many other nodes making it invisible. It is impossible to see what is connected to what anymore.

What you basically need is a edge and node avoidance system with two rules:
1. a edge shout never touch any node except its start and end node.
2. an edge shall never occupy the space of another edge, but only cross it perpendicular if needed.
This then reduces to a layout problem which can be handled without any additional information from the document objects. IMHO document object information is never enough to enforce those rules and hence would always lead to errors as seen here. But most likely creating a layout engines which enforces those rules will be rather hard. You can have a look at adaptagrams, they offer pretty powerful algorithms. (But maybe there are more powerful libraries out there foor such problems, maybe even a git library?)
Hah! I already looked at it a little while ago out of curiosity and even made some changes to the documentation. Sounds interesting, but to be honest the idea/concept hasn't penetrated my thick skull yet. Is your latest code merged into jurgens assembly branch? Even though I am building this on the assembly branch I am doing my best to make the dagview independent.
No, I modified the code very much recently and this is only in my repository. If you are interested I can provide an example code. Note that the recent update included the possibility to filter the graph, so this may come in handy for your additional ideas! And also feel free to copy the 3 relevant files over, no need for dependencies here (hail the templates!)
ickby
Posts: 2940
Joined: Wed Oct 05, 2011 7:36 am

Re: DAGView

Postby ickby » Tue Jun 09, 2015 5:43 pm

by the way, if you create a sketch without anything selected you can choose all datum planes as base, even from other parts. Tht is very powerful, as you can make dependent parts and still move both independently!
poutine
Posts: 6
Joined: Tue Jun 09, 2015 5:54 pm
Location: St-Jean-sur-Richelieu, Qc, Canada

Re: DAGView

Postby poutine » Tue Jun 09, 2015 6:05 pm

Hi.

Just to let you know that under Windows 7 64bits, using VS 2013, I get the following compile error:

Error 1 error C2653: 'QAbstractEventDispatcher' : is not a class or namespace name C:\Users\dannyl\Documents\Projets\FreeCAD_sf_master\src\Gui\DAGView\DAGView.cpp 57 1 FreeCADGui
Error 2 error C3861: 'instance': identifier not found C:\Users\dannyl\Documents\Projets\FreeCAD_sf_master\src\Gui\DAGView\DAGView.cpp 57 1 FreeCADGui
Error 3 error C2899: typename cannot be used outside a template declaration C:\Users\dannyl\Documents\Projets\FreeCAD_sf_master\src\Gui\DAGView\DAGModel.cpp 339 1 FreeCADGui
Error 4 error C2899: typename cannot be used outside a template declaration C:\Users\dannyl\Documents\Projets\FreeCAD_sf_master\src\Gui\DAGView\DAGModel.cpp 406 1 FreeCADGui
Error 5 error C2039: 'topological_sort' : is not a member of 'boost' C:\Users\dannyl\Documents\Projets\FreeCAD_sf_master\src\Gui\DAGView\DAGModel.cpp 464 1 FreeCADGui
Error 6 error C3861: 'topological_sort': identifier not found C:\Users\dannyl\Documents\Projets\FreeCAD_sf_master\src\Gui\DAGView\DAGModel.cpp 464 1 FreeCADGui
Error 7 error C2899: typename cannot be used outside a template declaration C:\Users\dannyl\Documents\Projets\FreeCAD_sf_master\src\Gui\DAGView\DAGModel.cpp 596 1 FreeCADGui
Error 8 error C2899: typename cannot be used outside a template declaration C:\Users\dannyl\Documents\Projets\FreeCAD_sf_master\src\Gui\DAGView\DAGModel.cpp 604 1 FreeCADGui
Error 9 error C2899: typename cannot be used outside a template declaration C:\Users\dannyl\Documents\Projets\FreeCAD_sf_master\src\Gui\DAGView\DAGModel.cpp 614 1 FreeCADGui
Error 10 error C2027: use of undefined type 'QGraphicsSceneMouseEvent' C:\Users\dannyl\Documents\Projets\FreeCAD_sf_master\src\Gui\DAGView\DAGModel.cpp 666 1 FreeCADGui
Error 11 error C2227: left of '->scenePos' must point to class/struct/union/generic type C:\Users\dannyl\Documents\Projets\FreeCAD_sf_master\src\Gui\DAGView\DAGModel.cpp 666 1 FreeCADGui
Error 12 error C2027: use of undefined type 'QGraphicsSceneMouseEvent' C:\Users\dannyl\Documents\Projets\FreeCAD_sf_master\src\Gui\DAGView\DAGModel.cpp 686 1 FreeCADGui
Error 13 error C2227: left of '->scenePos' must point to class/struct/union/generic type C:\Users\dannyl\Documents\Projets\FreeCAD_sf_master\src\Gui\DAGView\DAGModel.cpp 686 1 FreeCADGui

Might be specific to the case where "_PreComp_" is defined. For one, I think that the include QAbstractEventDispatcher is missing under this configuration as I was able to successfully compile "DAGView.cpp" by adding it outside the #ifndef _PreComp_ section.

As I am not totally familiar with CMake and FreeCAD build environment, this is probably as far as I can get to a solution.

Regards,
Danny
User avatar
tanderson69
Posts: 1517
Joined: Thu Feb 18, 2010 1:07 am

Re: DAGView

Postby tanderson69 » Tue Jun 09, 2015 7:30 pm

ickby wrote:
Hello, I was hoping you would chime in as we have had a similar conversation a little while ago.
Yes, but unfortunately my list of things to do in this branch is that long that I can't offer any coding help in this new view.
That is fine. Not enough code for 2 anyway. It is much more important to have someone on the same page to bounce ideas off.
ickby wrote:I think your problem goes deeper than what you have described in your initial post. Have a look at the following picture:
dag.png
There are two points:
1. Sketch002 is connected to origin: that is not true, there should be no line between them. origin should be left or right from the sketch/pad/body nodes and connect to part only. That is what i suspect you described n your first post. (the same happens for datum plane: it depends on Fillet, but not on Sketch, but for both connections exist)
2. Sketch002 depends on DatumPlane. This connection most likely exist, but pases through many many other nodes making it invisible. It is impossible to see what is connected to what anymore.
Thanks for the picture. Just to make sure I understand what you are saying, wouldn't both of the problems be solved if the sketch002 node/point was in the 1 column to the right of z axis? If no, why?
ickby wrote:What you basically need is a edge and node avoidance system with two rules:
1. a edge shout never touch any node except its start and end node.
2. an edge shall never occupy the space of another edge, but only cross it perpendicular if needed.
This then reduces to a layout problem which can be handled without any additional information from the document objects.
And how do you determine the column a feature should belong too?
ickby wrote:But most likely creating a layout engines which enforces those rules will be rather hard. You can have a look at adaptagrams, they offer pretty powerful algorithms. (But maybe there are more powerful libraries out there foor such problems, maybe even a git library?)
I have given this some thought and just a little research. My experience with graphviz makes me believe that this won't work as a basis for an interactive GUI. Mainly because a very small change to the graph can create an entirely different presentation. Causing much user frustration. I think this is also true with boost::topological_sort, which is why in my design document I mention a custom DFS that is predicated on an added documentObject creation index. I think this is the same problem you see in the treeview in undo/redo operations where objects jump to different positions.
ickby wrote:No, I modified the code very much recently and this is only in my repository. If you are interested I can provide an example code. Note that the recent update included the possibility to filter the graph, so this may come in handy for your additional ideas! And also feel free to copy the 3 relevant files over, no need for dependencies here (hail the templates!)
Thanks for the offer, I will hit you up if/when I am ready.
ickby wrote:by the way, if you create a sketch without anything selected you can choose all datum planes as base, even from other parts. Tht is very powerful, as you can make dependent parts and still move both independently!
did not know this, I will play. thanks.
User avatar
tanderson69
Posts: 1517
Joined: Thu Feb 18, 2010 1:07 am

Re: DAGView

Postby tanderson69 » Tue Jun 09, 2015 7:31 pm

poutine wrote:Might be specific to the case where "_PreComp_" is defined. For one, I think that the include QAbstractEventDispatcher is missing under this configuration as I was able to successfully compile "DAGView.cpp" by adding it outside the #ifndef _PreComp_ section.

As I am not totally familiar with CMake and FreeCAD build environment, this is probably as far as I can get to a solution.

Regards,
Danny
Thanks for posting I will investigate.
ickby
Posts: 2940
Joined: Wed Oct 05, 2011 7:36 am

Re: DAGView

Postby ickby » Wed Jun 10, 2015 1:12 pm

Thanks for the picture. Just to make sure I understand what you are saying, wouldn't both of the problems be solved if the sketch002 node/point was in the 1 column to the right of z axis? If no, why?
Well at least MainBody, Pad and Sketch002 need to be shifted. Than it will work.
User avatar
tanderson69
Posts: 1517
Joined: Thu Feb 18, 2010 1:07 am

Re: DAGView

Postby tanderson69 » Wed Jun 10, 2015 4:28 pm

I have been working on this and thinking about our conversation. We are both talking about the layout but are focused on different aspects at the moment. Maybe this will help convey my thinking.

1) I know the current layout is FUBAR. there is little to no logic behind it. That wasn't the point behind my initial post, but I do appreciate suggestions on this matter.

2) I know that altering document object is not going to be the solution to #1. The idea behind altering document object is using it to assist the solution to #1. Hopefully to produce a more user expected view. Consider the following picture:
docObjectExplanation.png
docObjectExplanation.png (40.69 KiB) Viewed 1386 times
User avatar
DeepSOIC
Posts: 7479
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: DAGView

Postby DeepSOIC » Tue Jun 23, 2015 6:03 pm

poutine wrote:Error 1 error C2653: 'QAbstractEventDispatcher' : is not a class or namespace name
I should have fixed this, and pushed the fix to assemblyMergeMaster1.
As for the rest, I have no idea how to fix them, I have them too. Errors start with:
C:\_vt\dev\PC\Qt\FreeCAD\FreeCAD-ellipse\src\Gui\DAGView\DAGModel.cpp:428: error: C2899: typename cannot be used outside a template declaration
code:

Code: Select all

void Model::selectionChanged(const SelectionChanges& msg)
{
  //note that treeview uses set selection which sends a message with just a document name
  //and no object name. Have to explore further.
  
  //lamda for clearing selections.
  auto clearSelection = [this]()
  {
    BGL_FORALL_VERTICES_T(currentVertex, *theGraph, Graph)  //  <---------- error
    {
      ViewEntryRectItem *rect = (*theGraph)[currentVertex].rectangle.get();
      assert(rect);
      rect->selectionOff();
    }
  };
  
From boost:

Code: Select all

#define BGL_FORALL_VERTICES_T(VNAME, GNAME, GraphType) \
for (std::pair<typename boost::graph_traits<GraphType>::vertex_iterator, \
               typename boost::graph_traits<GraphType>::vertex_iterator> BGL_RANGE(__LINE__) = vertices(GNAME); \
  BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
  for (typename boost::graph_traits<GraphType>::vertex_descriptor VNAME; \
    BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) ? (VNAME = *BGL_FIRST(__LINE__), true):false; \
     ++BGL_FIRST(__LINE__))
User avatar
DeepSOIC
Posts: 7479
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: DAGView

Postby DeepSOIC » Tue Jun 23, 2015 6:21 pm

Looks like I fixed it, proceeding to other errors
User avatar
DeepSOIC
Posts: 7479
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: DAGView

Postby DeepSOIC » Tue Jun 23, 2015 7:05 pm

Building on Windows of assemblyMergeMaster1 should be working now. It works for me, at least :mrgreen: .