Lazarus

Programming => Packages and Libraries => Topic started by: chrv on December 03, 2021, 10:54:56 am

Title: Visual PlanIt Overlay mode
Post by: chrv on December 03, 2021, 10:54:56 am
Hello everyone,

I'm trying to understand how "Overlay mode" works in Visual PlanIt.
I have read the wiki carefully but I cannot figure out how to activate this "Overlay mode".

In the attached zip, I made a prototype. Could someone modify this example so that "Overlay mode" can be activated.

Thank you
Title: Re: Visual PlanIt Overlay mode
Post by: wp on December 03, 2021, 05:43:18 pm
It looks as if grouping of resources has only be implemented for datastores based on databases, but not for datastores based on flat files.

Please give me some time to add this.
Title: Re: Visual PlanIt Overlay mode
Post by: chrv on December 03, 2021, 05:57:39 pm
In fact, i am interested in SQLite. I used XML as an example. I will check now with SQLinte.
Thank you.
Title: Re: Visual PlanIt Overlay mode
Post by: wp on December 03, 2021, 06:36:08 pm
SQLite3 should work, I tested it. The sample code in the wiki, however, is a bit imprecise because it uses constant ids for the resources to be merged, better to specify them as parameters:
Code: Pascal  [Select][+][-]
  1. procedure TMainForm.CreateResourceGroup(AResourceIDs: array of Integer; AGroupName: String = '');
  2. var
  3.   datastore: TVpCustomDatastore;
  4.   grp: TVpResourceGroup;
  5. begin
  6.   datastore := VpControlLink1.Datastore;
  7.   grp := datastore.Resources.AddResourceGroup(AResourceIDs, AGroupName);
  8.   grp.ReadOnly := true;
  9.   grp.Pattern := opDiagCross;
  10.   if datastore.Resource <> nil then
  11.     datastore.Resource.Group := grp
  12.   else
  13.     datastore.Resource.Group := nil;
  14.   datastore.RefreshEvents;  // or: datastore.UpdateGroupEvents;
  15. end;

So, when you want to overlay the second and third resources into the first resource shown in the resource combobox you should call it like this:
Code: Pascal  [Select][+][-]
  1. var
  2.   parentRes: Integer;
  3.   overlaidRes1: Integer;
  4.   overlaidRes2: Integer;
  5. ...
  6.   parentRes := datastore.Resources.Items[0];
  7.   overlaidRes1 := datastore.Resources.Items[1];
  8.   overlaidRes2 := datastore.Resources.Items[2];
  9.   CreateResourceGroup([parentRes, overlaidRes1, overlaidRes2]);
Title: Re: Visual PlanIt Overlay mode
Post by: chrv on December 04, 2021, 12:06:53 pm
Thank you very much: it works
minor fix:
Code: Pascal  [Select][+][-]
  1. aParentRes: = VpSqlite3Datastore1.Resources.Items [0].ResourceID

Can I still ask:
- how do I "deoverlay" the view.

Thank you for helping me
Title: Re: Visual PlanIt Overlay mode
Post by: wp on December 04, 2021, 08:16:04 pm
I added another way to tvplanit trunk how to create a resource group which is clearer and more flexible in my opinion: TVpResource.OverlayResources(AResources, ACaption). AResources is an array of the resource instances to be overlaid (not the resource ids any more!), and ACaption is an optional name for the resource group. When AResources is nil then resourcegroup assigned to the currently selected resource is removed. Unlike the old method, the resource to which the other resource are added must not be contained in AResources any more.

Code: Pascal  [Select][+][-]
  1.  type TVpResource = class(...)
  2.    function OverlayResources(const AResources: TVpResourceArray;  ACaption: String = ''): TVpResourceGroup;
  3.  

