Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r651 - in branches/itanium2: Core/Shm Core/Util fox


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r651 - in branches/itanium2: Core/Shm Core/Util fox
  • Date: Mon, 24 Oct 2005 03:10:37 -0600 (MDT)

Author: abe
Date: Mon Oct 24 03:10:35 2005
New Revision: 651

Modified:
   branches/itanium2/Core/Shm/MFStreamData.cc
   branches/itanium2/Core/Shm/MFStreamData.h
   branches/itanium2/Core/Util/Args.cc
   branches/itanium2/Core/Util/Args.h
   branches/itanium2/fox/FMantaImageFrame.cc
   branches/itanium2/fox/FMantaTrackballNav.cc
   branches/itanium2/fox/FMantaWindow.cc
   branches/itanium2/fox/FMantaWindow.h
   branches/itanium2/fox/MediaFusionApp.cc
   branches/itanium2/fox/MediaFusionBridge.cc
   branches/itanium2/fox/MediaFusionBridge.h
   branches/itanium2/fox/sc_demo.cc
Log:


All major functionality now works via media fusion. 

We are still missing a command here and there but Nigel is looking into it.

M    Core/Shm/MFStreamData.cc
M    Core/Shm/MFStreamData.h
M    fox/FMantaTrackballNav.cc
M    fox/MediaFusionApp.cc
M    fox/MediaFusionBridge.cc
M    fox/MediaFusionBridge.h
M    fox/FMantaImageFrame.cc
M    fox/sc_demo.cc

Rearranged interface so that control sliders are on the bottom.
M    fox/FMantaWindow.cc
M    fox/FMantaWindow.h

Added function to parse resolution spec from a string.
M    Core/Util/Args.cc
M    Core/Util/Args.h


Modified: branches/itanium2/Core/Shm/MFStreamData.cc
==============================================================================
--- branches/itanium2/Core/Shm/MFStreamData.cc  (original)
+++ branches/itanium2/Core/Shm/MFStreamData.cc  Mon Oct 24 03:10:35 2005
@@ -90,11 +90,13 @@
     stream_data->refCount++;
   }
 
+#if 0
   std::cerr << "Shared memory area: "           << std::endl
             << "size: " << sizeof(MFStreamData) << std::endl
             << "id:   " << stream_data->shmID      << std::endl
             << "key:  " << stream_data->key     << std::endl
             << "address: " << this_ptr          << std::endl;
+#endif
   
   return this_ptr;
 }

Modified: branches/itanium2/Core/Shm/MFStreamData.h
==============================================================================
--- branches/itanium2/Core/Shm/MFStreamData.h   (original)
+++ branches/itanium2/Core/Shm/MFStreamData.h   Mon Oct 24 03:10:35 2005
@@ -108,12 +108,14 @@
         MOUSE_STATE_MIDDLE = 0x2,
         MOUSE_STATE_LEFT   = 0x4,
 
-        KEYPRESS  = 100, // data is a xevent keysym id (A = 65)
-        DEVPRESS  = 101, // data is a xevent keysym id (F1 = 65470)
-        MOUSE_X   = 102, // data is the x position of the mouse.
-        MOUSE_Y   = 103, // data is the y position of the mouse.
-        MOUSE_BTN = 104, // data is a MOUSE_STATE id (possibled or'ed 
together)
-        MOUSE_MOD = 105  // data is a ... ?
+        KEYPRESS   = 100, // data is a xevent keysym id (A = 65)
+        DEVPRESS   = 101, // data is a xevent keysym id (F1 = 65470)
+        MOUSE_X    = 102, // data is the x position of the mouse.
+        MOUSE_Y    = 103, // data is the y position of the mouse.
+        MOUSE_BTN  = 104, // data is a MOUSE_STATE id (possibled or'ed 
together)
+        MOUSE_MOD  = 105, // data is a ... ?
+        MODPRESS   = 106,
+        MODRELEASE = 107
       };
       
       int command[MAX_NUM_SSCMD];

Modified: branches/itanium2/Core/Util/Args.cc
==============================================================================
--- branches/itanium2/Core/Util/Args.cc (original)
+++ branches/itanium2/Core/Util/Args.cc Mon Oct 24 03:10:35 2005
@@ -80,20 +80,37 @@
       char* ptr = const_cast<char*>(args[i].c_str());
       int tmpxres = (int)strtol(ptr, &ptr, 10);
       if(ptr == args[i].c_str() || *ptr != 'x'){
-       i--;
-       return false;
+        i--;
+        return false;
       }
       char* oldptr = ++ptr; // Skip the x
       int tmpyres = (int)strtol(ptr, &ptr, 10);
       if(ptr == oldptr || *ptr != 0){
-       i--;
-       return false;
+        i--;
+        return false;
       }
       xres = tmpxres;
       yres = tmpyres;
       return true;
     }
   }
