Can I display different graphics in two split views for a Document

Hi,

Is there any way to control "AIS2D_InteractiveContext" or V2d_view to dispay different graphics in two split views?

I want to dispaly a complicated graphics from one view to two split views (top & bottom) in a childframe. I want to display a block diagram in the top view, and then when clicking some block in the top view, the detail about the block would be displayed in the bottom view. AIS2D_InteractiveContext is used for the display.

My problem is at each time, both of the views display the same graphics. The two view use the same class for I want to use the same displaye methods for them.

Thanks a lot!

Regards
Chris

Sharjith Naramparambath's picture

Create two V3d_Views using the same V3d_Viewer. While doing this pass different WinID for each view using SetWindow method.

e.g.

short hi, lo;
Handle(WNT_Window) myWindow;
Handle(WNT_Window) myWindow2;

Handle(Graphic3d_WNTGraphicDevice) myDevice;
myDevice = new Graphic3d_WNTGraphicDevice();

windowHandle = (glong) GDK_WINDOW_HWND(gdkwin);
lo = (short) windowHandle;
hi = (short) (windowHandle >> 16);
myWindow = new WNT_Window(myDevice, (int)hi, (int)lo);

windowHandle = (glong) GDK_WINDOW_HWND(gdkwin2);
lo = (short) windowHandle;
hi = (short) (windowHandle >> 16);
myWindow2 = new WNT_Window(myDevice, (int)hi, (int)lo);
TCollection_AsciiString Domain("");

myViewer = new V3d_Viewer(myDevice,Name.ToExtString(),Domain.ToCString(),1000.0,V3d_XposYnegZpos,Quantity_NOC_GRAY95,V3d_ZBUFFER,V3d_GOURAUD,V3d_WAIT,Standard_True,V3d_TEX_ALL);

myView = new V3d_OrthographicView(myViewer);
myView->SetWindow(myWindow);
myView->SetSurfaceDetail(V3d_TEX_ALL);

myView2 = new V3d_OrthographicView(myViewer);
myView2->SetWindow(myWindow2);
myView->SetSurfaceDetail(V3d_TEX_ALL);

...
...
//Do rest stuff

Hope this helps!

Regards
N. Sharjith

Sharjith Naramparambath's picture

P.S.

You can set the projection for each view independently...

//first view
myView1->SetProj(V3d_Zpos);

// second view
myView2->SetProj(V3d_Xpos);

Roman Lygin's picture

Hi Chris,

The above answer from Sharjith Nair is correct.
Another note - I wouldn't bother with AIS2D_InteractiveContext and just used AIS_InteractiveContext and V3d_View with needed projection (e.g. along Z axis). I have never dealt with AIS2D but IIRC it uses Win32 API to draw objects what may result in poor performance. Anyway it should not offer any significant advantage but otherwise you may result using a code which may have behavior discrepancy with AIS, different API, etc. Just my 2 cents...

Roman
---
opencascade.blogspot.com - the Open CASCADE blog

Wang Chris's picture

Hi, Roman & N.Sharjith,

Many thanks to your kind help. I can understand the problem more clear from your answers. But I still cannot apply them directly into my problem. I give you more detail about my application:
"pDocTemplateForView3d = new CMultiDocTemplate(
IDR_VirtualEMCLab,
RUNTIME_CLASS(CMyDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CMyView));
if (!pDocTemplateForView3d)
return FALSE;
AddDocTemplate(pDocTemplateForView3d);

pDocTemplateForView2d = new CMultiDocTemplate(
IDR_VIRTUATYPE,
RUNTIME_CLASS(CMyDoc),
RUNTIME_CLASS(CChildFrame2d), // custom MDI child frame
RUNTIME_CLASS(CMyView2d));

CVirtualEMCLabDoc : (member variables)
Handle_V3d_Viewer myViewer;
Handle_AIS_InteractiveContext myAISContext;
Handle_V2d_Viewer myViewer2D;
Handle_AIS2D_InteractiveContext myAISInteractiveContext2D;

CVirtualEMCLabView2d : (member variables)
Handle_V2d_View myV2dView;

Methods like “Pan”, “Fit’… are defined within CVirtualEMCLabView2d.

This is the function to generate two views in CChildFrame2d.
BOOL CChildFrame2d::OnCreateClient( LPCREATESTRUCT lpcs,
CCreateContext* pContext)
{
VERIFY (m_wndSplitter.CreateStatic(this, 2, 1
VERIFY (m_wndSplitter.CreateView (0, 0, RUNTIME_CLASS (CVirtualEMCLabView2d), CSize (100, 100), pContext));
VERIFY (m_wndSplitter.CreateView (1, 0, RUNTIME_CLASS (CVirtualEMCLabView2d), CSize (100, 100), pContext));
m_wndSplitter.SetActivePane(0,0);

return TRUE;
}

The system always displays the two childframes of the same document, and with the CChildFrame2d with two split CVirtualEMCLabView2d views.

The problem is I don’t know how to control the graphics and let them just displayat one of the split views.

Thanks a lot!

Best Regards
Chris

Sharjith Naramparambath's picture

You can find a demo with code on codeproject, contributed by our very own Stephane Routelous of OCC forum.

http://www.codeproject.com/KB/splitter/automaticsplitter.aspx

Hopefully this, coupled with the above code, would be the answer for your problem.

Sharjith Naramparambath's picture

PS. The gdkwin you see in the above code is because I have done it in GTK. Use any toolkit what you need just to get is the Window id. In case of Win32 SDK and MFC its nothing but the HWND.

Wang Chris's picture

Hi, N.Sharjith,

Thank you very much for your help. I finally solved this problem.

I define separate view, viewwer and ISession2D_InteractiveContext for each of the two splitted views which are inherited from a baisc view. In this way, I can control the graphics in each view.

Regards
Chris