This code is working in your second demo project correctly for me:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.CheckBox1Change(Sender: TObject);
  2. var
  3.   aParentRes: TVpResource;
  4.   aOverlaidRes: TvpResourceArray = nil;
  5. begin
  6.   aParentRes := VpSqlite3Datastore1.Resources.Items[0];
  7.   if CheckBox1.Checked then
  8.   begin
  9.     SetLength(aOverlaidRes, 2);
  10.     aOverlaidRes[0] := VpSqlite3Datastore1.Resources.Items[1];
  11.     aOverlaidRes[1] := VpSqlite3Datastore1.Resources.Items[2];
  12.     aParentRes.OverlayResources(aOverlaidRes);
  13.   end else
  14.     aParentRes.OverlayResources(nil);
  15. end;

I also extended the FullDemo project of the tvplanit installation by a possibility to select from a TCheckListbox the resources to be overlaid.
Title: Re: Visual PlanIt Overlay mode
Post by: chrv on December 06, 2021, 09:14:48 pm
I tested your demo on trunk.
Everything seems to word as expected.
I will try to test my app on this version

Many thanks
Title: Re: Visual PlanIt Overlay mode
Post by: wp on December 07, 2021, 12:16:32 am
The wiki article about overlaid events (https://wiki.freepascal.org/Turbopower_Visual_PlanIt#Overlaying_events) has been updated to document the TVpResource.OverlayResources method.

And the flat-file datastores (xml, ini, json) have been extended to support resource groups as well.
Title: Re: Visual PlanIt Overlay mode
Post by: chrv on December 08, 2021, 12:13:34 pm
How is it possible to update Visual PlanIt from Online Package Manager. Is Visual PlanIt uptodate on OPM ?

Thank you ?
Title: Re: Visual PlanIt Overlay mode
Post by: wp on December 08, 2021, 12:17:18 pm
This new code is not yet available via OPM. You should either get the svn version from CCR, or download the zip-snapshot from https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/tvplanit/.
Title: Re: Visual PlanIt Overlay mode
Post by: chrv on December 13, 2021, 05:27:12 pm
Hello everyone,

I just did a simple test for PlanIt (see attachment, requires trunk version).
Everything goes well until I place 2 events in exactly the same place (same date and same time but with different "Description") => often (but not always) 1 of the 2 events disappears (only one event is visible).
The same appears with Overlay.
What am i missing ?
(you can use drag and drop to move events easily)

Thank you
Title: Re: Visual PlanIt Overlay mode
Post by: wp on December 14, 2021, 10:59:10 am
The overlapping "same" events issue should be fixed now. It was caused by the typical "don't do this with floating point values" mistake: do not compare floats by using the = operator, but allow for a tolerance due to round-off errors.

There is still an issue with drag and drop: When I add the first event to a new database and drag the event to another time slot the event is not deleted from the original time slot.
Title: Re: Visual PlanIt Overlay mode
Post by: chrv on December 14, 2021, 02:04:19 pm
I reinstalled the packege (r8177). Unfortunately, the same problem seems to persit unchanged on my test app.
Title: Re: Visual PlanIt Overlay mode
Post by: wp on December 14, 2021, 06:37:25 pm
Found another location which compares times using the >= and <= operators --> fixed. I do not see the disappearing "same" events any more, even when resources are overlaid.

If you still see the issue please give a description of the exact steps that I have to follow..
Title: Re: Visual PlanIt Overlay mode
Post by: chrv on December 15, 2021, 10:04:08 am
I send you an exemple (See attached app).

Event2 dragged on Event3 => OK
Event2 dragged on Event1 => Event2 disappears under Event1.
Title: Re: Visual PlanIt Overlay mode
Post by: wp on December 15, 2021, 10:17:03 am
You mean the demo attached to reply #10? There, the database provided is empty, there are no events.
Title: Re: Visual PlanIt Overlay mode
Post by: chrv on December 15, 2021, 12:19:49 pm
Excuse me.
Here is de good attachment

You can see that Event2 hide Event1 when dragged over Event1.
It is not the case when Event2 is draged over Event3.
Title: Re: Visual PlanIt Overlay mode
Post by: wp on December 15, 2021, 01:06:53 pm
I don't understand. The screenshot TvPlanIt-same-events-1 shows your application at first start: Event2 and Event1 share the same time slot, both are visible, nothing's hidden --> as expected. Then I dragged Event2 over Event3 --> screenshot-2, as expected. Then I dragged Event2 back over Event1 again --> screenshot-3, as expected (well, the order is different -- is this relevant?). And finally I dragged also Event3 over the others --> screenshot-4, again as expected.

Are you sure that you installed the most recent version of TvPlanIt from CCR?
Title: Re: Visual PlanIt Overlay mode
Post by: chrv on December 15, 2021, 03:06:42 pm
Here are my results for the 4 same situations. Quite different ? What am i doing wrong ?

I downloaded PlanIt on my PC from : Tree [r8180]  / components / tvplanit /
Windows 10
Lazarus 2.0.12
Title: Re: Visual PlanIt Overlay mode
Post by: wp on December 15, 2021, 05:23:27 pm
Checked TvPlanIt on Laz 2.0.12/FPC 3.2.0 (the previous tests were made with Laz/main and FPC 3.2.2) - no difference to my previous observations.

Running out of ideas...

Maybe this: Open file vpmisc.pas in the source folder of the TvPlanIt installation. Search for "SameTimeOrLater" and "SameTimeOrEarler". Do these functions exist? If they don't your installation is not up-to-date, contrary to your statement.

Or this: Did you recompile the tvplanit package after installation? if not the new code will not be be used. For simplicity, and to handle some other similar issues, do a clean rebuild of the entire IDE: "Tools" > "Configure Build Lazarus" > Check "Clean all" and "Switch after building to automatically" > Click "Build" - this will take some time, but everything related to an incomplete or outdated installation will be covered this way.
Title: Re: Visual PlanIt Overlay mode
Post by: chrv on December 16, 2021, 01:01:08 pm
Solved ...
Overlay mode works as expected.

It was clearly a problem of version. Sorry for troubles and time lost ...
Title: Re: Visual PlanIt Overlay mode
Post by: wp on December 16, 2021, 01:53:37 pm
No need to be sorry. It was interesting to revisit the code which I had ported several years ago.
Title: Re: Visual PlanIt Overlay mode
Post by: chrv on December 21, 2021, 10:26:59 pm
Hello everyone,

After several improvements, I arrive to a new problem.

As you can see in the attachment, when I try to use a TVpResourceCombo to drive a TVpDayView, I cannot display the item on the combo (see Form1, secondary form).
I can see the items in the list by dropping down it (2.png).
No problem to youse a TVpResourceCombo on the same form as the TVpDayView (See on the right of main form).

A short demo is attached.

Has anyone a solution ?
Title: Re: Visual PlanIt Overlay mode
Post by: wp on December 21, 2021, 11:32:47 pm
The second form is created after the main form. When you have the resource combobox on a second form, but all the other PlanIt stuff on the main form, the combo does not get notified that the datastore is set up because it does not yet exist.

Clear the Datastore property of the combobox on the second form. Then add the following code to the OnCreate handler of  this form:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   VpResourceCombo1.DataStore := MainForm.VpControlLink.DataStore;;
  4.   MainForm.ResourceChangeHandler(nil,MainForm.VpControlLink.Datastore.Resource);
  5. end;
When now the DataStore of the combo is set the combo reads all the required information and sets the selected item index.

Having to call a method of the main form here, kind of hurts me... I think I should spend some time to fully integrate the checkedlist box into the TVPlaint infrastructure...
Title: Re: Visual PlanIt Overlay mode
Post by: chrv on December 22, 2021, 07:41:23 am
It works fine.

Thank you very much
TinyPortal © 2005-2018