Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to show different views with IPanel? #14

Open
liuzmm opened this issue Jul 27, 2015 · 5 comments
Open

How to show different views with IPanel? #14

liuzmm opened this issue Jul 27, 2015 · 5 comments

Comments

@liuzmm
Copy link

liuzmm commented Jul 27, 2015

Hi Satoru,
my compliments for your library! I'm using IGeo to draw Nurbs Curves and then construct a Surface with IG.loft (after a few transformations). I would like to show in the same window two different views of my geometries (IG.top of the curves and IG. perspective of the Surface) and I guess I have to use two different IPanes.
Is it possible to use IGeo GUI with Processing 2.2.1? ( When I try to run a sketch I get the error unexpected token: package in reference to the first line package igeo.gui; )
How can I use the IPanel to get the result I need?
Is there any tutorial about this issue?
Thanks in advance!

@sghr
Copy link
Owner

sghr commented Jul 28, 2015

Because I didn't expect to use in that way, it's ugly but the below should work in Processing 2.2.1.

import igeo.*;
import igeo.gui.*;
size(800,400,IG.GL);
IGridPanel gridPanel = (IGridPanel)IG.cur().panel;
gridPanel.setupGrid(2, 1, null);
IPane pane1 = gridPanel.gridPanes[0][0];
IPane pane2 = gridPanel.gridPanes[1][0];
IView view1 = IView.getTopView((int)pane1.getX(),(int)pane1.getY(),pane1.getWidth(),pane1.getHeight());
view1.enableGL();
view1.setMode(new IGraphicMode(IGraphicMode.GraphicType.GL, false, true, false)); // fill false, wire true, transparent false
IView view2 = IView.getDefaultPerspectiveView((int)pane2.getX(),(int)pane2.getY(),pane2.getWidth(),pane2.getHeight());
view2.enableGL();
view2.setMode(new IGraphicMode(IGraphicMode.GraphicType.GL, true, true, false)); // fill true, wire true, transparent false
pane1.setView(view1);
pane2.setView(view2);
pane1.navigator().setRotateLock(true);
gridPanel.gridPanes[0][0].setVisible(true);
gridPanel.gridPanes[1][0].setVisible(true);
for(int i=0; i<100; i++){
  IVec pos = IRand.pt(100);
  new ISurface(pos, pos.cp(5,0,0), pos.cp(5,5,0), pos.cp(0,5,0)).clr(IRand.clr()); 
}

@liuzmm
Copy link
Author

liuzmm commented Jul 28, 2015

Hi Satoru,
many many thanks for your kind answer!
I have another doubt about the use of IPanes. It would be possible to draw different geometries in each IPane? It would be useful for me to treat each one as it was indipendent from the other, drawing in the first one only the curves (show in top view) and in the second one the surface (show in perspective view).

@sghr
Copy link
Owner

sghr commented Jul 28, 2015

Can you put different geometries in locations far apart and set the views to show each?
Otherwise, making multiple IG internal servers and tied to views is something I planned but not tested and it'd be very tricky.

@liuzmm
Copy link
Author

liuzmm commented Jul 31, 2015

Sorry for the late reply, I used the first trick you suggested and it works! Thank you so much!
One more question.. I'm using ControlP5 slider to move ICurves and get automatically an updated ILoft, but when I change the position the previous curves and surfaces don't disappear, overlapping each other. I tried to refresh the background with IG.bg(0), but it seems that nothing change. Is it possible to refresh the screen in another way?

@liuzmm
Copy link
Author

liuzmm commented Jul 31, 2015

Satoru, I found the refpiGeon method in Nathan Miller Supershape 3D template:

public void refpiGeon(){
IPoint [] ptarr = IG.points();
ICurve [] crvarr = IG.curves();
ISurface [] srfarr = IG.surfaces();
IBrep [] breparr = IG.breps();
IMesh [] mesharr = IG.meshes();

for (IPoint pt:ptarr){
pt.del();
}

for (ICurve crv:crvarr){
crv.del();
}

for (ISurface srf:srfarr){
srf.del();
}

for (IBrep brep:breparr){
brep.del();
}

for (IMesh mesh:mesharr){
mesh.del();
}
}

Is it possible to lock rotation and translation in the window and rotate only pressing a key in the keyboard (having only one IPane and one view)?

Regards,
liuz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants