[IGSTK-Users] Displaying spatial objects in 2D views

Luis Ibanez luis.ibanez at kitware.com
Tue Mar 27 10:41:14 EDT 2007


Hi Sophie,

As Patrick pointed out, what happens is that the View classes
are not exposing the functionality for setting the camera
parameters.


     This is a new feature that we must implement.


What you can do in the meantime is to add to the View
class, method such as :


void SetCameraPosition( double x, double y, double z )
{
   m_Camera->SetPosition ( x,y,z );
}


void SetCameraViewUp( double x, double y, double z )
{
   m_Camera->SetViewUp( x,y,z );
}


void ResetCamera()
{
   m_Renderer->ResetCamera();
}


Note that these three method are *horrific abominations*
of the principle of State Machine encapsulation.

Use them as a temporary measure ONLY.


We will implement them correctly as


     RequestSetCameraPosition()
     RequestSetCameraViewUp()
     RequestResetCamera()


along with their corresponding state machine inputs,
states and transitions.


Actually, if you want to make easier your transition
to future versions of IGSTK, you could already rename
your methods with the "Request" prefix.  Make sure to
put a very visible warning message in the documentation.



    Regards,


       Luis



--------------------
Patrick Cheng wrote:
> Hi Sophie,
> 
> This is not a very convenient way to display an image, I have to use 
> mouse to drag the image to the center every time after I loaded it.
> 
> If you read the thread on "image origin problem", I think jjina1028 had 
> the same problem. You can take Luis's suggestion, or hack into the 
> camera in View class and set the focus point to the image center.
> 
> We are considering refactoring the View class in the near future, we 
> will cover your concern at that time.
> 
> Patrick
> 
> Sophie Blestel wrote:
> 
>> Hi,
>>
>> So it isn't possible to represent a spatial objet on 2D views exept if 
>> it is in the corner ?
>>
>> 2007/3/26, Patrick Cheng <cheng at isis.georgetown.edu 
>> <mailto:cheng at isis.georgetown.edu>>:
>>
>>     Hi Sophie,
>>
>>     Because the initial camera focus point is set to (0,0,0)
>>     If your object is at location:
>>
>>     transform.SetTranslation (100, 0.1, 1000);
>>
>>     The object will appear at one of the four corners depending on the 
>> view
>>     orientation(Axial, Coronal, and Sagittal). Because the camera will 
>> try
>>     to accommodate everything in the window.
>>
>>     I will try your code to see if there is any issue of the cone object.
>>
>>     Patrick
>>
>>     ---------- Original Message ----------------------------------
>>     From: "Sophie Blestel" < sophie.blestel at gmail.com
>>     <mailto:sophie.blestel at gmail.com>>
>>     Date:  Mon, 26 Mar 2007 11:22:53 +0200
>>
>>      >Hi,
>>      >
>>      >I try to display a cone in 3D and 2D views, with a location and
>>     orientation
>>      >given. But on the 2D views the cone remains in the origin (on the
>>     right high
>>      >corner ) (on the 3D views it is well represented).
>>      >
>>      >This is my code :
>>      >
>>      >First I declare and initialise the cone :
>>      >    ConeType::Pointer m_Cone = ConeType::New();
>>      >    ConeRepresentationType::Pointer m_ConeRepresentation     =
>>      >ConeRepresentationType::New();
>>      >
>>      >    transform.SetTranslation (100, 0.1 , 1000);
>>      >
>>      >    m_Cone->RequestSetTransform( transform );
>>      >    m_ConeRepresentation->RequestSetConeObject( m_Cone );
>>      >
>>      >
>>      >I create my 4 views (Axial, Sagittal, Coronal and 3D) in a file
>>     .FL as
>>      >follows :
>>      >    Fl_Box DisplaySagittal {
>>      >          label {Display Sagittal}
>>      >          xywh {550 0 380 330} box FLAT_BOX color 0 labelcolor 7
>>      >          class {igstk::View2D}     }
>>      >
>>      >Then I set the orientation ok the 2D views :
>>      >    DisplayAxial->RequestSetOrientation( View2D::Axial );
>>      >    DisplaySagittal->RequestSetOrientation( View2D::Sagittal );
>>      >    DisplayCoronal->RequestSetOrientation( View2D::Coronal );
>>      >
>>      >And I add the cone representation to the 2D and 3D views :
>>      >    DisplayAxial->RequestAddObject( m_ConeRepresentation );   //
>>     if I do
>>      >m_ConeRepresentation->Copy() the cone disappears
>>      >    DisplaySagittal->RequestAddObject( m_ConeRepresentation );
>>      >    DisplayCoronal->RequestAddObject( m_ConeRepresentation );
>>      >    Display3D->RequestAddObject( m_ConeRepresentation );
>>      >
>>      >For each view, I do :
>>      >    DisplaySagittal->RequestResetCamera();
>>      >    DisplaySagittal->Update();
>>      >    DisplaySagittal->RequestEnableInteractions();
>>      >    DisplaySagittal->RequestSetRefreshRate( 20 );
>>      >    DisplaySagittal->RequestStart();
>>      >
>>      >And this is my loop :
>>      >    while(m_tms->mainWindow->visible())
>>      >    {
>>      >        Fl::wait(0.05);
>>      >        igstk::PulseGenerator::CheckTimeouts();
>>      >        Fl::check();
>>      >    }
>>      >
>>      >
>>      >Thanks for helping me,
>>      >
>>      >Sophie
>>      >
>>      >
>>      >
>>
>>
> _______________________________________________
> IGSTK-Users mailing list
> IGSTK-Users at public.kitware.com
> http://public.kitware.com/cgi-bin/mailman/listinfo/igstk-users
> 



More information about the IGSTK-Users mailing list