Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Chart Control
  New Posts New Posts RSS Feed - Flowgraph bug - and workaround.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Flowgraph bug - and workaround.

 Post Reply Post Reply
Author
Message
Algae View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: United States
Status: Offline
Points: 217
Post Options Post Options   Thanks (0) Thanks(0)   Quote Algae Quote  Post ReplyReply Direct Link To This Post Topic: Flowgraph bug - and workaround.
    Posted: 03 March 2011 at 8:58pm
I must say that the new chart material is great! You folks did a wonderful job.

The Flowgraph control was an unexpected bonus as I had an immediate use for it.
While I was implementing I noticed that if you try to delete a node with CXTPFlowGraphConnections (not just CXTPFlowGraphConnectionPoints) the system goes into spasms.

Before removing any node that has connection points with connections to it or any connection points with connections to it, you must remove the connections first. This is a little messy but I found the following works:

// where pNode is the CXTPFlowGraphNode you want to toss

for (int i = 0; i < pNode->GetConnectionPoints()->GetCount(); i++)
{
     pConnectionPoint = pNode->GetConnectionPoints()->GetAt(i);

     if (pConnectionPoint->GetConnectionsCount())
     {
         CXTPFlowGraphConnections* pConnections =    pNode->GetControl()->GetActivePage()->GetConnections();

         CXTPFlowGraphConnection* pConnection;

          for(int i = pConnections->GetCount()-1; i >= 0; i--)
          {
              pConnection = pConnections->GetAt(i);

              if (pConnection->GetInputPoint() == pConnectionPoint || pConnection->GetOutputPoint() == pConnectionPoint)
                    pConnection->Remove();
         }
     }
 }

After that you can call RemoveAll for the connection points, and finally toss the node.

Since there's no reference from the node or connection points to the connections there's no simple way to do a deep delete. There is a reference back to the connection points from the connections which is what I ended up using in this method. Unfortunately, that means you have to iterate all the connections on the control to remove the ones associated with the node which could be tedious if there were an inordinate number of them.

Please, if anyone has a better way to do this let me know and it will be some more fun for the Codejock people to work on.


Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 04 March 2011 at 6:28am
Hello,

Can you specify scenario when we can see problem.

We remove all connections in CXTPFlowGraphNode::OnRemoved so they removed before Node deleted.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Algae View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: United States
Status: Offline
Points: 217
Post Options Post Options   Thanks (0) Thanks(0)   Quote Algae Quote  Post ReplyReply Direct Link To This Post Posted: 24 March 2011 at 6:28pm
The problem occurs when I remove a single CXTPFlowGraphConnectionPoint from the Node. This is likely because it's beyond the design parameters of the code, but it would be a useful function.

Removing the entire Node works perfectly. Removing a single point from the Node fails.

There is another side effect I've discovered. The Node will not consistently resize properly after removing a point.  Sometimes it works, sometimes it doesn't. I'm not sure why yet. The node will either retain the original size box or will shrink the y coordinate properly. This occurs using the same code example as follows:

void My_View::RemoveConnectionPoint(CXTPFlowGraphConnectionPoint *point)
{
// kludge to remove associated connections

    if (point->GetConnectionsCount())
    {
        CXTPFlowGraphConnection* pConnection = NULL;
        CXTPFlowGraphConnections* pConnections = GetControl()->GetActivePage()->GetConnections();

        for (int i = pConnections->GetCount()-1; i >= 0; i--)
        {
            pConnection = pConnections->GetAt(i);
           
            if (pConnection->GetInputPoint() == point || pConnection->GetOutputPoint() == point)
                pConnection->Remove();
        }
    }

// we can now remove the Point from the Node

    CXTPFlowGraphNode *pNode = point->GetNode();
    pNode->GetConnectionPoints()->Remove(point);

// I would have expected the Node box to shrink accordingly and it does. But only sometimes.

}

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 25 March 2011 at 5:57am
Hello,

Thanks, agree this one about ConnectionPoint, we added  code to clean it.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Algae View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: United States
Status: Offline
Points: 217
Post Options Post Options   Thanks (0) Thanks(0)   Quote Algae Quote  Post ReplyReply Direct Link To This Post Posted: 25 March 2011 at 12:12pm

"The Node will not consistently resize properly after removing a point.  Sometimes it works, sometimes it doesn't. I'm not sure why yet. The node will either retain the original size box or will shrink the y coordinate properly."

Isolated this issue. The CSize m_szUserSize Node property was the culprit.

if m_szUserSize.cy is anything other than 0, the Node will size to that automatically (by design).

To solve, whenever I need to set a user width but not a user height, I set the cy to 0.

userSize.cy = 0;
pNode->SetSize(userSize);

I'd say this isn't a bug but something to watch for in coding if you are using the user size options.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.