mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +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:
@@ -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
@@ -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];
|
||||
|
Reference in New Issue
Block a user