Edit
Attach
Printable
topic end
<!-- * Set TOPICTITLE = <nop>CoCreate Modeling code examples: Color highlighting in the structure browser --> <style type="text/css"> pre { background-color:#FFEECC; } </style> ---++ <nop>CoCreate Modeling: Color highlighting in the structure browser <pre> ;; -*-Lisp-*- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Description: Highlights objects in browser using special colors ;; Author: Claus Brod ;; Language: Lisp ;; ;; (C) Copyright 2003 Claus Brod, all rights reserved ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (in-package :clausbrod.de) (use-package :oli) (defun my-color-interrogator (node name) (declare (ignore name)) (let* ((objname (BrowserNode-objPname node)) (objlist (oli:sd-string-split (BrowserNode-objPath node) "\"")) (objpath (if (> (length objlist) 1) (second objlist) (first objlist))) (obj (oli:sd-pathname-to-obj objpath)) ) (if (oli:sd-string-match-pattern-p "*Lochblech*" objname) "#ff0000" (if (oli:sd-string-match-pattern-p "*Distanz*" objname) "#0f0ff0" ) ) ) ) (sd-browser-add-interrogator "parcel-gbrowser" :interrogator-type :text-color :interrogator-func 'my-color-interrogator) </pre> I'll have to admit that I was hesitant to actually publish the above code. Why? Mostly because adding interrogators to a browser can have a significantly adverse effect on performance in the browser - so use this sparingly. The code above adds a so-called _interrogator_ to the structure browser. In this case, the interrogator is of type =:text-color=, i.e. it is called by the browser code whenever the browser needs to find out which color to use for the current entry. This feature can be used to highlight "special" objects in the browser. The definition of "special" is different for any user. The example code is quite dumb; it simply highlights all objects which have the substrings "Lochblech" or "Distanz" in their names. Again, interrogators are called quite often by the browser, so they should be short and sweet. In fact, the above code already violates this rule. If somebody finds a better way to decode the browser object node path than by doing string processing, please let me know. -- Main.ClausBrod --- Indeed that code does too much. Take this as a replacement: <pre> (defun my-color-interrogator (node name) (declare (ignore name)) (if (oli:sd-string-match-pattern-p "*Lochblech*" (BrowserNode-objPname node)) "#ff0000" (if (oli:sd-string-match-pattern-p "*Distanz*" (BrowserNode-objPname node)) "#0f0ff0" ) ) ) </pre> Only the Objname was used. I also removed the LET statement: I think that 2 times to read a value out of structure is better, because it avoids some lisp garbage (memory consumption). -- Main.DerWolfgang - 12 Nov 2004 Thanks Wolfgang! Your code is of course infinitely better! I have merged in your changes and [[%ATTACHURL%/browsercolors.lsp][attached]] the resulting code as a Lisp file. I will keep the above discussion as it is, though, because it is valuable in how it develops a better solution from the original proposal. Thanks again! -- Main.ClausBrod - 15 Nov 2004 I implemented a :text-color interrogator to highlight objects that lacked a Model Name (useful for us in a <nop>ModelManager environment) but in OSDM 2006 now there are pseudo-folders which return a <nop>BrowserNode-objPath of their Owner, and it is difficult in general to tell directly what class of object a given <nop>BrowserNode represents. Basically, we can see a Name and a path... is there any other information we can get that would help identify what class or type of object is being listed by the browser? Or in the case of a pseudo-folder, what type of items it "contains" ??? -- Main.TomBower - 25 Aug 2006 Unfortunately, I am not aware of a way to inquire the type of object from the browser node. But then, I wasn't involved in adding pseudo-folders and don't know too much about them, so I'd suggest to check with CoCreate support. -- Main.ClausBrod - 04 Sep 2006 --- %COMMENT{type="below" nonotify="on"}%The other issue we discovered with a :text-color interrogator is that once you have one, it masks the normal color behavior of standard Modeling (e.g. an invalid custom feature won't turn red any longer). This needs to be changed so that user-developed code can overlay on top of standard behavior, not replace it. -- Main.TomBower - 17 Sep 2009
to top
End of topic
Skip to action links
|
Back to top
Edit
|
Attach image or document
|
Printable version
|
Raw text
|
Refresh
|
More topic actions
Revisions: | r1.10 |
>
|
r1.9
|
>
|
r1.8
|
Total page history
|
Backlinks
You are here:
CoCreateModeling
>
MacroStructureBrowser
r1.10 - 17 Sep 2009 - 15:43 -
TomBower
to top
CoCreateModeling
CoCreate Modeling
FAQ
Introduction
Hardware
Operating system
Memory management
File handling
Installation
Licensing
Graphics
App. knowhow
Lisp
Learning
Programming
Debugging
DDE
Compiler
Customization
Troubleshooting
Links
Code examples
Viewbench
News
Changes
Index
Search
Impressum
Home
Webs
Atari
Blog
Claus
CoCreateModeling
Klassentreffen
Main
Sandbox
Sommelier
TWiki
Xplm
My links
edit
TWiki
Welcome
TWiki Web TWiki Web Home Changes Topics Index Search
TWiki Webs Atari Blog Main
OneSpaceModeling
?
Sandbox TWiki TWiki Webs Atari Blog Main
OneSpaceModeling
?
Sandbox TWiki
Jump:
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback