Creating new axis in 3d viewed object

Like many I require inverting an axis, in my case the y-axis. I am comfortable doing this in 2d by hiding the intrinsically created TAxis and drawing a TGaxis in it’s place with the appropriate ranges.

But how can I replace the y-axis when drawing an object in 3d such that it remains there through rotation? I have played with TAxis3D but don’t think the rulers can accomplish the feat I mention above.

Also, I noticed TAxis3D::PaintAxis(TGaxis* axis, Float_t ang) takes a TGaxis, but can’t figure out how this function works and if I could use it to solve my problem.

Thanks.

[/i]

The class TAxis3D was unfortunately designed with a wrong name and several
missing functions. We will try to fix this in a coming version, giving
the possibility to draw one single axis (as it should be) and not 3 !

Rene

[quote=“jribnik”]
But how can I replace the y-axis when drawing an object in 3d such that it remains there through rotation? I have played with TAxis3D but don’t think the rulers can accomplish the feat I mention above.
[/i][/quote]
I am afarid I did not understand exactly your needs. A small example would have helped.

I hope you have seen the methods:

root.cern.ch/root/htmldoc/src/TA … ggleRulers
it shows how to show / hide the 3D axice.

and

root.cern.ch/root/htmldoc/TAxis3 … D:GetXaxis
root.cern.ch/root/htmldoc/TAxis3 … D:GetYaxis
root.cern.ch/root/htmldoc/TAxis3 … D:GetZaxis

Those allow you to customise each axis (of TAxis class) attributes directly.

Some attrributes can be changed indirectly via the set of the proxy methods of TAxis3D class.

[quote=“jribnik”]
Also, I noticed TAxis3D::PaintAxis(TGaxis* axis, Float_t ang) takes a TGaxis, but can’t figure out how this function works and if I could use it to solve my problem.
[/i][/quote]

The method picks the TAxis data-members and propagate the attributes of the TAxis object to the internal TGaxis object. You have no access to the temporary TGAxis object. I can image over time (TAxis3D was done several years ago and was not changed since that much) TAxis evolved and TAxis3D::PaintAxis doesn’t propage all possible combinations of its modern attributes to TGAxis nowadays.

I’ll investigate this.

[quote=“fine”][quote=“jribnik”]
But how can I replace the y-axis when drawing an object in 3d such that it remains there through rotation? I have played with TAxis3D but don’t think the rulers can accomplish the feat I mention above.
[/i][/quote]
I am afarid I did not understand exactly your needs. A small example would have helped.
[/quote]

I require an inverted axis, however, all TAxis objects created with histograms or graphs display increasing value from left to right or bottom to top. As this is a property of the TAxis that I cannot change (in the future maybe?), I offset the TAxis in question and draw a TGaxis in it’s place.

This is easy enough in 2D, but I want to do it in 3D, and only for a single axis.

[quote=“brun”] We will try to fix this in a coming version, giving
the possibility to draw one single axis (as it should be) and not 3 !
Rene[/quote]

The commnet in the TAxis3D::PaintAxis clearly indicate where is the idea came from
//- void THistPainter::PaintLegoAxis(TGaxis *axis, Double_t ang)

Of course one axis can be drawn with TGAxis class directly.
This is what TAxis3D does 3 times in loop.

It is trivial to add some methods to disable each TGAxis painting in that loop. For example:

 TAxis3D::Enable("X", kTRUE)
 TAxis3D::Enable("Y", kTRUE)
 TAxis3D::Enable("Z", kTRUE)

or
TAxis3D::Enable(1, kTRUE)
TAxis3D::Enable(2, kTRUE)
TAxis3D::Enable(3, kTRUE)

However it doesn’t resolve the issue and will not fix the original design.

The TAxis3D was designed to provide the ZOOM/MOVE operation for 3D object.
In the other words to change the range of TView object by mouse.
The design just followed the histogram class design.
root.cern.ch/root/html402/TAxis3 … escription

The capability to draw these axice is an extra bonus
That may be provided by other means and by user code alone with 3 TGAxis or TAxis objects

3D Zoom/Move facility can not be provided with 1 or 2 axice. One needs all 3 to do that.
The class was not designed to be used stand-alone to draw the arbitrary axis in 3D that’s true.

Yes, TAxis3D is 3D equivalent of TAxis class for 1-2D. There is no 3D equivalent for TGAxis though.
I don’t think it can be done by “fixing” TAxis3D. I think we should provide TGaxis3D
(the same way as ROOT provide TAxis and TGaxis)

In theory one might fool the TAxis3D class by changing the range of the TView object with the macro like this:
{
TView *view = gPad->GetView();
Double_t minbox[3], maxbox[3];
view->GetRange(minbox,maxbox);
int i=0;
for(i=0;i<3;i++) printf(" Before: %d min = %f, max = %d\n", i,minbox[i],maxbox[1]);
// change the Z-axis range
Double_t exchange = minbox[2];
minbox[2] = maxbox[2];
maxbox[2] = exchange;
view->SetRange(minbox,maxbox);
view->GetRange(minbox,maxbox);
for(i=0;i<3;i++) printf(" After: %d min = %f, max = %d\n", i,minbox[i],maxbox[1]);
}

But TView class protection forbid this trick.

Watch the protection:

FindScope(scale, centre, irep);
if (irep < 0) {
    Error("ResetView", "Error in min-max scope");
    return;
}

with root.cern.ch/root/html402/src/TV … :ResetView

So the new TGAxis3D (as a counterpart for TAxis3D) class should be done. :frowning:

Mean time what you can try right now is to implement what you need using the method :bulb:
root.cern.ch/root/html402/src/TA … :PaintAxis
as a pattern. If you regard the use the “TGAxis::Draw…” methods there instead of “TGAxis::Paint…” ones. It should be not too difficult. I may assist you if you want.