Post Reply
Posts: 111
Joined: September 26th, 2018, 9:36 pm


Post by bjkwon » April 19th, 2019, 1:22 am

1. Judicious automatic repainting of the figure window

So far, there has been no way for the AUXLAB user to control automatic repainting of figure windows (here, "repainting of the figure window" means the window procedure in graffy.dll processing the WM_PAINT message, most likely through InvalidateRect calls.) InvalidateRect was called numerous times inside the code, presuming that repainting the figure would be necessary at all times whenever a change is made in the figure window or any of its children controls. This results in repainting of figure objects multiple times within a UDF, causing annoying flickering, or possibly crashing the application (crashing occurs if a change to the graffy objects is made from a different thread and the iterator of the vector for the graffy objects inside of OnPaint suddenly becomes invalid inside of a loop).

Therefore, from now on, a figure window (a dialog box control from the WinAPI's perspective) appears on the screen or a change in it is updated on the screen only in one of the following scenarios:
  1. when a graffy function is called (such as `figure`, `plot`, `axes`...) in the command console
  2. when an assignment statement involving GO such as `ax.color=[.7 .7 .8]` or any other statement causing a change of GO such as `ax.myfunction_change_color(some_color)` is made in the command console.
  3. when the operation of a UDF that involves 1) or 2) is complete and you return to the command console
  4. when the operation takes place in a debugger (i.e., the process stops at a breakpoint).
  5. when the function `repaint` is called for the figure window inside of a UDF.
Simply speaking, as a figure is created, an axes is made, a plot is made, and some of them are modified here and there; during all of these operations the figure will not appear as long as the operation executes inside a UDF. It should appear when it is complete and the user has the prompt back in the command console, or if there is an explicit function issued inside the UDF (e.g., `f.repaint`)

2. An important change in the code for all AUX operations

To support this feature, from now on, when a figure window (dialogbox control) shall be created with NOT visible (set in the dialog resource); because if it is set visible, CreateDialogParam forces the window to show. We should keep it from appearing until it is necessary. CGobj::visible for the figure object is set -1 to indicate that this is "uninitiated." This uninitiated state is necessary to differentiate it from the invisible state (visible=0), because the user might have specifically set visible=0.
  • All AUX operations ("block_func" as specified in psycon.y) shall undergo a checking whether a repainting should occur. That is, the following questions are considered:
    1. Is this a graffy function, such as `f=figure`
    2. Is this an assignment statement involving GOs, such as `ax.color=[.7 .7 .8]`
    3. Is this the end of a UDF and are you returning back to the command console?
  • If yes to one of the above, the following judgment should be made whether:
  • You don't have repaint now --- Add the desired area of the current block_func to the repaint table. or
  • You must repaint now (one of the 4 scenarios stated above) --- Call InvalidateRect for all the repaint areas specified in the repaint table. (in addition, if the figure window is uninitiated, it must first be set visible on.)
  • The "repaint table" is added in v1.501; A *CGraffyDLL* class variable ***redraw*** is defined as follows in graffy.cpp:

Code: Select all

class CGraffyDLL : public CWinApp  
multimap<HWND, RECT> redraw;  
3. Where is the checking done in the code (v1.501)?

The checking is done in HandleAuxFunctions in AuxFunc.cpp, TID and CallUDF in AstSig.cpp, all at the end of these functions.
  • The decision whether to repaint now is made in the function AstSig::`need2repaintnow`
  • If `need2repaintnow`returns true, call `RepaintGO`.
  • `need2repaintnow` is called in TID and CallUDF in AstSig.cpp and HandleAuxFunctions in AuxFunc.cpp
  • `RepaintGO` first checks if the figure has been initiated, if not (visible=-1), visible is set to 1 and ShowWindow(SW_SHOW). Then InvalidateRect is called according to the content of the repaint table.
  • `SetGoProperties` in TID adds the relevant HWND, RECT pair to the repaint table. It is called prior to need2repaintnow.
  • This section ***Where is the checking done in the code (v1.501)*** is only a draft as of 4/13/2019. This content may be revised later.

Posts: 111
Joined: September 26th, 2018, 9:36 pm

Re: v1.501

Post by bjkwon » January 15th, 2021, 11:21 pm

RepaintGO calls invalidateRedrawCue() that calls InvalidateRect.

RepaintGO is in
1) ShowWS_CommandPrompt --> handles command line operation for base (checked), and debugging udf (need to check)

Post Reply