Print Page | Close Window

Flowgraph bug - and workaround.

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Chart Control
Forum Description: Topics Related to Codejock Chart Control
URL: http://forum.codejock.com/forum_posts.asp?TID=17995
Printed Date: 21 November 2024 at 8:26pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Flowgraph bug - and workaround.
Posted By: Algae
Subject: Flowgraph bug - and workaround.
Date 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.





Replies:
Posted By: Oleg
Date 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


Posted By: Algae
Date 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.

}



Posted By: Oleg
Date 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


Posted By: Algae
Date 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.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net