#include "SierpinskyGUI.h"
#include "SALOME_LifeCycleCORBA.hxx"
#include "SalomeApp_Application.h"
-//#include "VisuGUI_Tools.h"
-
-#include <qlabel.h>
-#include <qlineedit.h>
-#include <qlayout.h>
-#include <qpushbutton.h>
-#include <qgroupbox.h>
-#include <qcheckbox.h>
-#include <qspinbox.h>
-#include <qthread.h>
-#include <qprogressbar.h>
-#include <qapplication.h>
+
+#include <QLabel>
+#include <QLineEdit>
+#include <QLayout>
+#include <QPushButton>
+#include <QGroupBox>
+#include <QCheckBox>
+#include <QSpinBox>
+#include <QThread>
+#include <QProgressBar>
+#include <QApplication>
#include <SUIT_Application.h>
#include <SUIT_Desktop.h>
#include <SUIT_FileDlg.h>
-#include <QtxDblSpinBox.h>
+#include <QtxDoubleSpinBox.h>
#include <SUIT_MessageBox.h>
#include <SALOMEconfig.h>
}
#define MY_EVENT QEvent::User + 555
-class MyEvent : public QCustomEvent
+class MyEvent : public QEvent
{
public:
- MyEvent( const int iter ) : QCustomEvent( MY_EVENT ), myIter( iter ) {}
+ MyEvent( const int iter ) : QEvent( (QEvent::Type)(MY_EVENT) ), myIter( iter ) {}
int iter() const { return myIter; }
private:
* Constructor
*/
SierpinskyGUI_RunDlg::SierpinskyGUI_RunDlg( QWidget* parent, SierpinskyGUI* module )
- : QDialog( parent, "SierpinskyGUI_RunDlg", true,
- WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ),
+ : QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
myThread( 0 ), myModule( module )
{
- setCaption( tr( "CAPTION" ) );
+ setAttribute( Qt::WA_DeleteOnClose );
+
+ setObjectName("SierpinskyGUI_RunDlg");
+ setModal(true);
+
+ setWindowTitle( tr( "CAPTION" ) );
setSizeGripEnabled( true );
QGridLayout* topLayout = new QGridLayout( this );
// start point group
box1 = new QGroupBox( tr( "START_POINT" ), this );
- box1->setColumnLayout( 0, Qt::Vertical );
- box1->layout()->setMargin( 0 ); box1->layout()->setSpacing( 0 );
- QGridLayout* box1Layout = new QGridLayout( box1->layout() );
+ QGridLayout* box1Layout = new QGridLayout( box1 );
box1Layout->setAlignment( Qt::AlignTop );
- box1Layout->setMargin( MARGIN_SIZE ); box1Layout->setSpacing( SPACING_SIZE );
+ box1Layout->setMargin( MARGIN_SIZE );
+ box1Layout->setSpacing( SPACING_SIZE );
QLabel* labX = new QLabel( "X:", box1 );
- myStartX = new QtxDblSpinBox( 0.0, 1.0, 0.1 ,box1);
+ myStartX = new QtxDoubleSpinBox( 0.0, 1.0, 0.1 ,box1);
myStartX->setMinimumWidth( 150 );
QLabel* labY = new QLabel( "Y:", box1 );
- myStartY = new QtxDblSpinBox( 0.0, 1.0, 0.1 ,box1);
+ myStartY = new QtxDoubleSpinBox( 0.0, 1.0, 0.1 ,box1);
myStartY->setMinimumWidth( 150 );
myStartRandom = new QCheckBox( tr( "RANDOM" ), box1 );
// base points group
box2 = new QGroupBox( tr( "BASE_POINTS" ), this );
- box2->setColumnLayout( 0, Qt::Vertical );
- box2->layout()->setMargin( 0 ); box2->layout()->setSpacing( 0 );
- QGridLayout* box2Layout = new QGridLayout( box2->layout() );
+ QGridLayout* box2Layout = new QGridLayout( box2 );
box2Layout->setAlignment( Qt::AlignTop );
- box2Layout->setMargin( MARGIN_SIZE ); box2Layout->setSpacing( SPACING_SIZE );
+ box2Layout->setMargin( MARGIN_SIZE );
+ box2Layout->setSpacing( SPACING_SIZE );
QLabel* labX1 = new QLabel( "X1:", box2 );
- myX1 = new QtxDblSpinBox( 0.0, 1.0, 0.1 , box2);
+ myX1 = new QtxDoubleSpinBox( 0.0, 1.0, 0.1 , box2);
myX1->setMinimumWidth( 150 );
QLabel* labY1 = new QLabel( "Y1:", box2 );
- myY1 = new QtxDblSpinBox( 0.0, 1.0, 0.1 , box2);
+ myY1 = new QtxDoubleSpinBox( 0.0, 1.0, 0.1 , box2);
myY1->setMinimumWidth( 150 );
QLabel* labX2 = new QLabel( "X2:", box2 );
- myX2 = new QtxDblSpinBox( 0.0, 1.0, 0.1 , box2);
+ myX2 = new QtxDoubleSpinBox( 0.0, 1.0, 0.1 , box2);
myX2->setMinimumWidth( 150 );
QLabel* labY2 = new QLabel( "Y2:", box2 );
- myY2 = new QtxDblSpinBox( 0.0, 1.0, 0.1, box2);
+ myY2 = new QtxDoubleSpinBox( 0.0, 1.0, 0.1, box2);
myY2->setMinimumWidth( 150 );
QLabel* labX3 = new QLabel( "X3:", box2 );
- myX3 = new QtxDblSpinBox( 0.0, 1.0, 0.1, box2);
+ myX3 = new QtxDoubleSpinBox( 0.0, 1.0, 0.1, box2);
myX3->setMinimumWidth( 150 );
QLabel* labY3 = new QLabel( "Y3:", box2 );
- myY3 = new QtxDblSpinBox( 0.0, 1.0, 0.1, box2);
+ myY3 = new QtxDoubleSpinBox( 0.0, 1.0, 0.1, box2);
myY3->setMinimumWidth( 150 );
myBaseRandom = new QCheckBox( tr( "RANDOM" ), box2 );
// number of iterations
QLabel* labIter = new QLabel( tr( "NB_ITERATIONS" ), this );
- myIter = new QSpinBox( 1, 100000, 1, this );
+ myIter = new QSpinBox( this );
+ myIter->setMinimum(1);
+ myIter->setMaximum(100000);
+ myIter->setSingleStep(1);
// results
box3 = new QGroupBox( tr( "RESULTS" ), this );
- box3->setColumnLayout( 0, Qt::Vertical );
- box3->layout()->setMargin( 0 ); box3->layout()->setSpacing( 0 );
- QGridLayout* box3Layout = new QGridLayout( box3->layout() );
+ QGridLayout* box3Layout = new QGridLayout( box3 );
box3Layout->setAlignment( Qt::AlignTop );
- box3Layout->setMargin( MARGIN_SIZE ); box3Layout->setSpacing( SPACING_SIZE );
+ box3Layout->setMargin( MARGIN_SIZE );
+ box3Layout->setSpacing( SPACING_SIZE );
myJpegCheck = new QCheckBox( tr( "EXPORT_2_JPEG" ), box3 );
myJpegFile = new QLineEdit( box3 );
myJpegBtn->setFixedSize( 20, 20 );
QLabel* labJpeg = new QLabel( tr( "IMAGE_SIZE" ), box3 );
- myJpegSize = new QSpinBox( 0, 1280, 10, box3 );
+ myJpegSize = new QSpinBox( box3 );
+ myJpegSize->setMinimum(0);
+ myJpegSize->setMaximum(1280);
+ myJpegSize->setSingleStep(10);
myJpegSize->setMinimumWidth( 150 );
QFrame* line = new QFrame( box3 );
myMedBtn->setFixedSize( 20, 20 );
QLabel* labMed = new QLabel( tr( "MESH_SIZE" ), box3 );
- myMedSize = new QtxDblSpinBox( 0.0, 1000, 1.0, box3);
+ myMedSize = new QtxDoubleSpinBox( 0.0, 1000, 1.0, box3);
myMedSize->setMinimumWidth( 150 );
myVisuCheck = new QCheckBox( tr( "IMPORT_MED_2_VISU" ), box3 );
- box3Layout->addMultiCellWidget( myJpegCheck, 0, 0, 0, 3 );
- box3Layout->addMultiCellWidget( myJpegFile, 1, 1, 0, 2 );
- box3Layout->addWidget( myJpegBtn, 1, 3 );
- box3Layout->addWidget( labJpeg, 2, 0 );
- box3Layout->addWidget( myJpegSize, 2, 1 );
- box3Layout->addMultiCellWidget( line, 3, 3, 0, 3 );
- box3Layout->addMultiCellWidget( myMedCheck, 4, 4, 0, 3 );
- box3Layout->addMultiCellWidget( myMedFile, 5, 5, 0, 2 );
- box3Layout->addWidget( myMedBtn, 5, 3 );
- box3Layout->addWidget( labMed, 6, 0 );
- box3Layout->addWidget( myMedSize, 6, 1 );
- box3Layout->addMultiCellWidget( myVisuCheck, 7, 7, 0, 3 );
+ box3Layout->addWidget( myJpegCheck, 0, 0, 1, 4 );
+ box3Layout->addWidget( myJpegFile, 1, 0, 1, 3 );
+ box3Layout->addWidget( myJpegBtn, 1, 3 );
+ box3Layout->addWidget( labJpeg, 2, 0 );
+ box3Layout->addWidget( myJpegSize, 2, 1 );
+ box3Layout->addWidget( line, 3, 0, 1, 4 );
+ box3Layout->addWidget( myMedCheck, 4, 0, 1, 4 );
+ box3Layout->addWidget( myMedFile, 5, 0, 1, 3 );
+ box3Layout->addWidget( myMedBtn, 5, 3 );
+ box3Layout->addWidget( labMed, 6, 0 );
+ box3Layout->addWidget( myMedSize, 6, 1 );
+ box3Layout->addWidget( myVisuCheck, 7, 0, 1, 4 );
// progress bar
myProgress = new QProgressBar( this );
- myProgress->setPercentageVisible( false );
+ myProgress->setTextVisible( false );
myProgress->setFixedHeight( 10 );
// common buttons
btnLayout->addStretch();
btnLayout->addWidget( myCancelBtn );
- topLayout->addMultiCellWidget( box1, 0, 0, 0, 1 );
- topLayout->addMultiCellWidget( box2, 1, 1, 0, 1 );
- topLayout->addWidget( labIter, 2, 0 );
- topLayout->addWidget( myIter, 2, 1 );
- topLayout->addMultiCellWidget( box3, 3, 3, 0, 1 );
- topLayout->addMultiCellWidget( myProgress,4, 4, 0, 1 );
- topLayout->addMultiCellLayout( btnLayout, 5, 5, 0, 1 );
+ topLayout->addWidget( box1, 0, 0, 1, 2 );
+ topLayout->addWidget( box2, 1, 0, 1, 2 );
+ topLayout->addWidget( labIter, 2, 0 );
+ topLayout->addWidget( myIter, 2, 1 );
+ topLayout->addWidget( box3, 3, 0, 1, 2 );
+ topLayout->addWidget( myProgress, 4, 0, 1, 2 );
+ topLayout->addLayout( btnLayout, 5, 0, 1, 2 );
// signals and slots connections
connect( myJpegBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
const QObject* snd = sender();
bool jpg = snd == myJpegBtn;
QString aFileName = SUIT_FileDlg::getFileName( this,
- jpg ? myJpegFile->text() : myMedFile->text(),
- QStringList::split( ":", jpg ? tr( "JPEG_FILES") : tr( "MED_FILES" ) ),
- jpg ? tr( "EXPORT_JPEG_FILE" ) : tr( "EXPORT_MED_FILE" ),
- false );
+ jpg ? myJpegFile->text() : myMedFile->text(),
+ (jpg ? tr( "JPEG_FILES") : tr( "MED_FILES" )).split( ":", QString::SkipEmptyParts ),
+ jpg ? tr( "EXPORT_JPEG_FILE" ) : tr( "EXPORT_MED_FILE" ),
+ false );
if ( !aFileName.isEmpty() ) {
jpg ? myJpegFile->setText( aFileName ) : myMedFile->setText( aFileName );
}
SIERPINSKY_ORB::SIERPINSKY_var aSierpGen = getSierpinskyEngine();
if( CORBA::is_nil( aRandGen ) || CORBA::is_nil( aSierpGen ) ) {
- SUIT_MessageBox::error1( this,
- tr( "ERR_ERROR" ),
- tr( "EXEC_ERROR" ),
- tr( "OK_BTN") );
+ SUIT_MessageBox::critical( this,
+ tr( "ERR_ERROR" ),
+ tr( "EXEC_ERROR" ),
+ tr( "OK_BTN") );
return;
}
QString aJPEGFile;
int aJPEGSize = 0;
if ( myJpegCheck->isChecked() ) {
- aJPEGFile = myJpegFile->text().stripWhiteSpace();
+ aJPEGFile = myJpegFile->text().trimmed();
aJPEGSize = myJpegSize->value();
if ( aJPEGFile.isEmpty() || aJPEGSize <= 0 ) {
- int res = SUIT_MessageBox::warn2( this,
- tr( "WRN_WARNING" ),
- tr( "JPEG_PARAMETERS_ERROR" ),
- tr( "YES_BTN"), tr( "NO_BTN" ), 0, 1, 0 );
+ int res = SUIT_MessageBox::warning( this,
+ tr( "WRN_WARNING" ),
+ tr( "JPEG_PARAMETERS_ERROR" ),
+ tr( "YES_BTN"), tr( "NO_BTN" ), 0, 1, 0 );
if ( res ) return;
}
}
QString aMEDFile;
double aMEDSize = 0;
if ( myMedCheck->isChecked() ) {
- aMEDFile = myMedFile->text().stripWhiteSpace();
+ aMEDFile = myMedFile->text().trimmed();
aMEDSize = myMedSize->value();
if ( aMEDFile.isEmpty() || aMEDSize <= 0 ) {
- int res = SUIT_MessageBox::warn2( this,
- tr( "WRN_WARNING" ),
- tr( "MED_PARAMETERS_ERROR" ),
- tr( "YES_BTN"), tr( "NO_BTN" ), 0, 1, 0 );
+ int res = SUIT_MessageBox::warning( this,
+ tr( "WRN_WARNING" ),
+ tr( "MED_PARAMETERS_ERROR" ),
+ tr( "YES_BTN"), tr( "NO_BTN" ), 0, 1, 0 );
if ( res ) return;
}
}
int iter = myIter->value();
// start execution
- myProgress->setTotalSteps( iter );
- myProgress->setProgress( 0 );
+ myProgress->setMaximum( iter );
+ myProgress->setValue( 0 );
if ( !myThread )
myThread = new MyThread( this, x, y, iter );
else
disconnect( myStartBtn, SIGNAL( clicked() ), this, SLOT( stop() ) );
connect( myStartBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
myStartBtn->setText( tr( "START_BTN" ) );
- myProgress->setProgress( 0 );
+ myProgress->setValue( 0 );
box1->setEnabled( true );
box2->setEnabled( true );
box3->setEnabled( true );
disconnect( myStartBtn, SIGNAL( clicked() ), this, SLOT( stop() ) );
connect( myStartBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
myStartBtn->setText( tr( "START_BTN" ) );
- myProgress->setProgress( 0 );
+ myProgress->setValue( 0 );
box1->setEnabled( true );
box2->setEnabled( true );
box3->setEnabled( true );
// export to JPEG
if ( myJpegCheck->isChecked() ) {
- QString aJPEGFile = myJpegFile->text().stripWhiteSpace();
+ QString aJPEGFile = myJpegFile->text().trimmed();
int aJPEGSize = myJpegSize->value();
if ( !aJPEGFile.isEmpty() && aJPEGSize > 0 ) {
- bool res = getSierpinskyEngine()->ExportToJPEG( aJPEGFile.latin1(), aJPEGSize );
+ bool res = getSierpinskyEngine()->ExportToJPEG( aJPEGFile.toLatin1().data(), aJPEGSize );
if ( !res ) {
// error: can't create JPEG image
}
}
// export to MED
if ( myMedCheck->isChecked() ) {
- QString aMEDFile = myMedFile->text().stripWhiteSpace();
+ QString aMEDFile = myMedFile->text().trimmed();
double aMEDSize = myMedSize->value();
if ( !aMEDFile.isEmpty() && aMEDSize > 0 ) {
- bool res = getSierpinskyEngine()->ExportToMED( aMEDFile.latin1(), aMEDSize );
+ bool res = getSierpinskyEngine()->ExportToMED( aMEDFile.toLatin1().data(), aMEDSize );
if ( res && myVisuCheck->isChecked() ) {
VISU::VISU_Gen_var aVisuGen = getVisuEngine();
if ( !CORBA::is_nil( aVisuGen ) ) {
- VISU::Result_var aResult = aVisuGen->ImportFile( aMEDFile.latin1() );
+ VISU::Result_var aResult = aVisuGen->ImportFile( aMEDFile.toLatin1().data() );
if ( !CORBA::is_nil( aResult ) )
aVisuGen->MeshOnEntity( aResult, "Sierpinsky", VISU::NODE );
myModule->getApp()->updateObjectBrowser( true );
}
}
else {
- myProgress->setProgress( myProgress->totalSteps() - step );
+ myProgress->setValue( myProgress->maximum() - step );
}
}
/*!
* Process progress event
*/
-void SierpinskyGUI_RunDlg::customEvent( QCustomEvent* e )
+void SierpinskyGUI_RunDlg::customEvent( QEvent* e )
{
if ( e->type() == MY_EVENT ) {
MyEvent* me = (MyEvent*)e;