#include <qpainter.h>
#include <qmenu.h>
#include <qcolordialog.h>
-#include <qcursor.h>\r
-#include <qevent.h>\r
+#include <qcursor.h>
+#include <qevent.h>
#include <qrubberband.h>
#include "View.h"
View::View( Handle(AIS_InteractiveContext) theContext, QWidget* parent, MDIWindow* mdi )
: QWidget( parent ), myMDI( mdi ), myRubberBand( 0 )
{
- setBackgroundRole( QPalette::NoRole );//NoBackground );\r
- // set focus policy to threat QContextMenuEvent from keyboard \r
- setFocusPolicy( Qt::StrongFocus );\r
- setAttribute( Qt::WA_PaintOnScreen );\r
- setAttribute( Qt::WA_NoSystemBackground );\r
-\r
+ setBackgroundRole( QPalette::NoRole );//NoBackground );
+ // set focus policy to threat QContextMenuEvent from keyboard
+ setFocusPolicy( Qt::StrongFocus );
+ setAttribute( Qt::WA_PaintOnScreen );
+ setAttribute( Qt::WA_NoSystemBackground );
+
#ifndef WNT
XSynchronize( x11Display(), true ); // it is possible to use QApplication::syncX();
#endif
*/
Visual *v = DefaultVisual( x11Display(), DefaultScreen( x11Display() ) );
int visualID = XVisualIDFromVisual( v );
-\r
+
/* Here we use the settings from
Optimizer_ViewInfo::TxglCreateWindow()
*/
int visualAttr[] = { GLX_RGBA, GLX_DEPTH_SIZE, 1,
GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER,
- None };\r
+ None };
pVisualInfo = ::glXChooseVisual (x11Display(), DefaultScreen(x11Display()), visualAttr);
- if ( isVisible() )\r
+ if ( isVisible() )
hide();
XSetWindowAttributes a;
int count;
if ( XGetWMColormapWindows( x11Display(), topLevelWidget()->winId(),
&cmwret, &count ) ) {
- cmw = new Window[count+1];\r
- memcpy( (char *)cmw, (char *)cmwret, sizeof(Window)*count );\r
- XFree( (char *)cmwret );\r
- int i;\r
- for (i = 0; i < count; i++) {\r
- if ( cmw[i] == winId() ) { /* replace old window */\r
- cmw[i] = w;\r
- break;\r
- }\r
- }\r
- if ( i >= count ) /* append new window */\r
- cmw[count++] = w;\r
- } else {\r
- count = 1;\r
- cmw = new Window[count];\r
- cmw[0] = w;\r
- }\r
- /* Creating new window (with good VisualID) for this widget */\r
- create( w );\r
- XSetWMColormapWindows( x11Display(), topLevelWidget()->winId(), cmw, count );\r
- delete [] cmw;\r
-\r
- if ( isVisible() )\r
- show();\r
- if ( pVisualInfo ) {\r
- XFree( (char *)pVisualInfo );\r
- }\r
- XFlush( x11Display() );\r
- }\r
-#endif // !defined WNT\r
- \r
- // will be set in OnInitial update, but, for more security :\r
- myCurrentMode = CurAction3d_Nothing;\r
- setMouseTracking( true );\r
- myView = NULL;\r
+ cmw = new Window[count+1];
+ memcpy( (char *)cmw, (char *)cmwret, sizeof(Window)*count );
+ XFree( (char *)cmwret );
+ int i;
+ for (i = 0; i < count; i++) {
+ if ( cmw[i] == winId() ) { /* replace old window */
+ cmw[i] = w;
+ break;
+ }
+ }
+ if ( i >= count ) /* append new window */
+ cmw[count++] = w;
+ } else {
+ count = 1;
+ cmw = new Window[count];
+ cmw[0] = w;
+ }
+ /* Creating new window (with good VisualID) for this widget */
+ create( w );
+ XSetWMColormapWindows( x11Display(), topLevelWidget()->winId(), cmw, count );
+ delete [] cmw;
+
+ if ( isVisible() )
+ show();
+ if ( pVisualInfo ) {
+ XFree( (char *)pVisualInfo );
+ }
+ XFlush( x11Display() );
+ }
+#endif // !defined WNT
+
+ // will be set in OnInitial update, but, for more security :
+ myCurrentMode = CurAction3d_Nothing;
+ setMouseTracking( true );
+ myView = NULL;
}
View::~View()
-{\r
+{
}
void View::init()
-{\r
- myView = myContext->CurrentViewer()->CreateView();\r
- int windowHandle = (int) winId();\r
- short hi, lo;\r
- lo = (short) windowHandle;\r
- hi = (short) ( windowHandle >> 16 );\r
-#ifdef WNT\r
- Handle(WNT_Window) hWnd = \r
- new WNT_Window( Handle(Graphic3d_WNTGraphicDevice)::\r
- DownCast( myContext->CurrentViewer()->Device() ) , (int) hi, (int) lo );\r
-#else\r
- Handle(Xw_Window) hWnd = \r
- new Xw_Window( Handle(Graphic3d_GraphicDevice)::\r
- DownCast( myContext->CurrentViewer()->Device() ),\r
- (int) hi, (int) lo, Xw_WQ_SAMEQUALITY, Quantity_NOC_BLACK );\r
-#endif // WNT\r
- myView->SetWindow( hWnd );\r
- if ( !hWnd->IsMapped() )\r
- hWnd->Map();\r
- myView->SetBackgroundColor(Quantity_NOC_GRAY40);\r
- myView->MustBeResized();\r
-\r
- Handle(Geom_Axis2Placement) anAxis = new Geom_Axis2Placement( gp::XOY() );\r
- myTrihedron = new AIS_Trihedron( anAxis );\r
- myContext->Display( myTrihedron );\r
-\r
- //myView->SetAntialiasingOn();\r
- myComputedModeIsOn = true;\r
- myView->SetScale(3.0316);\r
-\r
- // This is to update View properties dialog\r
- emit ViewInitialized();\r
-}\r
+{
+ myView = myContext->CurrentViewer()->CreateView();
+ int windowHandle = (int) winId();
+ short hi, lo;
+ lo = (short) windowHandle;
+ hi = (short) ( windowHandle >> 16 );
+#ifdef WNT
+ Handle(WNT_Window) hWnd =
+ new WNT_Window( Handle(Graphic3d_WNTGraphicDevice)::
+ DownCast( myContext->CurrentViewer()->Device() ) , (int) hi, (int) lo );
+#else
+ Handle(Xw_Window) hWnd =
+ new Xw_Window( Handle(Graphic3d_GraphicDevice)::
+ DownCast( myContext->CurrentViewer()->Device() ),
+ (int) hi, (int) lo, Xw_WQ_SAMEQUALITY, Quantity_NOC_BLACK );
+#endif // WNT
+ myView->SetWindow( hWnd );
+ if ( !hWnd->IsMapped() )
+ hWnd->Map();
+ myView->SetBackgroundColor(Quantity_NOC_GRAY40);
+ myView->MustBeResized();
+
+ Handle(Geom_Axis2Placement) anAxis = new Geom_Axis2Placement( gp::XOY() );
+ myTrihedron = new AIS_Trihedron( anAxis );
+ myContext->Display( myTrihedron );
+
+ //myView->SetAntialiasingOn();
+ myComputedModeIsOn = true;
+ myView->SetScale(3.0316);
+
+ // This is to update View properties dialog
+ emit ViewInitialized();
+}
void View::paintEvent ( QPaintEvent * e)
{
case CurAction3d_GlobalPanning :// noting
break;
case CurAction3d_DynamicRotation :
- if (!myComputedModeIsOn){\r
- myView->SetComputedMode(false);\r
- }\r
+ if (!myComputedModeIsOn){
+ myView->SetComputedMode(false);
+ }
myView->SetAnimationModeOn();
myView->StartRotation(point.x(),point.y());
break;
void View::onRButtonDown( Qt::KeyboardModifiers nFlags, const QPoint point )
{
- if ( nFlags == CASCADESHORTCUTKEY ) {\r
+ if ( nFlags == CASCADESHORTCUTKEY ) {
if ( !myComputedModeIsOn )
myView->SetComputedMode(false);
-// Standard_Boolean anim, deg;\r
-// anim = myView->AnimationMode( deg );\r
-// if ( anim /*&& deg*/ ) {\r
+// Standard_Boolean anim, deg;
+// anim = myView->AnimationMode( deg );
+// if ( anim /*&& deg*/ ) {
myCycleCounter = 0;
Application::startTimer();
- myView->SetAnimationModeOn();\r
+ myView->SetAnimationModeOn();
// myView->SetAnimationMode(true,true);
// myContext->DeactivateStandardMode( TopAbs_SHAPE );
// }
emit noActiveActions();
break;
case CurAction3d_DynamicRotation :
- myCurrentMode = CurAction3d_Nothing;\r
+ myCurrentMode = CurAction3d_Nothing;
myView->SetAnimationModeOff();
emit noActiveActions();
break;
QApplication::setOverrideCursor( Qt::WaitCursor );
// reset computed mode according to the stored one
// --> dynamic rotation may have change it
-\r
+
if (!myComputedModeIsOn)
- { \r
+ {
myView->SetComputedMode(false);
myComputedModeIsOn = Standard_False;
} else
- {\r
+ {
myView->SetComputedMode(false);
myComputedModeIsOn = Standard_True;
- }\r
+ }
//if ( myView->AnimationModeIsOn() ) {
myView->SetAnimationModeOff();
{
QMenu* popMenu = new QMenu( this );
- if( myContext->NbCurrents()) {\r
- QAction* a;\r
- myContext->InitCurrent();\r
- if (! myContext->Current()->IsKind(STANDARD_TYPE(AIS_Trihedron)))\r
+ if( myContext->NbCurrents()) {
+ QAction* a;
+ myContext->InitCurrent();
+ if (! myContext->Current()->IsKind(STANDARD_TYPE(AIS_Trihedron)))
{
a = new QAction( tr( "MEN_POP_OBJPROP" ), this );
- verify( connect( a, SIGNAL( activated() ), SLOT( onEditObjectProperties() ) ) );\r
+ verify( connect( a, SIGNAL( activated() ), SLOT( onEditObjectProperties() ) ) );
popMenu->addAction( a );
QMenu* dMode = popMenu->addMenu( tr( "MEN_POP_DISPLAYMODE" ) );
a = new QAction( tr( "MEN_POP_WIREFRAME" ), this );
- verify( connect( a, SIGNAL( activated() ), SLOT( onWireframeMode() ) ) );\r
+ verify( connect( a, SIGNAL( activated() ), SLOT( onWireframeMode() ) ) );
dMode->addAction( a );
-\r
+
a = new QAction( tr( "MEN_POP_SHADING" ), this );
verify( connect( a, SIGNAL( activated() ), SLOT( onShadingMode() ) ) );
- dMode->addAction( a );\r
+ dMode->addAction( a );
}
a = new QAction( tr( "MEN_POP_REMOVEOBJECT" ), this );
verify( connect( a, SIGNAL( activated() ), SLOT( onRemoveObject() ) ) );
- popMenu->addAction( a );\r
+ popMenu->addAction( a );
}
else {
QAction* a = new QAction( tr( "MEN_POP_VIEWPROP" ), this );
verify( connect( a, SIGNAL( activated() ), Application::getApplication(), SLOT( onEditViewProperties() ) ) );
- popMenu->addAction( a );\r
+ popMenu->addAction( a );
a = new QAction( tr( "MEN_POP_IMPORT" ), this );
verify( connect( a, SIGNAL( activated() ), SLOT( onImportObject() ) ) );
- popMenu->addAction( a );\r
+ popMenu->addAction( a );
popMenu->addSeparator();
if ( myContext->IsDisplayed( myTrihedron ) ) {
a = new QAction( tr( "MEN_POP_ERASETRIHEDRON" ), this );
verify( connect( a, SIGNAL( activated() ), SLOT( onEraseTrihedron() ) ) );
- popMenu->addAction( a );\r
+ popMenu->addAction( a );
}
else {
a = new QAction( tr( "MEN_POP_DISPLAYTRIHEDRON" ), this );
verify( connect( a, SIGNAL( activated() ), SLOT( onDisplayTrihedron() ) ) );
- popMenu->addAction( a );\r
+ popMenu->addAction( a );
}
popMenu->addSeparator();
a = new QAction( tr( "MEN_POP_CREATESHAPE" ), this );
verify( connect( a, SIGNAL( activated() ), SLOT( onCreateShape() ) ) );
- popMenu->addAction( a );\r
+ popMenu->addAction( a );
QMenu* loadObj = popMenu->addMenu( tr( "MEN_POP_LOADOBJECT" ) );
a = new QAction( tr( "MEN_POP_BOX" ), this );
verify( connect( a, SIGNAL( activated() ), SLOT( onLoadBox() ) ) );
- loadObj->addAction( a );\r
+ loadObj->addAction( a );
a = new QAction( tr( "MEN_POP_SPHERE" ), this );
verify( connect( a, SIGNAL( activated() ), SLOT( onLoadSphere() ) ) );
- loadObj->addAction( a );\r
+ loadObj->addAction( a );
a = new QAction( tr( "MEN_POP_TORUS" ), this );
verify( connect( a, SIGNAL( activated() ), SLOT( onLoadTorus() ) ) );
- loadObj->addAction( a );\r
+ loadObj->addAction( a );
-// a = new QAction( tr( "MEN_POP_LINE" ), this );\r
-// verify( connect( a, SIGNAL( activated() ), SLOT( onLoadLine() ) ) );\r
-// loadObj->addAction( a );\r
+// a = new QAction( tr( "MEN_POP_LINE" ), this );
+// verify( connect( a, SIGNAL( activated() ), SLOT( onLoadLine() ) ) );
+// loadObj->addAction( a );
}
popMenu->exec( QCursor::pos() );
}
void View::DrawRectangle( int MinX, int MinY, int MaxX, int MaxY, bool Draw )
-{\r
- if ( !myRubberBand )\r
- myRubberBand = new QRubberBand( QRubberBand::Rectangle, this );\r
- \r
- myRubberBand->setGeometry( QRect( QPoint( MinX, MinY ), QPoint( MaxX, MaxY ) ).normalized() );\r
- myRubberBand->setVisible( Draw );\r
+{
+ if ( !myRubberBand )
+ myRubberBand = new QRubberBand( QRubberBand::Rectangle, this );
+
+ myRubberBand->setGeometry( QRect( QPoint( MinX, MinY ), QPoint( MaxX, MaxY ) ).normalized() );
+ myRubberBand->setVisible( Draw );
/*
QPainter thePainter(this);
thePainter.setRasterOp(Qt::XorROP);
thePainter.drawRect(aRect);
m_IsVisible = true;
}
- */\r
+ */
}
void View::onImportObject()
}
void View::onCreateShape()
-{\r
+{
myView->SetScale(3.0316);
if ( !myShapeDlg )
myShapeDlg = new ShapeDlg( Application::getApplication(), myView, myContext );
}
void View::onLoadBox()
-{\r
+{
myView->SetScale(1.0);
Standard_Real size = myContext->CurrentViewer()->DefaultViewSize() / 4.;
gp_Pnt origin( -size / 2., -size / 2., -size / 2. );
}
void View::onLoadSphere()
-{\r
+{
myView->SetScale(1.0);
Standard_Real radius = myContext->CurrentViewer()->DefaultViewSize() / 4.;
Handle(AIS_Shape) sphere =
}
void View::onLoadTorus()
-{\r
+{
myView->SetScale(1.0);
Handle(V3d_Viewer) viewer = myContext->CurrentViewer();
Standard_Real r1 = viewer->DefaultViewSize() / 3.;
}
void View::onLoadLine()
-{\r
+{
myView->SetScale(1.0);
Handle(AIS_Line) line =
new AIS_Line( new Geom_Line( gp_Pnt( 0, 0, 0), gp_Dir( 0, 0, 1) ) );
}
void View::onShadingMode()
-{\r
- \r
- myContext->InitSelected();\r
- for( ; myContext->MoreSelected(); myContext->NextSelected() ) {\r
- Handle(AIS_InteractiveObject) obj = myContext->SelectedInteractive();\r
- //myContext->Erase( obj, false );\r
- //myContext->Display( obj /*, 1, 0*/, false );\r
- //myContext->Activate( obj, 0 );\r
- myContext->SetDisplayMode( obj, 1 );\r
- }\r
- myContext->UpdateCurrentViewer();\r
- \r
+{
+
+ myContext->InitSelected();
+ for( ; myContext->MoreSelected(); myContext->NextSelected() ) {
+ Handle(AIS_InteractiveObject) obj = myContext->SelectedInteractive();
+ //myContext->Erase( obj, false );
+ //myContext->Display( obj /*, 1, 0*/, false );
+ //myContext->Activate( obj, 0 );
+ myContext->SetDisplayMode( obj, 1 );
+ }
+ myContext->UpdateCurrentViewer();
+
}
void View::onDisplayTrihedron()