Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Friday, February 24, 2006 3:00:39 AM(UTC)
dgVisioscopie

Groups: Registered
Posts: 3


Hi,

 

We are using C#, .Net 2.0, VS 2005 and Leadtools 14.5 Medical Imaging Suite.

 

We are using RasterViewer, Annotation Manager, Automation and Container in our project.

 

I would like to know if it is possible to assign, by code, MeasurementUnit = AnnUnit.SmartMetric to all new Rulers ?

 

Because, when you are drawing a ruler, you can read the length in Inch.

 

We are a European software manufacturer company, and we need to have all our annotations objects using Metric system by default.

 

How can j do this?

 

How can I assign by code default properties to annotation layers (default color, measurement unit …) with and without annotation manager / automation?

 

Thanks,

 

David.

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Friday, February 24, 2006 7:45:36 AM(UTC)

wmiller  
wmiller

Groups: Registered
Posts: 7


Not sure if this is what you mean, its VB6 and uses the AnnAutomation object...

'Set automation defaults so that all newly created objects have this calibration
mRasterAnn.AnnSetBitmapDpiX mRasterAnn.AnnAutomation, dDpiX, False
mRasterAnn.AnnSetBitmapDpiY mRasterAnn.AnnAutomation, dDpiY, False
mRasterAnn.AnnSetUnit mRasterAnn.AnnAutomation, lCalibrateUnit + ANN_UNIT_DEF_ABBR, vbNullString, 2, False

My question is how do you apply this to existing objects (without AnnEnumeration, lol). I tried the AnnCalibrateRuler example, but none of the existing rulers were modified.

Bill M.
 
#3 Posted : Monday, February 27, 2006 8:16:16 AM(UTC)

Amin  
Amin

Groups: Manager, Tech Support
Posts: 354


David,
For Automation, here are 2 ways to make Ruler and similar objects get drawn in a specific unit, such as Centimeter:

1. Right after calling _automationManager.CreateDefaultObjects(), call the following code:
foreach(AnnAutomationObject autObj in _automationManager.Objects)
{
   if(autObj.Object is AnnPolyRulerObject)
   {
      AnnPolyRulerObject PolyRulerObj = autObj.Object as AnnPolyRulerObject;
      PolyRulerObj.MeasurementUnit = AnnUnit.Centimeter;
   }
   if(autObj.Object is AnnRulerObject)
   {
      AnnRulerObject RulerObj = autObj.Object as AnnRulerObject;
      RulerObj.MeasurementUnit = AnnUnit.Centimeter;
   }
   if(autObj.Object is AnnCrossProductObject)
   {
      AnnCrossProductObject CrossProductObj = autObj.Object as AnnCrossProductObject;
      CrossProductObj.MeasurementUnit = AnnUnit.Centimeter;
   }
}

2. In the automation.CurrentDesignerChanged event handler, do the following:
if(automation.CurrentDesigner != null && automation.CurrentDesigner is AnnCrossProductDrawDesigner)
{
   AnnCrossProductDrawDesigner DrawDes = automation.CurrentDesigner as AnnCrossProductDrawDesigner;
   AnnCrossProductObject tmplObj = DrawDes.ObjectTemplate as AnnCrossProductObject;
   tmplObj.MeasurementUnit = AnnUnit.Centimeter;
}
if(automation.CurrentDesigner != null && automation.CurrentDesigner is AnnLineDrawDesigner)
{
   AnnLineDrawDesigner DrawDes = automation.CurrentDesigner as AnnLineDrawDesigner;
   if(DrawDes.ObjectTemplate is AnnRulerObject)
   {
      AnnRulerObject tmplObj = DrawDes.ObjectTemplate as AnnRulerObject;
      tmplObj.MeasurementUnit = AnnUnit.Centimeter;
   }
}


In non-automated mode, you set the Object property of the
AnnDrawDesigner manually, so when you initialize the designer, set its MeasurementUnit to the value you want.

Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#4 Posted : Monday, February 27, 2006 9:24:10 AM(UTC)
dgVisioscopie

Groups: Registered
Posts: 3


Hi,

Thanks for all.

 

I found another way:

 

I declared the AnnUnit that I wanted.

private AnnUnit _mesureUnit = AnnUnit.SmartMetric;

 

Once you have added an AnnRulerObject, by code for example :

void Objects_ItemAdded(object sender, RasterCollectionEventArgs e)

        {

            try

            {

                if (e.Object is AnnRulerObject)

                {

                    (e.Object as AnnRulerObject).MeasurementUnit = this._mesureUnit;

                }

            }

            catch

            {

 

            }

        }

 

And just before drawing, while you are manipulating the Ruler with mouse :

private void Container_BeforeDrawingObjects(object sender, AnnPaintEventArgs e)

        {

            try

            {

                if (sender is AnnRulerObject)

                {

                    (sender as AnnRulerObject).MeasurementUnit = this._mesureUnit;

                }

            }

            catch

            {

 

            }

        }

 

 

David.

 
#5 Posted : Monday, February 27, 2006 9:45:24 AM(UTC)

Amin  
Amin

Groups: Manager, Tech Support
Posts: 354


Bill,
You can use the API for that. Here's what's needed in VB6:


Private Declare Function L_AnnSetBitmapDpiX Lib "LtrAn14n.DLL" (ByVal hObject As Long, ByVal dDpiX As Double, ByVal uFlags As Long) As Long

Private Declare Function L_AnnSetBitmapDpiY Lib "LtrAn14n.DLL" (ByVal hObject As Long, ByVal dDpiX As Double, ByVal uFlags As Long) As Long
Const ANNFLAG_RECURSE As Long = 8
Const ANNFLAG_NOTCONTAINER As Long = 2

   L_AnnSetBitmapDpiX RasterAnn.AnnContainer, 150, ANNFLAG_NOTCONTAINER + ANNFLAG_RECURSE
   L_AnnSetBitmapDpiY RasterAnn.AnnContainer, 150, ANNFLAG_NOTCONTAINER + ANNFLAG_RECURSE

Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2019, Yet Another Forum.NET
This page was generated in 0.214 seconds.