forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Some suggestions for future enhancements to Clearwin+
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
Wilfried Linder



Joined: 14 Nov 2007
Posts: 303
Location: Düsseldorf, Germany

PostPosted: Mon Aug 12, 2013 3:31 pm    Post subject: Reply with quote

Hi Eddie,

now I've used your idea and code for stretching a selected area and it works fine. So once again many thanks for your help!

Wilfried
Back to top
View user's profile Send private message Visit poster's website
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 1683
Location: Yateley, Hants, UK

PostPosted: Fri Aug 16, 2013 12:49 pm    Post subject: Reply with quote

Wilfried,

I'm really pleased that you liked it, but don't forget that Ian sorted out the XOR part so that it worked well. There is a benefit for me in doing things like this as I may be able to lose my fear of full_mouse_interrupts!

If you use this simple demonstration in production code, you will discover a problem. I used a very simple test about the left button. I did this deliberately, because testing coordinates is a much more obvious Fortran thing to do than sorting out the button presses! What I wrote probably won't work if the user presses Shift or Ctrl at the same time. If the mouse flags are IFL, then

Code:
           IF (and(IFL,MK_SHIFT)   .EQ.  MK_SHIFT)   THEN
               ISHFT  = 1
               ELSE
               ISHFT  = 0
               ENDIF
           IF (and(IFL,MK_CONTROL) .EQ. MK_CONTROL)  THEN
               ICTRL  = 1
               ELSE
               ICTRL  = 0
               ENDIF


... you can use the logical AND to determine if either of those keys have been pressed, also don't just test for 1 (left button) but sieve out the other button presses too (You might have different behaviour for them). I'm not good with these tests, so I do them once, and make some settings in integers that I can examine later, as in the example above. MK_SHIFT and MK_CONTROL are defined in the INS file.

Some suggestions I have for you are also that when I drew the node/handles, I drew them as circles. But you may have noticed, when I tested proximity, my test was in a square region!. You could draw handles other shapes, do other proximity tests, etc.

I also used 8 peripheral node handles: 4 corners, with free x-y movement; and 4 mid-sides, constrained to move only in x or y. If you use 4 corner node/handles, you can use the Shift or Ctrl modifiers to pull the shape into a general quadrilateral, or constrain the node to move in x or y (say), or use the right mouse button to keep it a quadrilateral.

You could also have a node/handle in the middle of the object which you could use to move it as a complete fixed shape in x, or y, or freely (again depending on Shift and Ctrl settings). I chose 8 node/handles partly because this might be familiar to you from the Paint application, but also it illustrated different behaviours for different nodes.

In Powerpoint, selecting an object draws control node/handles including one on a stalk that you can use to rotate the object. CorelDraw uses a second click on a node to select a rotatable mode, where the cursors are different. Moving a corner node rotates the object, and moving a mid-side node shears it (e.g. rectangle into parallelogram).

You need to consider the entire look and feel of your program, and the likely users, to see what settings to implement.

I hope that this is also helpful.

Eddie

