1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

0023670: Support for multiple 3D views: edited commands: vinit; added commands: vclose, vactivate, vviewlist

bugs/end script was edited to dump results from all opened views; duplicated vinit was deleted from bug625. QABugs::OCC280()
was edited to work with multiviews;ViewerInit() method was corrected. vviewlist command was modificated to output string.
Small corrections
Compile errors were corrected
This commit is contained in:
aba
2013-06-13 14:57:07 +04:00
parent da8536ad43
commit 18d715bde0
13 changed files with 1277 additions and 217 deletions

View File

@@ -856,7 +856,10 @@ is
-- are smaller than the printer's printing
-- area dimensions - use multiple printing
-- frames to cover the whole printing area
enumeration XAtom is
XA_DELETE_WINDOW
end XAtom;
---Purpose: Defines custom identifiers(atoms) for X window custom named properties
---------------------------------
-- Category: Instantiated classes
---------------------------------

View File

@@ -86,6 +86,7 @@ TCollection_AsciiString Aspect_DisplayConnection::GetDisplayName()
void Aspect_DisplayConnection::Init()
{
myDisplay = XOpenDisplay (myDisplayName.ToCString());
myAtoms.Bind (Aspect_XA_DELETE_WINDOW, XInternAtom(myDisplay, "WM_DELETE_WINDOW", False));
if (myDisplay == NULL)
{
@@ -95,4 +96,15 @@ void Aspect_DisplayConnection::Init()
Aspect_DisplayConnectionDefinitionError::Raise (aMessage.ToCString());
}
}
// =======================================================================
// function : GetAtom
// purpose :
// =======================================================================
Atom Aspect_DisplayConnection::GetAtom (const Aspect_XAtom theAtom) const
{
Atom anAtom = myAtoms.Find(theAtom);
return anAtom;
}
#endif

View File

@@ -20,8 +20,10 @@
#include <Standard_Transient.hxx>
#include <Aspect_DisplayConnection_Handle.hxx>
#include <Aspect_XAtom.hxx>
#include <TCollection_AsciiString.hxx>
#include <NCollection_DataMap.hxx>
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
#include <X11/Xlib.h>
@@ -52,6 +54,9 @@ public:
//! @return pointer to Display structure that serves as the connection to the X server.
Display* GetDisplay();
//! @return identifier(atom) for custom named property associated with windows that use current connection to X server.
Atom GetAtom (const Aspect_XAtom theAtom) const;
//! @return display name for this connection.
TCollection_AsciiString GetDisplayName();
@@ -63,8 +68,9 @@ private:
private:
Display* myDisplay;
TCollection_AsciiString myDisplayName;
Display* myDisplay;
NCollection_DataMap<Aspect_XAtom, Atom> myAtoms;
TCollection_AsciiString myDisplayName;
#endif
private:

View File

@@ -282,7 +282,12 @@ Quantity_Ratio Cocoa_Window::Ratio() const
void Cocoa_Window::Position (Standard_Integer& X1, Standard_Integer& Y1,
Standard_Integer& X2, Standard_Integer& Y2) const
{
//
NSWindow* aWindow = [myHView window];
NSRect aWindowRect = [aWindow frame];
X1 = (Standard_Integer) aWindowRect.origin.x;
Y1 = getScreenBottom() - (Standard_Integer) aWindowRect.origin.y - (Standard_Integer) aWindowRect.size.height;
X2 = X1 + (Standard_Integer) aWindowRect.size.width;
Y2 = Y1 + (Standard_Integer) aWindowRect.size.height;
}
// =======================================================================

View File

@@ -541,36 +541,29 @@ static Standard_Integer OCC280 (Draw_Interpretor& di, Standard_Integer argc, con
HLR = 1;
}
Handle(V3d_View) anOldView = ViewerTest::CurrentView();
TCollection_AsciiString anOldName = ViewerTest::GetCurrentViewName();
Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
if (Draw::Atoi (argv[2]))
{
aViewer->SetDefaultSurfaceDetail (V3d_TEX_ALL);
}
aViewer->SetDefaultTypeOfView (V3d_PERSPECTIVE);
Handle(Aspect_Window) asp = anOldView->Window();
aViewer->SetViewOff (anOldView);
Handle(Aspect_Window) asp = ViewerTest::CurrentView()->Window();
Handle(V3d_View) aNewView = aViewer->CreateView();
ViewerTest::CurrentView (aNewView);
TCollection_AsciiString aNewName=anOldName + "_new";
ViewerTest::InitViewName(aNewName,ViewerTest::CurrentView());
aNewView->SetWindow (asp);
if (!asp->IsMapped()) asp->Map();
anOldView->Remove();
anOldView.Nullify();
aNewView->Update();
// replace view in event manager
aNewView->Redraw();
ViewerTest::RemoveView(anOldName,false);
ViewerTest::UnsetEventManager();
ViewerTest::SetEventManager (new ViewerTest_EventManager (aNewView, ViewerTest::GetAISContext()));
if (HLR == 1)
{
di << "HLR\n";
aNewView->SetComputedMode (Standard_True);
ViewerTest::CurrentView()->SetComputedMode (Standard_True);
}
return 0;

View File

