Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Wednesday, May 13, 2020 7:24:17 AM(UTC)
roman112233

Groups: Registered
Posts: 1


How to make grid auto-fit and resize after deleting of one series? That is my question

Hey everyone. I'm working with JS Medical Viewer. I want to resize grid automatically after I remove one series and fit every non-empty cell into new layout(for example 4 -> 3)
Example of my investigation is looking like this(I don't mind rows for now):
Code:

viewer.layout.beginUpdate();
viewer.get_gridLayout().set_rows(1);
viewer.get_gridLayout().set_columns(tab.itemCount - 1);

It sort of works, but two points:
a) for example I had 3 rows, then removed one series, grid rerendered to two rows, if I open new image - there will be 4 cells(and expected number is 3). So it remembers layout somewhere I can't find where
b) If I remove the very first image, cell will remain empty. If we had three images and I delete left one - I get 2-cell grid, one of cells is going to be empty and 3rd image is not displaying. So I would like to know how to remove cell from grid and repaint accordingly.
For removing cells I use
Code:

$commangular.dispatch('DeleteCell');
// or 
viewer.layout.get_items().remove(cell);
viewer.emptyDivs.items.remove(cell);
disposeAutomation(cell.get_automation());
seriesManagerService.remove_cell(cell);
cell.dispose();


Sorry if there were similar question, and thank you for the attention
Also, why is there no native method for removing all empty cells from grid and refitting it?
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Thursday, May 14, 2020 2:20:22 PM(UTC)
Christopher

Groups: Registered, Tech Support, Administrators
Posts: 66

Was thanked: 3 time(s) in 3 post(s)

Hi Roman,

The LEADTOOLS Medical Viewer has two separate options to create the grid layout controls needed to display and manage DICOM files.
The two available are ‘Grid’ and ‘Random’ which can be found in the CellsArrangment Enumeration for you to declare.

The Grid arrangement allows the medical viewer engine to manage the insertion of data, images, tags, etc.

gridView.png

In order to maintain the symmetry and organized look of the cells; when a grid has an odd or fewer than the declared row/column number of images, it automatically configures these to insert a blank cells. To further organize these in the way that works for your development, the CellGridLayout Class can help to define certain parameters.
Built into these blank cells is the ability to _click and add to the cell directly.

As an extension of the LayoutManager Object, you can use the emptyDivs Property to identify these cells and remove excess.

The other option is the Random Arrangement.
This option requires that you define the bounds of each cell as you wish, albeit without some of the properties, methods, and commands that are managed by the Medical Viewer in Grid view.
This will require more coding, but will provide precision manipulation from a development standpoint.

In your described scenario, where you are wanting these excess cells removed to limit or even eliminate the cells, you will need to follow the logic provided in the pseudo code from below. (please note that this in written in C# but the logic is the focus)
What this code logic does, is identify the cell count to adjust the grid view accordingly.
Essentially, anytime that the collection of cells is an odd number, the row is reduced down to 1 so that all are displayed.
This should be checked on both the add and remove events that you create (possibly including the invalidate() method as described in ‘b’).

Code:
public void medicalViewerCells()
      {
         int activeCells = medicalViewer.Cells.Count();
         
         if ((activeCells % 2) == 1)
         {
            if (medicalViewer.Cells.Count() == 3)
            {
               medicalViewer.Rows = 1;
               medicalViewer.Columns = 3;
            }
            else
            {
               medicalViewer.Columns = medicalViewer.Cells.Count();
               medicalViewer.Rows = 1;
               
               //If one blank cell at the end of the last row is acceptable - 
               //then replace the two lines above with the two lines below
               
               //(((medicalViewer.Cells.Count()) / 2) + 1);
               //medicalViewer.Rows = ((medicalViewer.Cells.Count()) / medicalViewer.Columns);

            }
         }
         else if ((activeCells % 2) == 0)
         {
            if (medicalViewer.Cells.Count() == 2)
            {
               medicalViewer.Rows = 1;
               medicalViewer.Columns = 2;
            }
            else
            {
               medicalViewer.Columns = ((medicalViewer.Cells.Count()) / 2);
               medicalViewer.Rows = ((medicalViewer.Cells.Count()) / medicalViewer.Columns);
            }
         }
      }


b)
To redraw the medical viewer you can add an invalidate() Method to the logic operations since this will update the view anytime a cell is either removed or added.

Additional References
Leadtools.Controls.Medical Namespace
https://www.leadtools.co...script/cm/namespace.html
Chris Thompson
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2020, Yet Another Forum.NET
This page was generated in 0.071 seconds.