AvAxisLabelObject

AvAxisLabelObject

Hello,

I am trying to access the Base property of an AxisLabel object using Fortran. Is there a way to do that? It appears that there is no function that returns an AvAxislabel object for Fortran. If that is really the case, how can someone move the labels of an axis using fortran?

Thanks in advance,

vasilis

10 帖子 / 0 全新
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项

Hi Vasilis,

The avLabel function in AvObjMod returns a handle to the AxisLabel. Here's an example:

Code:

program AxisLabel_Base
    use AvFRT
    use AvObjMod

    implicit none
    integer(4) :: status
    real(4) :: base
    integer(int_ptr_kind()) :: hRoot, hGraph, hAxis

    Print *, "Opening: ../Data/XML/Bessel.xml"
    call avOpen("../Data/XML/Bessel.xml", AV_FALSE, status)
    hRoot = avGetObject("/")
    hGraph = avItem(avGraphs(hRoot), "Bessel Functions")
    hAxis = avItem(avAxes(hGraph), "Horizontal axis")
    call avGetRefLine(hAxis, base)
    Print *, "Horizontal axis Label Base = ", base
    call avSetRefLine(hAxis, 0.4, status)
    Print *, "Setting value to 0.3"
    call avSetBase(avLabel(hAxis), 0.3, status)
    call avGetBase(avLabel(hAxis), base)
    Print *, "New value: ", base
    
    end program

By the way, we're working on creating a set of examples that illustrates how to access each AV object model objects from Fortran. This should be in the next release.

John

Hallo John,

I started writing my reply, with the intent to tell you that I have already tried something similar to your code and that as well as your code didn't work. Both programs crash when the avSetBase fuction is called.

Nevertheless I managed to finde out where the problem is hidden. The hintto uncover the error came from the fact that avGetbase works perfectly, whereas avSetbase fails.If you look at the documentation of the Base property you will notice the following:

C++ syntax
HRESULT get_Base(float *pVal);
HRESULT put_Base(float newVal);

Fortran syntax
subroutine avGetBase(object, val)
integer(int_ptr_kind()), intent(IN):: object
real(4), intent(OUT) :: val
end subroutine avGetBase

subroutine avSetBase(object, val, status)
integer(int_ptr_kind()), intent(IN):: object
real(8), intent(IN) :: val
integer, intent(OUT) :: status
end subroutine avSetBase

This led me to beleive that the interface of avSetBase was wrong. So I went to the AvObjMod.f90 file and change the interface of avSetBase so that val has a real(4) type, instead of a real(8). After that everything worked asi t should have.

I think that this qualifies as a bug, don't you?

Vasilis

Hallo John,

before you had a chance to answer my precious post, I have come across a new problem with the AvAxisLabel Object. I have been trying to change its colour without any success. I have also tried to get the colour of an avAxisLabel using

call AVGetColor(avLabel(hAxisX),col)

but it returns the following error (provided by avGetErrorMessage):

"Not a AxisTickmark, Border, Grid, Label, Light, or Marker object ".

Am I doing something wrong or am I just unlucky and stumbled onto a new bug?

Thanks in advance

Vasilis

Hi Visillis,

Regarding avSetBase, yes that's a bug. Actually I had just run across that one myself, the next update should have the correct interface.

Regarding avGetColor, this is also a bug, but in this case it's in the library code itself. I'll have this fix in the next update as well. If you can't wait for the next update, you can change the library source yourself, as the source code for avfrt.lib is part of the kit. If add the following lines to AVGETCOLOR function inC:Program FilesIntelArray VisualizersrcAvObjMod.cpp and rebuild the library, that should fix the problem.

Code:

AvComQIPtr pILabel((IUnknown *)hObject);
if (pILabel) {
	long nColor;
	hr = pILabel->get_Color(&nColor);
	if (FAILED(hr)) {
		*pVal = -1;
		SetError(pILabel);
	} else {
		*pVal = nColor;
	}
	return;
}
// start insert block
AvComQIPtr pIAxisLabel((IUnknown *)hObject);
if (pIAxisLabel) {
	long nColor;
	hr = pIAxisLabel->get_Color(&nColor);
	if (FAILED(hr)) {
		*pVal = -1;
		SetError(pIAxisLabel);
	} else {
		*pVal = nColor;
	}
	return;
}
// end insert block
AvComQIPtr pIMarker((IUnknown *)hObject);

Add the lines between "// start insert block" and "// end insert block" to AvObjMod.cpp. The line number should be 3983 or so.

Please let us know about any other problems you find in AvObjMod. This module contains hundreds of subroutines/functions, not all of which has been tested. I'm the process right now of creating a comprehensive test suite for the AvObjMod which will be a big help in finding problems in the library.

John

Hallo John,

thank you for your response. Now that that was solved I have run into a new problem.
I wish to make an image plot on a non-uniform grid. The first problem that I encountered was that the avGetScaleSource and the avSetScaleSource routines crash my program, so I could use some of your help with them.
Furthermore, I have tried to do that using ArrayViewer in order to see how the result looks like, but I had no success with it. As soon as I set the X and Y sources the plot becomes blue without any scales. The data that I used were those of the Simple example (matrix M, and two matrices that represent x*x and 1d-3*y*y).
The documentation on the subject is rather sketchy, so your help is desperately needed.

Thanks

Vasilis

I have some examples of image plots on a non-uniform grid (e.g. the graph "image test" in the attached file, but the problem may be with the Fortran interface again. Can you post the program where you are setting up the image plot? I'll take a look at it.

John

Hello John,

it took me a while to respond but work has its own priorities. I am attaching two files:

1. a modified example of the use of the AvObject including a routine that produces among other things a line graph with two plots and two Y-axes that can be dynamically updated, in case that the results of a calculation have to be seen real time. The programming is probably an overkill so your input would be appreciated.

2. an .xml file containing all the graphs that are produced by the aforementioned example. There I have changed the X- and Y-ScaleSources and the Transform in the ArrayViewer but the appearance is not convincing. It should be the same plot as "graph2" only on an asymmetrical grid. There appears to be no way to do that using the AvObject Structure since the AvSetScaleSource routine is severely bugged (there is for instance no argument for the coordinate to be scaled). Could you give me a tip or two how to solve this problem both from inside the Viewer as well as using the AvObject routines.

Once again, thanks in advance

Vasilis

Here is also the .xml file that I could not attach in my previous post.

Vasilis

Hello John,

I just downloaded the latest Fortran update and was happy to see that the corrections that we talked about were already in place. I have one remark though: Although the AvGetColor routine was corrected as you promised, the same correction wasn't applied to the avSetColor routine, which still fails with the AvAxisLabel Object.

Regards

Vasilis

发表评论

登录添加评论。还不是成员?立即加入