myIsOnTop( false ),
myIsHighlighted( false ),
myIsSelected( false ),
- myIsMoving( false )
+ myIsMoving( false ),
+ myIsMovable( true )
{
}
//================================================================
void GraphicsView_Object::move( double theDX, double theDY, bool theIsAtOnce )
{
+ if( !myIsMovable )
+ return;
+
if( theIsAtOnce )
{
finishMove( true );
virtual bool hasSpecificZValue() const { return false; }
virtual bool isSelectable() const { return true; }
- virtual bool isMovable() const { return true; }
+
+ virtual bool isMovable() const { return myIsMovable; }
+ virtual bool setMovable( bool theMovable ) { myIsMovable = theMovable; }
virtual QRectF getRect() const;
bool myIsSelected;
bool myIsMoving;
+ bool myIsMovable;
QTransform myViewTransform;
};
// Name : GraphicsView_ViewFrame
// Purpose : Constructor
//=======================================================================
-GraphicsView_ViewFrame::GraphicsView_ViewFrame( SUIT_Desktop* d, GraphicsView_Viewer* vw )
+GraphicsView_ViewFrame::GraphicsView_ViewFrame( SUIT_Desktop* d, GraphicsView_Viewer* vw, QWidget* w )
: SUIT_ViewWindow( d ),
myViewer( vw )
{
aLayout->setMargin( 0 );
aLayout->setSpacing( 0 );
- myViewPort = new GraphicsView_ViewPort( aFrame );
+ if( w )
+ myViewPort = dynamic_cast<GraphicsView_ViewPort*>(w);
+ else
+ myViewPort = new GraphicsView_ViewPort( aFrame );
+
aLayout->addWidget( myViewPort );
createActions();
return tid;
}
+//================================================================
+// Function : getToolBarId
+// Purpose :
+//================================================================
+int GraphicsView_ViewFrame::getToolBarId()
+{
+ return myToolBarId;
+}
+
//================================================================
// Function : dumpView
// Purpose :
enum { DumpId, FitAllId, FitRectId, FitSelectId, ZoomId, PanId, GlobalPanId, ResetId };
public:
- GraphicsView_ViewFrame( SUIT_Desktop*, GraphicsView_Viewer* );
+ GraphicsView_ViewFrame( SUIT_Desktop*, GraphicsView_Viewer*, QWidget* w = NULL );
~GraphicsView_ViewFrame();
public:
virtual void setVisualParameters( const QString& theParameters );
void expandToolBarActions();
+ int getToolBarId();
protected slots:
void onViewPan();
onBoundingRectChanged();
}
+//================================================================
+// Function : isItemAdded
+// Purpose :
+//================================================================
+bool GraphicsView_ViewPort::isItemAdded( QGraphicsItem* theItem )
+{
+ if( GraphicsView_Object* anObject = dynamic_cast<GraphicsView_Object*>( theItem ) )
+ {
+ for( GraphicsView_ObjectList::iterator anIter = myObjects.begin(); anIter != myObjects.end(); anIter++ )
+ if( theItem == *anIter )
+ return true;
+ }
+ else {
+ for( int i = 0; i < myScene->items().size(); i++ )
+ if( theItem == myScene->items().at(i) )
+ return true;
+ }
+ return false;
+}
+
//================================================================
// Function : removeItem
// Purpose :
public:
GraphicsView_Scene* getScene() { return myScene; }
void addItem( QGraphicsItem* theItem );
+ bool isItemAdded( QGraphicsItem* theItem );
void removeItem( QGraphicsItem* theItem );
enum SortType { NoSorting, SelectedFirst, SortByZLevel };
// Name : GraphicsView_Viewer
// Purpose : Constructor
//=======================================================================
-GraphicsView_Viewer::GraphicsView_Viewer( const QString& title )
+GraphicsView_Viewer::GraphicsView_Viewer( const QString& title, QWidget* widget )
: SUIT_ViewModel(),
mySelector( 0 ),
myTransformer( 0 ),
+ myWidget( widget ),
myIsInitialized( false )
{
}
//================================================================
SUIT_ViewWindow* GraphicsView_Viewer::createView( SUIT_Desktop* theDesktop )
{
- GraphicsView_ViewFrame* aViewFrame = new GraphicsView_ViewFrame( theDesktop, this );
+ GraphicsView_ViewFrame* aViewFrame = new GraphicsView_ViewFrame( theDesktop, this, myWidget );
connect( aViewFrame, SIGNAL( keyPressed( QKeyEvent* ) ),
this, SLOT( onKeyEvent( QKeyEvent* ) ) );
enum TransformType { NoTransform, Reset, FitAll, FitRect, FitSelect,
Zoom, PanGlobal, Pan, FitWidth, UserTransform = 100 };
public:
- GraphicsView_Viewer( const QString& title );
+ GraphicsView_Viewer( const QString& title, QWidget* widget = NULL );
~GraphicsView_Viewer();
public:
protected:
GraphicsView_Selector* mySelector;
GraphicsView_ViewTransformer* myTransformer;
+ QWidget* myWidget;
bool myIsInitialized;
};
return vm;
}
+SUIT_ViewManager* LightApp_Application::createViewManager( SUIT_ViewModel* theModel )
+{
+ SUIT_ResourceMgr* resMgr = resourceMgr();
+
+ SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
+ desktop(),
+ theModel );
+
+ QString vmType = vm->getType();
+
+ vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
+
+ addViewManager( vm );
+ SUIT_ViewWindow* vw = vm->createViewWindow();
+ if ( vw && desktop() ) {
+ vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
+ vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
+ }
+
+ if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
+ myUserWmTypes << vmType;
+
+ return vm;
+}
+
/*!
SLOT: Removes view manager from application
*/
virtual void removeViewManager( SUIT_ViewManager* );
virtual SUIT_ViewManager* createViewManager( const QString& vmType );
virtual SUIT_ViewManager* createViewManager( const QString& vmType, QWidget* w );
+ virtual SUIT_ViewManager* createViewManager( SUIT_ViewModel* );
QWidget* getWindow( const int, const int = -1 );
QWidget* dockWindow( const int ) const;