DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

DIAdem add custom panel item

Hello,

 

Is it possible to add a custom panel item to the existing items (NAVIGATOR, VIEW, ANALYSIS, REPORT, DAC, VISUAL, SCRIPT)?

 

I now how to add buttons in the panel items and how to add menu items, but I couldn't find if it is possible to extend the DIAdem panel.

 

With kind regards,

Stijn

0 Kudos
Message 1 of 8
(5,862 Views)

Hi Stijn,

 

You can add new large panel icons to the panel icon bar on the left of DIAdem.  What you can't do is create a new workspace in the middle of DIAdem.  So even if a user clicks on your new custom panel icon, they will still always ne in the workspace of one of the normal DIAdem panels.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 8
(5,748 Views)
Hi Brad,

How can I add a new large panel item? What is the script command?

I want to add a button which include buttons which do for instance automatic calculations with the data in the Data Portal.

I added these buttons at the moment in the VIEW panel, but It will be nice if the buttons are easy to find/access in al the panels.

Thanks!

With kind regards,
Stijn
0 Kudos
Message 3 of 8
(5,716 Views)

Hi Stijn,

 

Here's a good start for you.

 

Call AddPanelIcon(IconFileName, ScriptFilePath)


Sub AddPanelIcon(IconFileName, ScriptFilePath)
  Dim ButtonIDs, ButtonNames, ButtonIcons, ButtonScripts
  ButtonIDs = Array("Separator", "GrabFlukeWaveform")
  ButtonNames = Array("", "Grab Fluke Waveform")
  ButtonIcons = Array("", IconFileName)
  ButtonScripts = Array("", ScriptFilePath)
  Call AddActionObjects(ButtonIDs, ButtonNames, ButtonIcons, ButtonScripts)
  Call AddButtons(BarManager.Bars("DIAPanels"), ButtonIDs, Array(1, 1))
End Sub ' AddPanelIcon()


Function AddActionObjects(ButtonIDs, ButtonNames, ButtonIcons, ButtonScripts)
  Dim j, iMax, jMax, ActionObjects, ActionObj
  ActionObjects = Array("")
  IF IsArray(ButtonIDs) THEN
    jMax = UBound(ButtonIDs)
    ReDim ActionObjects(jMax)
    ReDim Preserve ButtonNames(jMax)
    ReDim Preserve ButtonIcons(jMax)
    ReDim Preserve ButtonScripts(jMax)
    FOR j = 1 TO jMax
      IF ButtonIDs(j) <> "" THEN
        IF BarManager.ActionObjs.Exists(ButtonIDs(j)) THEN
          Set ActionObj = BarManager.ActionObjs(ButtonIDs(j))
          Call BarManager.ActionObjs.Remove(ButtonIDs(j))
        END IF
        Set ActionObjects(j) = BarManager.ActionObjs.Add(ButtonIDs(j), "CustomButton")
        ActionObjects(j).ToolTip = ButtonNames(j)
        IF Left(ButtonScripts(j), 11) = "BarManager." THEN
          ActionObjects(j).OnClickCode.Code = ButtonScripts(j)
        ELSE
          ActionObjects(j).OnClickCode.Code = "Call ScriptStart(""" & ButtonScripts(j) & """)"
        END IF
        ActionObjects(j).Picture = ButtonIcons(j)
      END IF ' ButtonIDs(j) <> ""
    NEXT ' j
  END IF ' IsArray(ButtonIDs)
AddActionObjects = ActionObjects
End Function ' AddActionObjects()


Function AddButtons(Bar, ButtonIDs, ButtonFlags)
  Dim j, iMax, jMax, Buttons
  Buttons = Array("")
  IF IsArray(ButtonIDs) THEN
    jMax = UBound(ButtonIDs)
    ReDim Buttons(jMax)
    ReDim Preserve ButtonFlags(jMax)
    FOR j = jMax TO 1 Step -1
      IF Bar.UsedActionObjs.Exists(ButtonIDs(j)) THEN
        Call Bar.UsedActionObjs.Remove(ButtonIDs(j))
      END IF
    NEXT ' j
    iMax = Bar.UsedActionObjs.Count
    IF NOT Bar.UsedActionObjs(iMax).ID = "Separator" AND ButtonIDs(0) = "Separator" THEN
      Call Bar.UsedActionObjs.Add("Separator")
    END IF
    FOR j = 1 TO jMax
      IF (ButtonFlags(j)) THEN Call Bar.UsedActionObjs.Add(ButtonIDs(j))
    NEXT ' j
  END IF ' IsArray(ButtonIDs)
AddButtons = Buttons
End Function ' AddButtons()

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Message 4 of 8
(5,671 Views)

Hello Brad,

 

Thanks for the script! I used parts from your example and I managed it to add an own button in the Panel bar.

I also added buttons behind this panel bar button, but I want to have a Group bar in between. How can I add a group bar? And how do I know/set the name of the new panel bar (Bar ID).

 

With kind regards,

Stijn 

 

 

0 Kudos
Message 5 of 8
(5,566 Views)

HI Stijn,

 

The important thing to remember when creating a "new" panel in DIAdem is that you really haven't.  You've created a new big panel icon, yes, but when the user clicks on it, he/she is still in one of the normal panels, where by default there already is a group icon bar.  You can customize that group bar, but the user is probably going to expect you to customize it back to the normal state when they "leave" your custom panel.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 6 of 8
(5,467 Views)

Hi, I found this topic very interesting and I got the code to work except for the icon itself, iI get a question mark icon with the error "the file is not available"...what am I doing wrong ?

0 Kudos
Message 7 of 8
(3,250 Views)

Hi DescInno,

 

The custom icon you want to display has to exist in a known DIAdem folder to show up correctly.  The easiest way to do this is to add your custom icon file to the following DIAdem folder that contains the shipping icon files:

 

"C:\Program Files (x86)\National Instruments\DIAdem 2017\Resource\BarSource\"

 

Brad

0 Kudos
Message 8 of 8
(3,238 Views)