a TGauge & TProgressBar question

Hi;

(Sorry, my question is long but it is very easy to understand.)

I have a tree structure. Each node in this tree structure may have various number of children nodes. And I have a procedure that traces
all of the nodes in this tree and does some time-consuming computation at each step.

I want to use a TProgressBar or a TGauge to inform the user about the progress of this computing process. In order to do so, I have to know the total number of nodes in the tree but since this tree lies in some database tables on the hard disk, it is meaningless to add an additional cost to calculate the number of nodes before the actual computation.

My question is, is there another way to make use of the progress bar in a way that we won't need to do such a node-counting calculation beforehand?
That is, will adding the number of nodes incrementally during the actual computing process help us?

(Previously I asked a similar question about Progress bars on this board, but now i reduced it to a specific one, and if it is possible, i need sample code or pseudocode)

Thanx,

_yilmaz

Comments

  • : Hi;
    :
    : (Sorry, my question is long but it is very easy to understand.)
    :
    : I have a tree structure. Each node in this tree structure may have various number of children nodes. And I have a procedure that traces
    : all of the nodes in this tree and does some time-consuming computation at each step.
    :
    : I want to use a TProgressBar or a TGauge to inform the user about the progress of this computing process. In order to do so, I have to know the total number of nodes in the tree but since this tree lies in some database tables on the hard disk, it is meaningless to add an additional cost to calculate the number of nodes before the actual computation.
    :
    : My question is, is there another way to make use of the progress bar in a way that we won't need to do such a node-counting calculation beforehand?
    : That is, will adding the number of nodes incrementally during the actual computing process help us?
    :
    : (Previously I asked a similar question about Progress bars on this board, but now i reduced it to a specific one, and if it is possible, i need sample code or pseudocode)
    :
    : Thanx,
    :
    : _yilmaz
    :
    This might be a possible way:
    each time you access a node, count the child nodes and add those to the Max of the bar. This way you dynamically count the number of nodes during the calculation. This shouldn't take up too much additional processing power.
  • Yes, but that is just the point that I'm asking. When I add to the Max property, how can I give the progress effect to the user? How and when and how much should I increment the pointer of the progress bar?

    It will be better if you can explain it by a pseudocode.

    Thanx...

    : : Hi;
    : :
    : : (Sorry, my question is long but it is very easy to understand.)
    : :
    : : I have a tree structure. Each node in this tree structure may have various number of children nodes. And I have a procedure that traces
    : : all of the nodes in this tree and does some time-consuming computation at each step.
    : :
    : : I want to use a TProgressBar or a TGauge to inform the user about the progress of this computing process. In order to do so, I have to know the total number of nodes in the tree but since this tree lies in some database tables on the hard disk, it is meaningless to add an additional cost to calculate the number of nodes before the actual computation.
    : :
    : : My question is, is there another way to make use of the progress bar in a way that we won't need to do such a node-counting calculation beforehand?
    : : That is, will adding the number of nodes incrementally during the actual computing process help us?
    : :
    : : (Previously I asked a similar question about Progress bars on this board, but now i reduced it to a specific one, and if it is possible, i need sample code or pseudocode)
    : :
    : : Thanx,
    : :
    : : _yilmaz
    : :
    : This might be a possible way:
    : each time you access a node, count the child nodes and add those to the Max of the bar. This way you dynamically count the number of nodes during the calculation. This shouldn't take up too much additional processing power.
    :

  • : Yes, but that is just the point that I'm asking. When I add to the Max property, how can I give the progress effect to the user? How and when and how much should I increment the pointer of the progress bar?
    :
    : It will be better if you can explain it by a pseudocode.
    :
    : Thanx...
    :
    : : : Hi;
    : : :
    : : : (Sorry, my question is long but it is very easy to understand.)
    : : :
    : : : I have a tree structure. Each node in this tree structure may have various number of children nodes. And I have a procedure that traces
    : : : all of the nodes in this tree and does some time-consuming computation at each step.
    : : :
    : : : I want to use a TProgressBar or a TGauge to inform the user about the progress of this computing process. In order to do so, I have to know the total number of nodes in the tree but since this tree lies in some database tables on the hard disk, it is meaningless to add an additional cost to calculate the number of nodes before the actual computation.
    : : :
    : : : My question is, is there another way to make use of the progress bar in a way that we won't need to do such a node-counting calculation beforehand?
    : : : That is, will adding the number of nodes incrementally during the actual computing process help us?
    : : :
    : : : (Previously I asked a similar question about Progress bars on this board, but now i reduced it to a specific one, and if it is possible, i need sample code or pseudocode)
    : : :
    : : : Thanx,
    : : :
    : : : _yilmaz
    : : :
    : : This might be a possible way:
    : : each time you access a node, count the child nodes and add those to the Max of the bar. This way you dynamically count the number of nodes during the calculation. This shouldn't take up too much additional processing power.
    : :
    :
    :
    The position increments is dictated by the nodes processed. Both components then calculate the relative position based on the Min, Position, and Max properties. If you increase the Max you will cause the bar to jump backwards and then start moving forwards again once the calculations start again until it reaches nearly the end.
    There are two another possibilities:
    - I've been reading up on the TTreeView (which I don't use much myself), and I noticed that the TTreeNodes object has a property Count, which holds the number of nodes in the tree. In other words, if the tree is completely filled, you can quickly look at that property to get the number of nodes.
    - Or you could start out with an estimation based on the size of the database and the size of the records. If it reaches about 90-95% you quickly count the remaining records and update the Max. This will cause a slight delay in the calculation, but the behaviour of the bar will be more natural. This can only be done if the records are of similar size.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories