CoCreate User Forum

CoCreate User Forum (https://www.cocreateusers.org/forum/index.php)
-   Customization (https://www.cocreateusers.org/forum/forumdisplay.php?f=12)
-   -   icons in a graphical browser (https://www.cocreateusers.org/forum/showthread.php?t=8107)

rvn 09-26-2013 06:17 AM

icons in a graphical browser
 
Hi,

How is it possible to get the little icons next to a browsernode in a graphical browser. I can't find a command to do this, but it should be possible, because the structure browser has all kinds of icons in to it.

thanks in advance
greetings
Ruben

rvn 09-27-2013 12:20 AM

Re: icons in a graphical browser
 
After a bit of searching in google I found a solution with interrogators. So now I can place an icon next to the browsernodes in my new browser. But I still have a little problem, the icon is next to all the browsernodes instead of next to the selected one. How can I do this? My code is here below.

Code:

(in-package :mat)
(use-package :oli)
       
        (defvar *dirbrowser* "Materials")
       
        (defun dirbrowser-build-tree ()
                (setf parent
                        (sd-create-browsernode        :tree *dirbrowser*
                                                                        :parent nil
                                                                        :objPname "Materials")
                )
                (sd-create-browsernode  :tree *dirbrowser*
                                                                :parent parent
                                                                :objPname "Plate")
                (setf profile
                        (sd-create-browsernode  :tree *dirbrowser*
                                                                        :parent parent
                                                                        :objPname "Profile")
                )
                (sd-create-browsernode  :tree *dirbrowser*
                                                                :parent parent
                                                                :objPname "Round Bar")
                (sd-create-browsernode  :tree *dirbrowser*
                                                                :parent parent
                                                                :objPname "Square")
        )
       
        (defun dirbrowser-create ()
                (sd-destroy-browser-tree *dirbrowser*)
                (sd-create-browser-tree *dirbrowser* :update-func 'dirbrowser-build-tree)
                (sd-destroy-graphical-browser *dirbrowser*)
                (sd-create-graphical-browser *dirbrowser* :tree *dirbrowser* :createAsTab nil :tabname "Materials" :topLabel "Materials" :minHeight 400        :maxWidth 200 :maxHeight 1000 :tabImage "C:/Users/rvn/Dropbox/Programming/1-lisps/bmp/create.bmp")
                (sd-show-graphical-browser *dirbrowser* :position '("task-ds" :lefbottom))
        )
       
        (dirbrowser-create)
        (dirbrowser-build-tree)
       
        (sd-browser-add-interrogator        *dirbrowser*
                                                                        :interrogator-type :primary-pixmap
                                                                        :interrogator-func 'functie)
                                                               
        (defun functie (node name)
                (setf node (sd-get-browsernode-struct *dirbrowser* parent))
                (setf name (sd-browser-register-image        *dirbrowser*
                                                                                                :image "create"
                                                                                                :filename "C:/Users/rvn/Dropbox/Programming/1-lisps/bmp/create.bmp"
                                                                                                :type :primary-image))
        )


Andy Poulsen 09-27-2013 08:48 AM

Re: icons in a graphical browser
 
Hi Ruben,

As I indicated in email, the reason you're seeing icons for all items is that the interrogator isn't actually checking anything -- it's just returning the name of the image to use. So you need to update that function. I've fixed that, and made a few other changes to clean up the code, and I have also added a few comments. I think this will do what you need:
Code:

(in-package :mat)
(use-package :oli)

(defvar *dirbrowser* "Materials")

;; create a couple of variables to hold our parent node and profile node
(defvar *parent-node* nil)
(defvar *profile-node* nil)

(defun dirbrowser-build-tree ()
  (setf *parent-node* (sd-create-browsernode        :tree *dirbrowser*
                                                :parent nil
                                                :objPname "Materials"))
  (sd-create-browsernode  :tree *dirbrowser*
                          :parent *parent-node*
                          :objPname "Plate")
  (setf *profile-node*        (sd-create-browsernode  :tree *dirbrowser*
                                                :parent *parent-node*
                                                :objPname "Profile"))
  (sd-create-browsernode  :tree *dirbrowser*
                          :parent *parent-node*
                          :objPname "Round Bar")
  (sd-create-browsernode  :tree *dirbrowser*
                          :parent *parent-node*
                          :objPname "Square")
  )

(defun dirbrowser-create ()
  (sd-destroy-browser-tree *dirbrowser*)
  (sd-create-browser-tree *dirbrowser* :update-func 'dirbrowser-build-tree)
  (sd-destroy-graphical-browser *dirbrowser*)
  (sd-create-graphical-browser
  *dirbrowser* :tree *dirbrowser* :createAsTab nil :tabname "Materials"
  :topLabel "Materials" :minHeight 400        :maxWidth 200 :maxHeight 1000
  :tabImage "C:/Users/rvn/Dropbox/Programming/1-lisps/bmp/create.bmp")
  (sd-show-graphical-browser *dirbrowser* :position '("task-ds" :lefbottom))
  )

(dirbrowser-create)
(dirbrowser-build-tree)

;; register the image when this file is loaded.  Then we can use it any time.
(sd-browser-register-image *dirbrowser*
                        :image "create"
                        :filename "C:/Users/rvn/Dropbox/Programming/1-lisps/bmp/create.bmp"
                                :type :primary-image)

(defun functie (node name)
  ;; only return "create" when the node is the parent node
  (when (string= (browsernode-nodeid node) *parent-node*)
    "create"))

(sd-browser-add-interrogator        *dirbrowser*
                                :interrogator-type :primary-pixmap
                                :interrogator-func 'functie)

I hope this helps!

andy

rvn 10-17-2013 10:58 PM

Re: icons in a graphical browser
 
Hi Andy,

Thanks again for this, works great!

Greetings Ruben

andrea 04-13-2018 06:06 AM

Re: icons in a graphical browser
 
Is it possible to associate to these icons a "change color part and density" command?

So if I click them and then click on the piece in the 3D window, will I change the color and density of the part?


All times are GMT -8. The time now is 08:18 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.