(PS As I know you do finite element analysis, I also considered using shape functions to allow distortion of the shape as in Zienkiewicz's book, but it made the code too long. There is also then a limit on the amount of distortion before the element becomes ill-conditioned. You can also consider using area-select to pick up more than one node/handle or the whole object).
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 1683
Location: Yateley, Hants, UK

PostPosted: Fri Aug 16, 2013 1:08 pm    Post subject: Reply with quote

Paul,

Quote:
I have had another go at %ob[rounded]. Please test today's beta upload.


Sorry, I missed this until this morning, and was away from my computer for a couple of days anyway. I had a go, and fine, it ignores the outer invisible box. It minimises and restores as it should.

But, using my settings of:

Code:
      IA=WINIO@('%bg[btnface]%sy[3d_thin]')


.... I found the top right and bottom left corners appeared in white only, and this didn't look right to me. In the interests of trying to be helpful, I also looked at the other 3d options, e.g. 3d_raised, 3d_depressed and plain 3d, and while the white corner in these positions sounds as if it might be right to do the shading, I think that you could forget that attempt and it would look better - just do it in the default colour (black in my example).

The rounded corners certainly make the application look more modern, and in my various attempts I was impressed at the look of the %sy options I haven't used.

Thanks for this effort.

I sometimes feel that the bottom of a box is too close to what goes before, and Clearwin+ outsmarts me if I just put in a blank character. However, if I put in a character (such as a full stop) in the right colour, I can outsmart the box to give me more space! (The full stop even just about works if I forget to set its colour).

Eddie
Back to top
View user's profile Send private message
Wilfried Linder



Joined: 14 Nov 2007
Posts: 303
Location: Düsseldorf, Germany

PostPosted: Fri Aug 16, 2013 6:13 pm    Post subject: Reply with quote

Eddie,

to get info about the mouse I use

Code:
      mouse_x = clearwin_info@('GRAPHICS_MOUSE_X')+1
      mouse_y = clearwin_info@('GRAPHICS_MOUSE_Y')+1
      m_flag  = AND(clearwin_info@('GRAPHICS_MOUSE_FLAGS'),31)
      m_info  = adjustl(clearwin_string@('call_back_reason'))


and then

Code:
      if (m_info(1:12) .eq. 'MOUSE_DOUBLE')
     *  m_info(1:20) = 'MOUSE_LEFT_CLICK    '
 
      if (m_info(1:16) .eq. 'MOUSE_LEFT_CLICK' .or.
     *    m_info(1:17) .eq. 'MOUSE_RIGHT_CLICK') then
c
c        ... something
        remember = m_flag
c
      else if (m_info(1:18) .eq. 'MOUSE_LEFT_RELEASE' .or.
     *    m_info(1:19) .eq. 'MOUSE_RIGHT_RELEASE') then
c
c       ... something else
        m_flag = remember
c
      end if


I found some values by testing - for instance, pressing the central mouse wheel gives the value 8 for m_flag.

In my image display I use the mouse wheel to set the zoom factor. This can be done with something like

Code:
      wparam= clearwin_info@('MESSAGE_WPARAM')
      i = hiword@(wparam)


... then with i the zoom factor is calculated.

My experience is that with Clearwin+ and WinAPI and a lot of time of trial and testing (and also colleagues like here in the forum!) it is possible to do nearly everything with Fortran under Windows.

Best regards and a nice evening
Wilfried
Back to top
View user's profile Send private message Visit poster's website
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 1683
Location: Yateley, Hants, UK

PostPosted: Fri Aug 16, 2013 6:38 pm    Post subject: Reply with quote

Wilfried,

I never experimented with the mouse wheel for zooming, I always chose (initially) to zoom in steps, or (later) to zoom to a selected area. I shall have to try the wheel.

I didn't know if I made it clear, but the mouse flags are a combination of all the settings, and if you can be sure that the user only does one thing, you can test for that. If the user does more than one thing together, you need to sort out precisely what is going on (hence the logical AND function) - otherwise, you are doing much the same as I do (I think that this is an engineer's response, rather than a computer scientist's method!).

I found full_mouse_interrupts (FMI) problematic some years ago, and use them only rarely through fear (probably). Although John Campbell gave me a lot of help, in retrospect I think I got in a mess because I expected the same behaviour with and without full_mouse_interrupts, and in some important respects, it is different. For example, when you get the callback reason MOUSE_LEFT_CLICK, without FMI it means the left mouse button has been depressed AND released, where as with FMI, it only means depressed only - released give a different callback reason! If you interrogate the mouse flags you decide for yourself what the mouse button status is. This isn't very clear in the documentation, although it is best described in the CHM file in the "library reference" under "CLEARWIN_STRING@".

Eddie
Back to top
View user's profile Send private message
Wilfried Linder



Joined: 14 Nov 2007
Posts: 303
Location: Düsseldorf, Germany

PostPosted: Sat Aug 17, 2013 6:50 am    Post subject: Reply with quote

Eddie,

I always use full_mouse_input within the %gr graphics area. Is this what you mean saying full_mouse_interrupt? The behaviour of callback reasons like mouse_left_click are not modified if I press shift and/or ctrl, therefore I had no problems with getting mouse parameters up to now.

Wilfried
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 5046
Location: Salford, UK

PostPosted: Sat Aug 17, 2013 7:51 am    Post subject: Reply with quote

If you hold down the CTRL key whilst using the mouse wheel then you are often provided with a zoom. This includes Google Chrome (that I am using at the moment) and recent versions of Plato (not sure when I added this).

You get the same effect from a pinch movement on the mouse pad or on the screen of a tablet (i.e. the CTRL key state is added automatically by the system).

Next question: is there an easy way to get the CTRL key state in ClearWin+ when processing a mouse wheel event? If not then I need to add something.
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 1683
Location: Yateley, Hants, UK

PostPosted: Sat Aug 17, 2013 9:40 am    Post subject: Reply with quote

Hi Wilfried,

You are correct: it is the automatic behaviour of my fingers without the connection of my brain that writes "interrupts" instead of "input". Many decades ago, we were not insulated from the (optional) mouse driver software by Windows. An "interrupt" was generated by the mouse software every time it moved or was clicked, so that the cpu could save what it was doing, respond in some way, and then return where it left off. Assuming that deep down the PC is still working much the same way, the mouse message in Windows is probably responding to an interrupt. Paul would know.

If you don't use FMI (input, not interrupt!) then you get MOUSE_LEFT_CLICK on the button release, not the button press. Now I understand the difference, I may lose my fear of FMI!

Eddie
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 1683
Location: Yateley, Hants, UK

PostPosted: Sat Aug 17, 2013 10:08 am    Post subject: Reply with quote

Paul,

The effect you describe also works in Internet Explorer. In view of this, it is probably an emerging standard.

Are Shift and Ctrl button presses what is meant by extended mouse events (http://msdn.microsoft.com/en-us/library/cc240587.aspx) and equivalent to buttons 4 and 5? (Rhetorical question - I wouldn't understand the answer!) - in which case they should be reasonably easy to sort out from the flags.

It would be very useful to add something at some point to be able to decipher a pinch, stretch or swipe movement - eventually. At the moment I think your suggestion to help the Fortran-only speaker sort this out is an excellent one. It would be a great gesture (pun intended!)

(Another rhetorical question: if a pinch = Ctrl + Mouse wheel, is a "negative pinch" Ctrl + negative wheel motion, and if so, what is mapped to Shift+mouse wheel etc?).

If Windows 8 tablet support is contemplated, then it would be very important to be able to determine if a physical keyboard was connected.

Eddie
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 5046
Location: Salford, UK

PostPosted: Sat Aug 17, 2013 11:00 am    Post subject: Reply with quote

I have added the following information to cwplus.enh.

%^gr[full_mouse_input] already provides the callback reason "MOUSE_WHEEL". When this event is processed, mouse data can
be obtained by calling clearwin_info@ with any of the following arguments:
"GRAPHICS_MOUSEWHEEL_ROTATION", "GRAPHICS_MOUSE_FLAGS", "GRAPHICS_MOUSE_X", and "GRAPHICS_MOUSE_Y".

A mouse wheel event combined with holding down the CTRL key is usually interpreted as "Zoom in" or "Zoom out". Also when
a pinching movement is used on a mouse pad or on a touch sensitive screen, the system translates this to a mouse wheel
event with the CTRL key held down. To test for the CTRL key state, take the bitwise AND of the mouse flags with MK_CONTROL
(MK_CONTROL has the value 8).
Back to top
View user's profile Send private message
IanLambley



Joined: 17 Dec 2006
Posts: 468
Location: Sunderland

PostPosted: Sat Aug 17, 2013 11:09 am    Post subject: Reply with quote

The get_mouse_info@ and the clearwin_info@ equivalent methods only provides the shift and control information if a mouse button is pressed prior to and held during the mouse wheel action. The states can be obtained at any time, see code below. I have shown it called from within one of my mouse wheel callback routines to show the information is available, but I only print the info.
Code:

      Integer*4 function OnMouseWheel()
      implicit real*8 (a-h,o-z)
      include <windows.ins>
      include 'params.inc'
      include 'drawtool.inc'
      include 'f77pcs.for'
      integer*4 wheel_rot,wparam,zoom_back,zoom_in
c     and get the wheel scroll values from WPARAM in OnMouseWheel:
      OnMouseWheel = 2
      if(mod(idraw_mode,2) .eq.0)then   !Normal P&ID window

        wparam = clearwin_info@('MESSAGE_WPARAM')
        wheel_rot = HIWORD@(wparam) / 120 ! rotations reported as *120
        call set_zoom_factor(sqrt(sqrt(2d0)))
        if(wheel_rot .eq. 1)then
          i = zoom_in()
        elseif(wheel_rot .eq. -1)then
          i = zoom_back()
        endif
        call set_zoom_factor(sqrt(2d0))
        i = i
      endif
      print *,modkeystates()
      end

      integer*4 function modkeystates()
! get states of shift, control and alt modifier keys - not left right dependent
      include <windows.ins>
      integer*4 test_bit@
      integer*1 key_shift,key_control,key_alt
      key_shift   = GetKeyState(VK_SHIFT)
      key_control = GetKeyState(VK_CONTROL)
      key_alt     = GetKeyState(VK_MENU)
      modkeystates = test_bit@(key_shift,7)     +
     &               test_bit@(key_control,7)*2 +
     &               test_bit@(key_alt,7)    *4
      end

      integer*4 function modkeystates1()
! get states of shift, control and alt modifier keys - left & right dependent
! bits 0 to 2 are identical to non-handed version
! bits 3 to 5 are left hand sensitive
! bits 6 to 8 are right hand sensitive
      include <windows.ins>
      integer*4 test_bit@
      integer*1 key_lshift,key_lcontrol,key_lalt
      integer*1 key_rshift,key_rcontrol,key_ralt
      key_lshift   = GetKeyState(VK_LSHIFT)
      key_lcontrol = GetKeyState(VK_LCONTROL)
      key_lalt     = GetKeyState(VK_LMENU)
      key_rshift   = GetKeyState(VK_RSHIFT)
      key_rcontrol = GetKeyState(VK_RCONTROL)
      key_ralt     = GetKeyState(VK_RMENU)
      modkeystates1 = modkeystates() +
     &                test_bit@(key_lshift,7)  *  8 +
     &                test_bit@(key_lcontrol,7)* 16 +
     &                test_bit@(key_lalt,7)    * 32 +
     &                test_bit@(key_rshift,7)  * 64 +
     &                test_bit@(key_rcontrol,7)*128 +
     &                test_bit@(key_ralt,7)    *256
      end



Last edited by IanLambley on Sat Aug 17, 2013 12:03 pm; edited 3 times in total
Back to top
View user's profile Send private message Send e-mail
Wilfried Linder



Joined: 14 Nov 2007
Posts: 303
Location: Düsseldorf, Germany

PostPosted: Sat Aug 17, 2013 11:33 am    Post subject: Reply with quote

This is my code for setting the zoom factor:

Code:
C ====================================================================== CCCC
c     define zoom steps

      MODULE ZOOM_STEPS

      integer*4,dimension(20)::ztab=(/10,13,18,25,35,50,71,100,141,200,
     *              283,400,566,800,1131,1600,2263,3200,4525,6400/)
      end

C ====================================================================== CCCC

      INTEGER FUNCTION MAUS_ZOOM()

c     zoom with mouse wheel

      USE ZOOM_STEPS

      IMPLICIT NONE
      INCLUDE <WINDOWS.INS>

      integer*4     i,j,WPARAM

      WPARAM = CLEARWIN_INFO@('MESSAGE_WPARAM')
      i = HIWORD@(WPARAM)

      do j = 1,20
        if (zoom == ztab(j)) exit
      end do
      if (i > 0) then
        if (j < 20) zoom = ztab(j+1)
      else
        if (j > 1) zoom = ztab(j-1)
      end if
c
c     refresh the graphics
c
      maus_zoom = 3
      end


There is no influence by any keys pressed or not, including Shift, Ctrl and combinations of keys, also no influence by any mouse button pressed or released.

Wilfried
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 5046
Location: Salford, UK

PostPosted: Sat Aug 17, 2013 11:42 am    Post subject: Reply with quote

Various conversations...

John

Not sure about your comment. I tested without pressing a mouse button. Only mouse wheel movement and hold key down. Granted you would normally hold the key down a little before moving the mouse wheel.

Eddie

I have now fixed the %sy[3d] and %ob[rounded] combination. However, it doesn't look good to me because the various shades of grey do not work well together (the background colour matches one of the scoring colours so two of the corners don't look right).
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 1683
Location: Yateley, Hants, UK

PostPosted: Sat Aug 17, 2013 12:00 pm    Post subject: Reply with quote

Ian,

Most useful. I presume that the three includes aren't really required, and the + in the penultimate line isn't either.

Eddie
Back to top
View user's profile Send private message
IanLambley



Joined: 17 Dec 2006
Posts: 468
Location: Sunderland

PostPosted: Sat Aug 17, 2013 12:06 pm    Post subject: Reply with quote

Eddie,
Absolutely correct, the includes in the first routine were specific to my code and can be omitted for other users, but was just there as a demo.

And yes, the "+" was just me getting carried away now edited from the post.
Thanks
Ian
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Goto page Previous  1, 2, 3, 4  Next
Page 3 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group