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 : Monday, January 15, 2018 10:21:25 PM(UTC)

tksong  
tksong

Groups: Registered
Posts: 10

Thanks: 1 times

I want to measure the length of the NITF image using the Ruler function.

https://drive.google.com/open?id...6wopCU94tTFh1DnLSGoknDxz

The image above is on the way to using the Ruler, so I don't want the length to be displayed.

I want to know how I can control the options of the Ruler function.


Additionally, Except for the GetSelectItem () function, I want to know how I can access the Object inside the Container.
 

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 : Tuesday, January 16, 2018 1:51:04 PM(UTC)
Anthony Northrup

Groups: Registered, Tech Support, Administrators
Posts: 199

Was thanked: 28 time(s) in 28 post(s)

Hello,

Since you didn't specify what language you are developing with, my answers are for C#, let me know if it's different and I'll change my answers to the language you are using.

You can stop the ruler length from being displayed by changing the Font property to null on the ruler. To have this set by default, you can modify the AnnAutomationObject's template for the ruler and poly ruler, below is a snippet for how to achieve this:
Code:

foreach (AnnAutomationObject autoObj in annAutomationObj.Manager.Objects)
{
    AnnObject obj = autoObj.ObjectTemplate;
    if (obj.Id == AnnObject.RulerObjectId || obj.Id == AnnObject.PolyRulerObjectId)
        obj.Font = null;
}


You can get the length of a ruler annotation by using the GetRulerLength method, for the argument calibrationScale you can pass the CalibrationScale of the current container's mapper, below is a snippet for how to achieve this:
Code:

LeadLengthD rulerLength = rulerObj.GetRulerLength(annContainerObj.Mapper.CalibrationScale);


For getting the current ruler, you can iterate through the children of the container and check the IsSelected property. Below is a snippet for how to perform some operation on the selected ruler.
Code:

AnnPolyRulerObject currentRuler = null;
foreach (AnnObject obj in annContainerObj.Children)
{
    if (obj.Id == AnnObject.RulerObjectId)
        currentRuler = (AnnPolyRulerObject)obj;
}
if (currentRuler != null)
{
    // A ruler was selected, do something with it
}
Anthony Northrup
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 
#3 Posted : Tuesday, January 16, 2018 7:49:39 PM(UTC)

tksong  
tksong

Groups: Registered
Posts: 10

Thanks: 1 times

Sorry. It's my mistake.

I am working on an MFC environment and appreciate your answers.

 
#4 Posted : Wednesday, January 17, 2018 11:54:41 AM(UTC)
Anthony Northrup

Groups: Registered, Tech Support, Administrators
Posts: 199

Was thanked: 28 time(s) in 28 post(s)

Hello,

For these answers I modified the following demo:[LEADTOOLS 19]\Examples\ClassLibrary\MSVC\Annotate

You can hide the length of the ruler annotations by using the OnAnnEvent callback. You can use the SetShowFlags method of the LAnnRuler to hide just the length. Below is the modified OnAnnEvent from the demo I referred to above
Code:

L_VOID CAnnDemoBitmap::OnAnnEvent(L_UINT uAnnEvent, LPARAM lParam)
{
    LAnnotationWindow::OnAnnEvent(uAnnEvent, lParam);

    switch (uAnnEvent)
    {
    case LTANNEVENT_INSERT:
        {
            LAnnotation  * pAnnObj;

            pAnnObj = LAnnotation::CreateAnnObject((HANNOBJECT)(LONG_PTR)lParam);
            if (pAnnObj != NULL)
            {
                if (pAnnObj->GetType()== ANNOBJECT_BUTTON)
                {
                    pAnnObj->SetTag(++m_nButtons, 0);
                }
                else
                {
                    if (pAnnObj->GetType()== ANNOBJECT_HOTSPOT)
                    {
                        pAnnObj->SetTag(++m_nHotspots, 0);
                    }
                    // Added the following if statement
                    if (pAnnObj->GetType() == ANNOBJECT_RULER || pAnnObj->GetType() == ANNOBJECT_POLYRULER)
                    {
                        ((LAnnRuler*)pAnnObj)->SetShowFlags(ANNSHOW_GAUGE | ANNSHOW_TICMARKS);
                    }
                    pAnnObj->SetHandle(NULL);
                    delete pAnnObj;
                }
            }
        }
        break;
// Rest of method...


In order to get the length of a ruler, you can use the GetDistance method. Here's a helper you can use for getting the length:
Code:

L_INT GetLengthOfRuler(LAnnObject *obj, L_DOUBLE *pdDistance)
{
    // No object?
    if (obj == NULL)
        return FAILURE;
    // Invalid type?
    if (obj->GetType() != ANNOBJECT_RULER && obj->GetType() != ANNOBJECT_POLYRULER)
        return FAILURE;
    // Cast to a ruler
    LAnnRuler *ruler = (LAnnRuler*)obj;
    // Return length
    return ruler->GetDistance(pdDistance);
}


And yes, you will most likely have to use the GetSelectedItems method. However, if you create these manually, you can simply store the tag of the annotations and use GetObjectFromTag.
Anthony Northrup
Developer 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-2024, Yet Another Forum.NET
This page was generated in 0.087 seconds.