@@ -69,13 +69,30 @@ is
---Category: Create the viewer....
ViewerInit ( thePxLeft, thePxTop : Integer from Standard = 0;
thePxWidth, thePxHeight : Integer from Standard = 0);
---Purpose:
-- implemented in ViewerTest_ViewerCommands.cxx
thePxWidth, thePxHeight : Integer from Standard = 0;
theViewName : CString from Standard = "";
theDisplayName : CString from Standard = "")
returns AsciiString from TCollection;
---Purpose: Creates view with default or custom name
-- and add this name in map to manage muliple views
-- implemented in ViewerTest_ViewerCommands.cxx
---Category: Manage the name of views
RemoveViewName (theName: AsciiString from TCollection);
InitViewName (theName: AsciiString from TCollection;
theView: View from V3d);
GetCurrentViewName returns AsciiString from TCollection;
---Category: Delete the viewer....
RemoveView (theViewName:AsciiString from TCollection;
isContextRemoved:Boolean from Standard= Standard_True);
---Purpose: Removes view and clear all maps
-- with information about its resources if neccessary
---Category: Selection in the viewer....
WClass returns TShared from MMgt is private;
---C++: return const &
---Purpose: Returns a window class that implements standard behavior of

File diff suppressed because it is too large Load Diff

View File

@@ -25,11 +25,18 @@
#include <V3d_Viewer.hxx>
#include <AIS_InteractiveContext.hxx>
#include <NIS_View.hxx>
#include <TCollection_AsciiString.hxx>
#include <NCollection_DoubleMap.hxx>
//! Custom Cocoa view to handle events
@interface ViewerTest_CocoaEventManagerView : NSView
@end
//! Custom Cocoa window delegate to handle window events
@interface Cocoa_WindowController : NSObject <NSWindowDelegate>
@end
extern void ActivateView (const TCollection_AsciiString& theViewName);
extern void VT_ProcessExpose();
extern void VT_ProcessConfigure();
extern void VT_ProcessKeyPress (const char* theBuffer);
@@ -44,12 +51,81 @@ extern Standard_Boolean VT_ProcessButton1Press (Standard_Integer theArgsNb,
Standard_Boolean theIsShift);
extern void VT_ProcessButton1Release(Standard_Boolean theIsShift);
extern NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)> ViewerTest_myViews;
extern int X_Motion; // Current cursor position
extern int Y_Motion;
extern int X_ButtonPress; // Last ButtonPress position
extern int Y_ButtonPress;
extern Standard_Boolean IsDragged;
// =======================================================================
// function : SetCocoaWindowTitle
// purpose :
// =======================================================================
void SetCocoaWindowTitle (const Handle(Cocoa_Window)& theWindow, Standard_CString theTitle)
{
NSView* aView = theWindow->HView();
NSWindow* aWindow = [aView window];
NSString* aTitleNS = [[NSString alloc] initWithUTF8String: theTitle];
[aWindow setTitle: aTitleNS];
[aTitleNS release];
}
// =======================================================================
// function : GetCocoaScreenResolution
// purpose :
// =======================================================================
void GetCocoaScreenResolution (Standard_Integer& theWidth, Standard_Integer& theHeight)
{
NSRect aRect = [[NSScreen mainScreen] visibleFrame];
theWidth = (Standard_Integer )aRect.size.width;
theHeight = (Standard_Integer )aRect.size.height;
}
// =======================================================================
// function : FindViewId
// purpose :
// =======================================================================
TCollection_AsciiString FindViewId (const NSWindow* theWindow)
{
TCollection_AsciiString aViewId = "";
NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator anIter(ViewerTest_myViews);
for (;anIter.More();anIter.Next())
{
NSView* aView = Handle(Cocoa_Window)::DownCast
(anIter.Value()->Window())->HView();
NSWindow* aWindow = [aView window];
if (aWindow == theWindow)
{
aViewId = anIter.Key1();
return aViewId;
}
}
return aViewId;
}
@implementation Cocoa_WindowController
- (void )windowWillClose: (NSNotification* )theNotification
{
TCollection_AsciiString aViewId = "";
if (ViewerTest_myViews.IsBound2 (ViewerTest::CurrentView()))
{
aViewId = ViewerTest_myViews.Find2 (ViewerTest::CurrentView());
}
ViewerTest::RemoveView (aViewId);
}
- (void )windowDidBecomeKey: (NSNotification* )theNotification
{
NSWindow *aWindow = [theNotification object];
ActivateView (FindViewId (aWindow));
}
@end
// =======================================================================
// function : ViewerMainLoop
// purpose :
@@ -79,6 +155,10 @@ void ViewerTest_SetCocoaEventManagerView (const Handle(Cocoa_Window)& theWindow)
// replace content view in the window
theWindow->SetHView (aView);
// set delegate for window
Cocoa_WindowController* aWindowController = [[[Cocoa_WindowController alloc] init] autorelease];
[aWin setDelegate: aWindowController];
// make view as first responder in winow to capture all useful events
[aWin makeFirstResponder: aView];
[aWin setAcceptsMouseMovedEvents: YES];

View File

@@ -338,7 +338,22 @@ Quantity_Ratio Xw_Window::Ratio() const
void Xw_Window::Position (Standard_Integer& X1, Standard_Integer& Y1,
Standard_Integer& X2, Standard_Integer& Y2) const
{
//
if (myXWindow == 0)
{
return;
}
XFlush (myDisplay->GetDisplay());
XWindowAttributes anAttributes;
XGetWindowAttributes (myDisplay->GetDisplay(), myXWindow, &anAttributes);
Window aChild;
XTranslateCoordinates (myDisplay->GetDisplay(), anAttributes.root, myXWindow,
0, 0, &anAttributes.x, &anAttributes.y, &aChild);
X1 = -anAttributes.x;
X2 = X1 + anAttributes.width;
Y1 = -anAttributes.y;
Y2 = Y1 + anAttributes.height;
}
// =======================================================================