// Qt includes
#include <QCloseEvent>
-#include <QTimerEvent>
+#include <QApplication>
#include <QGraphicsScene>
+#define DRAW_EVENT ( QEvent::User + 1 )
#include <iostream>
QWidgetAction* hierarchyDepthAction = new QWidgetAction( theViewFrame );
hierarchyDepthAction->setDefaultWidget( myHierarchyDepth );
- QPushButton* updateButton = new QPushButton( tr( "UPDATE" ) );
+ updateButton = new QPushButton( tr( "UPDATE" ) );
QWidgetAction* updateAction = new QWidgetAction( theViewFrame );
updateAction->setDefaultWidget( updateButton );
std::cout << "\n\n\n TOTAL COST = " << myTotalCost << std::endl;
clearSelected();
+ clearView( false );
// draw nodes on scene
std::map< std::string, int > entryLevelMap;
return;
currentLevel = 0;
myComputedCost++;
- sleep(1);
std::string objectEntry = i->first;
DependencyTree_Object* objectItem = myTreeMap[ objectEntry ];
horDistance = 100 + int( objectItem->boundingRect().width() );
drawWardArrows( j->second.second );
}
std::cout << "\n ComputedCost = " << myComputedCost << std::endl;
- fitAll( true );
}
int DependencyTree_View::select( const QRectF& theRect, bool theIsAppend )
mySelectionMgr->setSelectedObjects( listIO, true );
}
+void DependencyTree_View::customEvent ( QEvent * event )
+{
+ if( event->type() == DRAW_EVENT ) {
+ //qthread->sleepDraw();
+
+ std::cout << "\n\n\n DRAW_EVENT!!! " << std::endl;
+ QPushButton* cancelButton = dynamic_cast<QPushButton*>( cancelAction->defaultWidget() );
+ QProgressBar* progressBar = dynamic_cast<QProgressBar*>( progressAction->defaultWidget() );
+
+ std::cout << "\n\n *** myIsCompute " << myIsCompute << std::endl;
+ if ( !cancelButton->isChecked() ) {
+ std::cout << "\n\n *** getComputeProgress = " << getComputeProgress() << std::endl;
+ progressBar->setValue( progressBar->maximum() * getComputeProgress() );
+
+ }
+
+ std::cout << "\n\n *** qthread->isFinished() = " << qthread->isFinished() << std::endl;
+ if( !myIsCompute || qthread->isFinished() ) {
+ changeWidgetState( false );
+ cancelButton->setChecked( false );
+ progressBar->setValue(0);
+ }
+ }
+ event->accept();
+}
+
+void DependencyTree_View::addItem( QGraphicsItem* theObject )
+{
+ GraphicsView_ViewPort::addItem( theObject );
+ qthread->sleepDraw();
+ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+ QApplication::postEvent( this, new QEvent( ( QEvent::Type )DRAW_EVENT ) );
+}
+
void DependencyTree_View::mouseMoveEvent(QMouseEvent *event)
{
QGraphicsView::mouseMoveEvent( event );
return myIsCompute;
}
-void DependencyTree_View::timerEvent(QTimerEvent *event)
-{
- QPushButton* cancelButton = dynamic_cast<QPushButton*>( cancelAction->defaultWidget() );
- QProgressBar* progressBar = dynamic_cast<QProgressBar*>( progressAction->defaultWidget() );
-
- std::cout << "TIMER! " << std::endl;
- if ( !cancelButton->isChecked() )
- progressBar->setValue( progressBar->maximum() * getComputeProgress() );
-
- if( !myIsCompute || qthread->isFinished() ) {
- changeWidgetState( false );
- killTimer( myTimer );
- cancelButton->setChecked( false );
- progressBar->setValue(0);
- }
- event->accept();
-}
+//void DependencyTree_View::timerEvent(QTimerEvent *event)
+//{
+// QPushButton* cancelButton = dynamic_cast<QPushButton*>( cancelAction->defaultWidget() );
+// QProgressBar* progressBar = dynamic_cast<QProgressBar*>( progressAction->defaultWidget() );
+//
+// std::cout << "TIMER! " << std::endl;
+// if ( !cancelButton->isChecked() )
+// progressBar->setValue( progressBar->maximum() * getComputeProgress() );
+//
+// if( !myIsCompute || qthread->isFinished() ) {
+// changeWidgetState( false );
+// killTimer( myTimer );
+// cancelButton->setChecked( false );
+// progressBar->setValue(0);
+// }
+// event->accept();
+//}
void DependencyTree_View::closeEvent( QCloseEvent* event )
{
if( !myIsUpdate )
return;
- clearView( false );
+// clearView( false );
qthread = new DependencyTree_ComputeDlg_QThread( this );
changeWidgetState( true );
- myTimer = startTimer( 100 ); // millisecs
+ //myTimer = startTimer( 100 ); // millisecs
qthread->start();
}
if( level >= myLevelsNumber || !myIsCompute )
return;
myComputedCost++;
- sleep(1);
theCurrentLevel += theLevelStep;
GEOMUtils::LevelInfo levelInfo = theWard.at( level );
GEOMUtils::LevelInfo::const_iterator node;
if( j >= myLevelsNumber || !myIsCompute )
break;
myComputedCost++;
- sleep(1);
GEOMUtils::LevelInfo Level = theWard.at(j);
GEOMUtils::LevelInfo::const_iterator node;
for (node = Level.begin(); node != Level.end(); node++ ) {
myHierarchyDepth->setEnabled( !theIsCompute );
myDisplayAscendants->setEnabled( !theIsCompute );
myDisplayDescendants->setEnabled( !theIsCompute );
+ updateButton->setEnabled( !theIsCompute );
}
DependencyTree_ComputeDlg_QThread::DependencyTree_ComputeDlg_QThread( DependencyTree_View* theView )
{
myView->setIsCompute( true );
myView->drawTree();
+ myView->fitAll( true );
+ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+ QApplication::postEvent( myView, new QEvent( ( QEvent::Type )DRAW_EVENT ) );
}
-bool DependencyTree_ComputeDlg_QThread::result()
+void DependencyTree_ComputeDlg_QThread::sleepDraw()
{
-
+ msleep(10);
}
void DependencyTree_ComputeDlg_QThread::cancel()