Jump to content
Jouher

Control (focus) another HM screen based on movement in first HM.

Recommended Posts

Hi,

I have to move, zoom in, zoom out my second hypermesh based on movement of mouse pointer in first hm screen. That is, the x,y,z in first hm sgould be replicated simulatanaeously in second hm.

 

This is to compare two models.

 

How can i code this. Pls help. Is it possible?

 

@tinh Do you have any idea, or code?

Share this post


Link to post
Share on other sites

Yes.

Set a timer with trigger proc that get view matrix of 1st hm, send this matrix to 2nd hm. 

2nd hm receives and display model with that view matrix

Share this post


Link to post
Share on other sites

@tinh Thanks Tin, can you explain with code briefly, if possible. what is trigger proc and how to get updated view matrix alone each time

Share this post


Link to post
Share on other sites

Hi Jouher,

 

This can be easily done in HyperView using Synchronize Windows to compare models. Unless you want to update mesh you should be able to compare models easily in HyperView. 

 

image.png.00b8638a928ba68c24d42123aa4e479e.png

Share this post


Link to post
Share on other sites

Because zoom in/ zoom out not recorded in command.tcl, you cannot catch that event

So I think periodically monitor viewmatrix, if it is changed we will send message to 2nd hm

 

A timer is created by command 'after'

A proc like this will self-repeated by a timer:

 

proc ::MonitorViewMatrix {Period Callback} {

     if {![info exists ::MonitorViewMatrix(matrix)]} {

          set ::MonitorViewMatrix(matrix) [hm_winfo viewmatrix]

     }

     set matrix [hm_winfo viewmatrix]

     if {![string equal $matrix ::MonitorViewMatrix(matrix)]} {

          catch {eval $Callback}

     }

     if {[info exists ::MonitorViewMatrix(timer)]} {

          after cancel $::MonitorViewMatrix(timer)

     }

     set ::MonitorViewMatrix(timer) [after $Period [list ::MonitorViewMatrix $Period $Callback]]

}

 

 

 

You have to prepare a callback proc, example ::SendTo2ndHm

Then start monitoring view changes by:

::MonitorViewMatrix 2000 ::SendTo2ndHm

 

 

To send a message to 2nd hm, you should use dde facility, or socket (need administrator account)

 

Are you familiar with client-server programming?

Refer to dde commands in Tcl/Tk manual.

 

Example::

Open a server on 2nd hm:

package require dde

dde servername -handler eval -- HM2

(HM2 may be changed if another already opened)

 

 

A simple ::SendTo2ndHm on 1st hm:

package require dde

proc ::SendTo2ndHm args {

     dde eval -async HM2 *viewset {*}[hm_winfo viewmatrix]

}

 

 

vipin and Livil Lyle like this

Share this post


Link to post
Share on other sites

Sorry, i forgot a claw (bold line)

 

 proc ::MonitorViewMatrix {Period Callback} {

     if {![info exists ::MonitorViewMatrix(matrix)]} {

          set ::MonitorViewMatrix(matrix) [hm_winfo viewmatrix]

     }

     set matrix [hm_winfo viewmatrix]

     if {![string equal $matrix ::MonitorViewMatrix(matrix)]} {

          catch {eval $Callback}

          set ::MonitorViewMatrix(matrix) $matrix

     }

     if {[info exists ::MonitorViewMatrix(timer)]} {

          after cancel $::MonitorViewMatrix(timer)

     }

     set ::MonitorViewMatrix(timer) [after $Period [list ::MonitorViewMatrix $Period $Callback]]

}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...