+
+  bool getResolutionArg(const string& arg, int& xres, int& yres)
+  {
+    char* ptr = const_cast<char*>(arg.c_str());
+    int tmpxres = (int)strtol(ptr, &ptr, 10);
+    if(ptr == arg.c_str() || *ptr != 'x'){
+      return false;
+    }
+    char* oldptr = ++ptr; // Skip the x
+    int tmpyres = (int)strtol(ptr, &ptr, 10);
+    if(ptr == oldptr || *ptr != 0){
+      return false;
+    }
+    xres = tmpxres;
+    yres = tmpyres;
+    return true;
+  }  
 
   bool getPointArg(int& i, const vector<string>& args, Point& p)
   {

Modified: branches/itanium2/Core/Util/Args.h
==============================================================================
--- branches/itanium2/Core/Util/Args.h  (original)
+++ branches/itanium2/Core/Util/Args.h  Mon Oct 24 03:10:35 2005
@@ -20,6 +20,9 @@
   bool getVectorArg(int& i, const vector<string>&, Vector& p);
   void parseSpec(const string& spec, string& name, vector<string>& args);
 
+  // Parse a resolution value from a string.
+  bool getResolutionArg(const string& arg, int& xres, int& yres);
+  
   // Generic version that grabs an argument of type T.
   template<typename T>
   bool getArg(int& i, const vector<string>& args, T& result) {

Modified: branches/itanium2/fox/FMantaImageFrame.cc
==============================================================================
--- branches/itanium2/fox/FMantaImageFrame.cc   (original)
+++ branches/itanium2/fox/FMantaImageFrame.cc   Mon Oct 24 03:10:35 2005
@@ -53,14 +53,19 @@
 // Fox event on window resize.
 long FMantaImageFrame::onConfigure  ( FXObject *sender, FXSelector sel, void 
*data ) {
 
-       // Send a transaction to manta, notifying change resolution.
-       manta_interface->addTransaction("resize",
-                                                                             
                                                          Callback::create( 
manta_interface,                  // Call on this.
-                                                                             
                                                                              
                                                    
&RTRTInterface::changeResolution, // This method.
-                                                                             
                                                                              
                                                    manta_channel,            
        // These args.
-                                                                             
                                                                              
                                                    getWidth(),
-                                                                             
                                                                              
                                                    getHeight(),
-                                                                             
                                                                              
                                                    true ) );
+  std::cerr << "ImageFrame resize" << std::endl;
+
+  if (shown()) {
+  
+    // Send a transaction to manta, notifying change resolution.
+    manta_interface->addTransaction("resize",
+                                    Callback::create( manta_interface,       
           // Call on this.
+                                                      
&RTRTInterface::changeResolution, // This method.
+                                                      manta_channel,         
           // These args.
+                                                      getWidth(),
+                                                      getHeight(),
+                                                      true ) );
+  }
        return 1;
 }
 
@@ -70,12 +75,10 @@
        FXEvent *event = (FXEvent *)data;
        FXushort sel_type = FXSELTYPE( sel );
 
-       // std::cout << "Click count: " << event->click_count << std::endl;
-
        // Check for a double click.
        if (event->click_count == 2) {
                if (fox_target)
-                       return 
fox_target->handle(this,FXSEL(FXSELTYPE(sel),ID_PIXEL_SELECT),data);
+                       return 
fox_target->handle(this,FXSEL(FXSELTYPE(sel),0),data);
                return 0;
        }
 
@@ -102,7 +105,12 @@
 
   // std::cerr << "Key pressed: " << event->text.text() << std::endl;
 
-       return navigator->onKeyPress( sender, sel, data );
+  // Check for a tab key.
+  if (event->text[0] == '\t') {
+    return 
fox_target->handle(this,FXSEL(FXSELTYPE(sel),ID_PIXEL_SELECT),data);
+  }
+  else
+    return navigator->onKeyPress( sender, sel, data );
 }
 
 bool FMantaImageFrame::shootOneRay( int pixel_x, int pixel_y, Point 
&result_position, Vector &result_normal ) {
@@ -117,7 +125,14 @@
        int xres, yres;
        bool stereo;
        rtrt->getResolution( manta_channel, stereo, xres, yres );
-       
+
+  // Determine if we should use the ImageFrame height or the actual image 
hight.
+  int image_height;
+  if (shown())
+    image_height = getHeight();
+  else
+    image_height = yres;
+  
        // Determine the image coordinates of the pixel.
        Real image_x, image_y;
        
@@ -128,7 +143,7 @@
   Real yoffset = (-yres/2.+0.5)*yscale;
        
        image_x = pixel_x * xscale + xoffset;
-       image_y = (getHeight() - pixel_y) * yscale + yoffset;
+       image_y = (image_height - pixel_y) * yscale + yoffset;
        
        // Create a ray packet.
        RayPacketData data;

Modified: branches/itanium2/fox/FMantaTrackballNav.cc
==============================================================================
--- branches/itanium2/fox/FMantaTrackballNav.cc (original)
+++ branches/itanium2/fox/FMantaTrackballNav.cc Mon Oct 24 03:10:35 2005
@@ -53,12 +53,16 @@
                break;
        case SEL_RIGHTBUTTONPRESS:
                mouse_down[2] = true;
-       
+
+    printf("Right button. state: 0x%x SHIFTMASK 0x%x\n", event->state, 
SHIFTMASK );
+    
                // Two clicks of the right button changes the lookat point.
                if ((event->state & SHIFTMASK) == SHIFTMASK) {
                        // New center of rotation.
                        Point lookat;
                        Vector normal;
+
+      std::cerr << "Setting center of rotation. " << event->win_x << " " << 
event->win_y << std::endl;
                        
                        if (manta_frame->shootOneRay( event->win_x, 
event->win_y, lookat, normal )) {
                                manta_interface->addTransaction("camera 
lookat",

Modified: branches/itanium2/fox/FMantaWindow.cc
==============================================================================
--- branches/itanium2/fox/FMantaWindow.cc       (original)
+++ branches/itanium2/fox/FMantaWindow.cc       Mon Oct 24 03:10:35 2005
@@ -79,15 +79,18 @@
 
 
FXIMPLEMENT(FMantaWindow,FXMainWindow,FMantaWindowMap,ARRAYNUMBER(FMantaWindowMap));
 
-FMantaWindow::FMantaWindow( FXApp *app, const FXString &name, int width, int 
height,
+FMantaWindow::FMantaWindow( FXApp *app, const FXString &name,
+                            int width, int height,
+                            int xres,  int yres,
                                                                              
                                  FXIcon *ic,FXIcon *mi,FXuint opts,FXint 
x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb,FXint hs,FXint 
vs )
-       : FXMainWindow( app, name, ic, mi, opts, x, y, w, h, pl, pr, pt, pb, 
hs, vs ),
+       : FXMainWindow( app, name, ic, mi, opts, x, y, width, height, pl, pr, 
pt, pb, hs, vs ),
        
          manta_interface( 0 ),
                fast_quit( false ) ,
                cutting_snap( 1 ),
                extra_options_dialog( 0 )
 {
+  
/////////////////////////////////////////////////////////////////////////////
        // Menu Bar.
        menu_bar = new FXMenuBar( this, LAYOUT_FILL_X );
        
@@ -138,34 +141,38 @@
        cutting_flip  = new FXMenuCommand( options_menu, "Flip Cutting 
Plane", 0, this, ID_CUTTING_FLIP );
        cutting_flip->disable();
 
-       // extra_options = new FXMenuCommand( options_menu, "Extra Options", 
0, this, ID_EXTRA_OPTIONS );
-       // extra_options->disable();
   new FXMenuSeparator( options_menu );
        
        new FXMenuTitle( menu_bar, "Options", 0, options_menu );
 
+  
/////////////////////////////////////////////////////////////////////////////
        // Create the content of the window.
-       FXComposite *frame = new FXHorizontalFrame( this, LAYOUT_FILL );
-       FXComposite *left_controls  = new FXVerticalFrame( frame, 
LAYOUT_FILL_Y|LAYOUT_LEFT );
-       FXComposite *viewers        = new FXVerticalFrame( frame, LAYOUT_FILL 
);
-       FXComposite *right_controls = new FXVerticalFrame( frame, 
LAYOUT_FILL_Y|LAYOUT_RIGHT );
+  FXComposite *frame = 0;
+  FXComposite *viewers  = new FXVerticalFrame( this, LAYOUT_FILL );
+       FXComposite *controls = new FXVerticalFrame( this, 
FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_SIDE_BOTTOM );
 
-       // Manta Image Frame.
-       manta_frame = new FMantaImageFrame( viewers, app, this, width, 
height, 0 );
-       
+  
/////////////////////////////////////////////////////////////////////////////
+  // Sliders.
+  
        // Control speed.
-       speed_slider = new FXRealSlider( left_controls, this, 
ID_SPEED_SLIDER, REALSLIDER_VERTICAL|LAYOUT_FILL_Y );
+  frame = new FXHorizontalFrame( controls, LAYOUT_FILL_X );
+  new FXLabel( frame, "Control Speed: " );
+       speed_slider = new FXRealSlider( frame, this, ID_SPEED_SLIDER, 
REALSLIDER_HORIZONTAL|LAYOUT_FILL_X );
        speed_slider->setRange( 0.001, 5.0 );
        
        // Cutting plane slider.
-       cutting_slider = new FXRealSlider( right_controls, this, 
ID_CUTTING_SLIDER, REALSLIDER_VERTICAL|LAYOUT_FILL_Y );
+  frame = new FXHorizontalFrame( controls, LAYOUT_FILL_X );
+  new FXLabel( frame, "Cutting Plane: " );
+       cutting_slider = new FXRealSlider( frame, this, ID_CUTTING_SLIDER, 
REALSLIDER_HORIZONTAL|LAYOUT_FILL_X );
        cutting_slider->setRange( -1.0, 1.0 );
        cutting_slider->setValue( 0.0 );
        cutting_slider->disable();
        
-       frame = new FXHorizontalFrame( viewers, LAYOUT_FILL_X );
 
+  
/////////////////////////////////////////////////////////////////////////////
        // Navigators.
+  frame = new FXHorizontalFrame( controls, LAYOUT_FILL_X );
+  new FXLabel( frame, "Camera Controls:" );
        navigator_list = new FXListBox( frame, this, ID_NAVIGATOR_LIST, 
LAYOUT_BOTTOM|COMBOBOX_STATIC,0,0,0,20 );
        navigator_list->setNumVisible( 3 );
        
@@ -175,9 +182,16 @@
        
        new FXButton( frame, "Add", 0, this, ID_ADD_BOOKMARK );
 
+  
/////////////////////////////////////////////////////////////////////////////
   // Camera paths dialog.
   camera_path_dialog = new FMantaRecorderDialog( this, "Path Recorder" );
   camera_path_dialog->hide();
+
+  
//////////////////////////////////////////////////////////////////////////////
+       // Manta Image Frame.
+       manta_frame = new FMantaImageFrame( viewers, app, this, width, 
height, 0 );
+
+
 }
 
 void FMantaWindow::addExtraOptionsDialog( const FXString &name, FXDialogBox 
*extra_options_dialog_ ) {

Modified: branches/itanium2/fox/FMantaWindow.h
==============================================================================
--- branches/itanium2/fox/FMantaWindow.h        (original)
+++ branches/itanium2/fox/FMantaWindow.h        Mon Oct 24 03:10:35 2005
@@ -120,7 +120,11 @@
                
                // Constructors.
                FMantaWindow() : manta_interface( 0 ), fast_quit( false ) {  
};
-               FMantaWindow( FXApp *app, const FXString &name, int width = 
512, int height = 512,
+               FMantaWindow( FXApp *app, const FXString &name,
+                  
+                  int width = 512, int height = 512, // Dimensions of the gui
+                  int xres  = 512, int yres   = 512, // Dimensions of the 
image.
+                  
                              FXIcon *ic=NULL,FXIcon *mi=NULL,FXuint 
opts=(DECOR_ALL),
                                                                        FXint 
x=50,FXint y=50,FXint w=512,FXint h=512,FXint pl=0,FXint pr=0,FXint 
pt=0,FXint pb=0,FXint hs=0,FXint vs=0);
                

Modified: branches/itanium2/fox/MediaFusionApp.cc
==============================================================================
--- branches/itanium2/fox/MediaFusionApp.cc     (original)
+++ branches/itanium2/fox/MediaFusionApp.cc     Mon Oct 24 03:10:35 2005
@@ -17,7 +17,9 @@
 MediaFusionApp::MediaFusionApp(const FXString& name,const FXString& vendor ) 
:
   FXApp( name, vendor ),
   mf_target_id( 0 )
-{ }
+{
+  event.state = 0x0;
+}
 
 
////////////////////////////////////////////////////////////////////////////////
 // dispatchEvents
@@ -55,7 +57,7 @@
         event.win_y=ev.xkey.y;
         event.root_x=ev.xkey.x_root;
         event.root_y=ev.xkey.y_root;
-        event.state=ev.xkey.state&~(Button4Mask|Button5Mask);     // Exclude 
wheel buttons
+        // event.state=ev.xkey.state&~(Button4Mask|Button5Mask);     // 
Exclude wheel buttons
 
         // Translate to keysym
         n = XLookupString( &ev.xkey, buf, sizeof(buf), &sym, NULL );
@@ -82,6 +84,8 @@
           if(sym==KEY_F13) event.state|=METAMASK;     // Key between Ctrl 
and Alt (on most keyboards)
           if(sym==KEY_Alt_L) event.state|=ALTMASK;
           if(sym==KEY_Alt_R) event.state|=ALTMASK;    // FIXME do we need 
ALTGR flag instead/in addition?
+
+          // printf( "event.state after press: 0x%x\n", event.state );
         }
         else{
           if(sym==KEY_Shift_L) event.state&=~SHIFTMASK;
@@ -91,8 +95,12 @@
           if(sym==KEY_F13) event.state&=~METAMASK;    // Key between Ctrl 
and Alt (on most keyboards)
           if(sym==KEY_Alt_L) event.state&=~ALTMASK;
           if(sym==KEY_Alt_R) event.state&=~ALTMASK;   // FIXME do we need 
ALTGR flag instead/in addition?
+
+          // printf( "event.state after release: 0x%x\n", event.state );
         }
 
+
+        
         // Send the FXEvent on to the target window handler.
         if (window->handle( this, FXSEL(event.type,ID_MEDIA_FUSION_APP), 
&event )) {
           refresh();
@@ -109,11 +117,13 @@
         event.win_y  = ev.xmotion.y;
         event.root_x = ev.xmotion.x_root;
         event.root_y = ev.xmotion.y_root;
-        event.state  = ev.xmotion.state&~(Button4Mask|Button5Mask);        
// Exclude wheel buttons
+        // event.state  = ev.xmotion.state&~(Button4Mask|Button5Mask);       
 // Exclude wheel buttons
         event.code   = 0;
         
-        if((FXABS(event.root_x-event.rootclick_x)>=6) || 
(FXABS(event.root_y-event.rootclick_y)>=6))
-           event.moved=1;
+        if((FXABS(event.root_x-event.rootclick_x)>=6) || 
(FXABS(event.root_y-event.rootclick_y)>=6)) {
+          event.moved=1;
+          event.click_count=0;
+        }
 
         if (window->handle( this, FXSEL(event.type,ID_MEDIA_FUSION_APP), 
&event )) {
           refresh();
@@ -132,10 +142,10 @@
         event.win_y=ev.xbutton.y;
         event.root_x=ev.xbutton.x_root;
         event.root_y=ev.xbutton.y_root;
-        event.state=ev.xbutton.state&~(Button4Mask|Button5Mask);          // 
Exclude wheel buttons
+        // event.state=ev.xbutton.state&~(Button4Mask|Button5Mask);          
// Exclude wheel buttons
 
-        // Ignore the mouse wheel.
         event.code=ev.xbutton.button;
+
         if(ev.xbutton.type==ButtonPress){                               // 
Mouse button press
 
           // Check which button is pressed.
@@ -144,9 +154,12 @@
           
if(ev.xbutton.button==Button3){event.type=SEL_RIGHTBUTTONPRESS;event.state|=RIGHTBUTTONMASK;}
 
           // Check to see if the cursor remained in one position and double 
clicked
-          if(!event.moved && (event.time-event.click_time<400) && 
(event.code==(FXint)event.click_button)) {
+          if(!event.moved && (event.time-event.click_time<500) && 
(event.code==(FXint)event.click_button)) {
             event.click_count++;
             event.click_time=event.time;
+
+            // std::cout << "Multiple click " << event.click_count << 
std::endl;
+                        
           }
           else{
             // Reset the click count
@@ -159,9 +172,11 @@
             event.click_time=event.time;
           }
           
-          if(!(ev.xbutton.state&(Button1Mask|Button2Mask|Button3Mask)))
-            event.moved=0;
-          
+          // if(!(ev.xbutton.state&(Button1Mask|Button2Mask|Button3Mask))) {
+          //std::cout << "Moved=0" << std::endl;
+          event.moved=0;
+            //}
+
         }
 
         else {                                                           // 
Mouse button release
@@ -170,6 +185,8 @@
           
if(ev.xbutton.button==Button3){event.type=SEL_RIGHTBUTTONRELEASE;event.state&=~RIGHTBUTTONMASK;}
         }
 
+        // printf( "Event state: 0x%x\n", event.state );
+        
         // Send the event to the target window
         if (window->handle( this, FXSEL(event.type,ID_MEDIA_FUSION_APP), 
&event )) {
           refresh();

Modified: branches/itanium2/fox/MediaFusionBridge.cc
==============================================================================
--- branches/itanium2/fox/MediaFusionBridge.cc  (original)
+++ branches/itanium2/fox/MediaFusionBridge.cc  Mon Oct 24 03:10:35 2005
@@ -67,9 +67,7 @@
 void MediaFusionBridge::run() {
 
   // Attach to the shm segment.
-  std::cerr << "MediaFusionBridge starting targed window: " << window_id
-            << " root: " << root_id
-            << std::endl;
+  std::cerr << "Listening for MediaFusion commands..." << std::endl;
 
   try {
     stream_data = new( shm_key, false ) MFStreamData;
@@ -105,20 +103,27 @@
     for (int i=0;i<packet.size;++i) {
 
       switch (packet.command[i]) {
-      case MFSPacket::KEYPRESS:
 
+      case MFSPacket::MODRELEASE:
+
+        // Send a key press event.
+        key_event( KeyRelease, packet.data[i] );
+        break;
+        
+      case MFSPacket::MODPRESS:
+      case MFSPacket::KEYPRESS:
+        
         // Send a key press event.
-        keypress_event( packet.data[i] );
+        key_event( KeyPress, packet.data[i] );
           
         break;
       case MFSPacket::DEVPRESS:
-        std::cerr << "DEVPRESS: " << packet.data[i] << std::endl;
+        // std::cerr << "DEVPRESS: " << packet.data[i] << std::endl;
 
         // Function keys etc.
         
         break;
       case MFSPacket::MOUSE_X:
-        // Note that atleast in the streamviewer test program, the y 
coordinate went across the screen.
         // std::cerr << "MOUSE_X: " << packet.data[i] << std::endl;
 
         // Update mouse coordinate.
@@ -132,22 +137,25 @@
         // std::cerr << "MOUSE_Y: " << packet.data[i] << std::endl;
 
         // Update mouse coordinate.
-        mouse_y = packet.data[i];
+        mouse_y = (stream_data->yres - packet.data[i]);
         
         // Send a mouse motion event.
         motion_event();
 
         break;
       case MFSPacket::MOUSE_BTN:
-        std::cerr << "MOUSE_BTN: " << packet.data[i] << std::endl;
+        // std::cerr << "MOUSE_BTN: " << packet.data[i] << std::endl;
         
         mf_button = packet.data[i];
 
+#if 0        
         // Avoid out of range commands.
-        if ((mf_button < 0) || (mf_button > 7))
+        if ((mf_button != 0) && !(
+            (mf_button & MFSPacket::MOUSE_STATE_LEFT) ||
+            (mf_button & MFSPacket::MOUSE_STATE_LEFT) ||
+            (mf_button & MFSPacket::MOUSE_STATE_LEFT)))
           break;
-
-        printf( "Before mouse_state: 0x%x\nCurrent mouse_button: 0x%x\n", 
mouse_state, mouse_button );
+#endif
         
         
///////////////////////////////////////////////////////////////////////
         // Update the button state.
@@ -215,10 +223,10 @@
         // Send mouse update event.
 
         // button_press_event();
-        printf( "After mouse_state: 0x%x\nCurrent mouse_button: 0x%x\n", 
mouse_state, mouse_button );        
+        // printf( "After mouse_state: 0x%x\nCurrent mouse_button: 0x%x\n", 
mouse_state, mouse_button );        
         break;
       case MFSPacket::MOUSE_MOD:
-        std::cerr << "MOUSE_MOD: " << packet.data[i] << std::endl;
+        // std::cerr << "MOUSE_MOD: " << packet.data[i] << std::endl;
 #if 0
         state = packet.data[i];
         modifier_state = 0x0;
@@ -265,7 +273,7 @@
   }
 }
 
-void MediaFusionBridge::keypress_event( int keysym ) {
+void MediaFusionBridge::key_event( int type, int keysym ) {
 
   XEvent event;
   KeyCode keycode;
@@ -283,10 +291,10 @@
   //           << std::endl;
 
   // Create an send a Key press event.
-  event.xany.type        = KeyPress;
+  event.xany.type        = type;
   event.xkey.root        = root_id;
   event.xkey.subwindow   = 0;
-  event.xkey.time        = CurrentTime;
+  event.xkey.time        = SCIRun::Time::currentSeconds() * 1000.0;
   event.xkey.x           = mouse_x;
   event.xkey.y           = mouse_y;
   event.xkey.x_root      = mouse_x;
@@ -313,7 +321,7 @@
   event.xany.type            = MotionNotify;
   event.xmotion.root         = root_id;
   event.xmotion.subwindow    = 0;  
-  event.xmotion.time         = CurrentTime;
+  event.xmotion.time         = SCIRun::Time::currentSeconds() * 1000.0;
   event.xmotion.x            = mouse_x;
   event.xmotion.y            = mouse_y;
   event.xmotion.x_root       = mouse_x;
@@ -339,7 +347,7 @@
   event.xany.type            = event_type;
   event.xbutton.root         = root_id;
   event.xbutton.subwindow    = 0;  
-  event.xbutton.time         = CurrentTime;
+  event.xbutton.time         = SCIRun::Time::currentSeconds() * 1000.0;
   event.xbutton.x            = mouse_x;
   event.xbutton.y            = mouse_y;
   event.xbutton.x_root       = mouse_x;

Modified: branches/itanium2/fox/MediaFusionBridge.h
==============================================================================
--- branches/itanium2/fox/MediaFusionBridge.h   (original)
+++ branches/itanium2/fox/MediaFusionBridge.h   Mon Oct 24 03:10:35 2005
@@ -62,7 +62,7 @@
     int modifier_state;
     
     // Helper methods.
-    void keypress_event( int keysym );
+    void key_event( int type, int keysym );
     void motion_event();
     void button_event( int event_type );
     

Modified: branches/itanium2/fox/sc_demo.cc
==============================================================================
--- branches/itanium2/fox/sc_demo.cc    (original)
+++ branches/itanium2/fox/sc_demo.cc    Mon Oct 24 03:10:35 2005
@@ -64,128 +64,12 @@
 #include <Model/Groups/TransparentKDTree.h>
 #include <Model/Materials/CopyColorMaterial.h>
 
+#include <fox/FMantaTransparent.h>
+
 #include <fox/MediaFusionApp.h>
 
 using namespace Manta::Kdtree;
 
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-// Digital Mockup Dialog Box.
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-class DmDemoDialog : public FXDialogBox {
-       FXDECLARE(DmDemoDialog)
-private:
-       FXListBox    *render_mode_box;
-       // FXRealSlider *alpha_slider;
-       FMantaRealSlider *alpha_slider;
-
-       FMantaWindow *manta_window;
-       
-       KDTree *kdtree;
-       TransparentKDTree *transparent_kdtree;
-       
-public:
-       enum {
-               ID_RENDER_MODE_SELECT = FXDialogBox::ID_LAST,
-               ID_ALPHA_SLIDER,
-               ID_LAST
-       };
-       DmDemoDialog() {  };
-       DmDemoDialog( FMantaWindow *manta_window_,
-                     KDTree *kdtree_, TransparentKDTree *transparent_kdtree_,
-                                                               const 
FXString &name, FXuint opts=DECOR_ALL,
-                                                   FXint x=50,FXint 
y=50,FXint w=0,FXint h=0,FXint pl=10,
-                                                               FXint 
pr=10,FXint pt=10,FXint pb=10,FXint hs=4,FXint vs=4 );
-       
-       void setKdtrees( KDTree *kdtree_, TransparentKDTree 
*transparent_kdtree_ ) {
-               kdtree = kdtree_; transparent_kdtree = transparent_kdtree_; }
-       
-       void create() { FXDialogBox::create(); show( PLACEMENT_DEFAULT ); };
-       
-       long onRenderModeSelect( FXObject *sender, FXSelector key, void *data 
);
-       long onAlphaSlider     ( FXObject *sender, FXSelector key, void *data 
);
-
-};
-
-FXDEFMAP(DmDemoDialog) DmDemoDialogMap[] = {
-       
//////////////////////////////////////////////////////////////////////////////
-       //        Message_Type ID                                   
Message_Handler
-       FXMAPFUNC(SEL_COMMAND, DmDemoDialog::ID_RENDER_MODE_SELECT,    
DmDemoDialog::onRenderModeSelect ),
-       FXMAPFUNC(SEL_COMMAND, DmDemoDialog::ID_ALPHA_SLIDER,          
DmDemoDialog::onAlphaSlider )
-};     
-
-FXIMPLEMENT(DmDemoDialog,FXDialogBox,DmDemoDialogMap,ARRAYNUMBER(DmDemoDialogMap));
-
-
-DmDemoDialog::DmDemoDialog( FMantaWindow *manta_window_,
-                                                                             
                                  KDTree *kdtree_, TransparentKDTree 
*transparent_kdtree_,
-                                                                             
                                  const FXString &name, FXuint opts,
-                                                                             
                                  FXint x,FXint y,FXint w,FXint h,FXint pl,
-                                                                             
                                  FXint pr,FXint pt,FXint pb,FXint hs,FXint 
vs ) : 
-       manta_window( manta_window_ ),
-       kdtree( kdtree_ ), transparent_kdtree( transparent_kdtree_ ),
-       FXDialogBox ( manta_window_->getApp(), name, opts, x, y, w, h, pl, 
pr, pt, pb, hs, vs ) 
-{
-
-       RTRTInterface *manta_interface = manta_window->getMantaInterface();
-       
-       FXHorizontalFrame *frame = new FXHorizontalFrame( this );
-
-       // Add render mode selection box.
-       render_mode_box = new FXListBox( frame, this, ID_RENDER_MODE_SELECT );
-       render_mode_box->appendItem( "Opaque Surfaces", 0, kdtree );
-       render_mode_box->appendItem( "Transparent Surfaces", 0, 
transparent_kdtree );
-       
-       // Add alpha slider.
-       frame = new FXHorizontalFrame( this, LAYOUT_FILL_X );
-       new FXLabel( frame, "Alpha: " );
-       // alpha_slider = new FXRealSlider( frame, this, ID_ALPHA_SLIDER, 
LAYOUT_FILL_X );
-       
-       alpha_slider = new FMantaRealSlider( frame, 
-                       new FMantaSet<TransparentKDTree,Real>( 
manta_interface, transparent_kdtree, &TransparentKDTree::setAlpha ),
-                       LAYOUT_FILL_X );
-                       
-       alpha_slider->setRange( 0.0, 1.0 );
-       alpha_slider->setValue( transparent_kdtree->getAlpha() );
-       alpha_slider->disable();
-       
-}
-
-long DmDemoDialog::onRenderModeSelect( FXObject *sender, FXSelector key, 
void *data ) {
-
-       // Determine which option selected.
-       int index = render_mode_box->getCurrentItem();
-       Object *new_root = (Object *)render_mode_box->getItemData( index );
-       
-       if (new_root == kdtree) {
-               alpha_slider->disable();
-       }
-       
-       if (new_root == transparent_kdtree) {
-               alpha_slider->enable();
-       }
-       
-       manta_window->setSceneObject( new_root );
-
-       return 1;
-}
-
-long DmDemoDialog::onAlphaSlider     ( FXObject *sender, FXSelector key, 
void *data ) {
-
-       // Set the control speed for interaction.
-       Real alpha = *((double *)data);
-       
-       manta_window->getMantaInterface()->addTransaction("Set Alpha",
-               Callback::create( transparent_kdtree, 
&TransparentKDTree::setAlpha,alpha));
-       
-       return 1;
-
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
 
 // XXX to be replaced!
 namespace fox_manta {
@@ -214,6 +98,12 @@
   int shm_key = 100;
 
   
+  int width = 512; // Dimensions of the gui.
+  int height = 256;
+
+  int xres = 512; // Dimensions of the image.
+  int yres = 512; 
+    
        // Look for specific args.
        for (int i=0;i<argc;++i) {
                string arg = argv[i];
@@ -235,6 +125,11 @@
     else if (arg == "-key") {
       shm_key = atoi( argv[++i] );
     }
+    else if(arg == "-res"){
+      if(!getResolutionArg( (argv[++i]), xres, yres)){
+        std::cerr << "Error parsing resolution should be in form NxM" << 
std::endl;
+      }
+    }
        }
        
        std::cerr << "Using " << np << " workers plus one gui thread." << 
std::endl;
@@ -244,15 +139,23 @@
   MediaFusionApp app( "", "Abe Stephens -- SGI" );
        app.init( argc, argv );
 
-       int width = 512;
-       int height = 512;
-
        // Add an FMantaWindow.
-       FMantaWindow manta_window( &app, "Open-Source MANTA. Silicon Graphics 
Inc. and SCI Institute, University of Utah", width, height );
-       
+       FMantaWindow manta_window( &app, "Open-Source MANTA. Silicon Graphics 
Inc. and SCI Institute, University of Utah",
+                             width, height, xres, yres );
+
+       // Create the manta image frame.
+       FMantaImageFrame *manta_frame = manta_window.getMantaFrame();
+  
+  // Hide the GLX Image frame since we will be using media fusion.
+  manta_frame->hide();
+  
        // Create the application's windows.
        app.create();
 
+  // Instruct the MediaFusionApp to intercept events for the frame.
+  app.setTargetId( manta_frame->id() );
+  
+  
/////////////////////////////////////////////////////////////////////////////
        // Construct Manta.
        RTRTInterface *manta_interface = createRTRT();
        
@@ -268,20 +171,19 @@
        manta_interface->selectRenderer       ( "raytracer" );
        manta_interface->selectShadowAlgorithm( "hard" );
        
-       // Camera *camera = new PinholeCamera( Point ( 0.0, 0.0, 0.0 ), Point 
( 0.0, -1.0, 0.0 ), Vector( 0.0, 0.0, 1.0 ), 60 );
-       
-       // Create the manta image frame.
-       FMantaImageFrame *manta_frame = manta_window.getMantaFrame();
-
-  std::cout << "X Window id: " << manta_frame->id() << std::endl;
-
-  // Set the target window id to intercept external events for.
-  app.setTargetId( manta_frame->id() );
-
   
/////////////////////////////////////////////////////////////////////////////
   // Create a SHMImageDisplay.
   SHMImageDisplay image_display( shm_key );
 
+  // Add a transaction to resize to the target resolution.
+  manta_interface->addTransaction("resize",
+                                  Callback::create( manta_interface,         
         
+                                                    
&RTRTInterface::changeResolution, 
+                                                    0,                    
+                                                    xres,
+                                                    yres,
+                                                    true ) );
+  
   
/////////////////////////////////////////////////////////////////////////////
   // Create a user interface event listener for the shm segment.
   MediaFusionBridge mf_bridge( (Window)manta_frame->id(),
@@ -385,7 +287,7 @@
                
                // Create a new extra options dialog.
                manta_window.addExtraOptionsDialog( "Transparency",
-      new DmDemoDialog( &manta_window, kdtree, transparent_kdtree, 
"Transparency" ));
+      new FMantaTransparentDialog( &manta_window, kdtree, 
transparent_kdtree, "Transparency" ));
                
        }
        




  • [MANTA] r651 - in branches/itanium2: Core/Shm Core/Util fox, abe, 10/24/2005

Archive powered by MHonArc 2.6.16.

Top of page