Control (focus) another HM screen based on movement in first HM.
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?
Answers
-
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
0 -
@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
0 -
@tinh and zoom in zoom out is not recorded in command file. what to do?
0 -
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.
0 -
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]
}
0 -
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]]
}
0