Пример #1
0
MainWindow::MainWindow(QWidget *parent) : QWidget(parent){
    setWindowTitle("Babylon");

    //create button
    open=new QPushButton("Open");
    save1=new QPushButton("Save to TIFF");
    save2=new QPushButton("Save to JPG");
    quit=new QPushButton("Quit");
    zoomIn=new QPushButton("ZoomIn");
    zoomOut=new QPushButton("ZoomOut");
    webView=new QPushButton("GoogleMaps");
    reset=new QPushButton("Reset");
    submit=new QPushButton("Submit");
    
    //create checkBox
    movable=new QCheckBox("movable");
    movable->setChecked(true); //default
    
    //create layout
    QVBoxLayout *layout1=new QVBoxLayout;
    QGridLayout *layout=new QGridLayout;
    
    //create label & textline
    scaleLabel=new QLabel("scale");
    xlabel=new QLabel("longitude(°)");
    ylabel=new QLabel("latitude(°)");
    valueLabel=new QLabel("Value");
    minlabel=new QLabel("min");
    maxlabel=new QLabel("Max");
    scaleLine=new QLineEdit;
    xline=new QLineEdit;
    yline=new QLineEdit;
    valueLine=new QLineEdit;
    minline=new QLineEdit;
    maxline=new QLineEdit;
    
    
    //layout button
    layout1->addWidget(open);
    layout1->addWidget(quit);
    layout1->addWidget(save1);
    layout1->addWidget(save2);
    layout1->addWidget(zoomIn);
    layout1->addWidget(zoomOut);
    layout1->addWidget(webView);
    layout1->addWidget(reset);
    layout1->addWidget(movable);

    save1->setEnabled(false);
    save2->setEnabled(false);
    
    //layout textline
    layout1->addWidget(scaleLabel);
    layout1->addWidget(scaleLine);
    layout1->addWidget(ylabel);
    layout1->addWidget(yline);
    layout1->addWidget(xlabel);
    layout1->addWidget(xline);
    layout1->addWidget(valueLabel);
    layout1->addWidget(valueLine);
    
    layout1->addWidget(minlabel);
    layout1->addWidget(minline);
    layout1->addWidget(maxlabel);
    layout1->addWidget(maxline);
    layout1->addWidget(submit);
    
    layout1->addStretch();
    
    //connect button & checkBox
    connect(open,SIGNAL(clicked()),this,SLOT(open_clicked()));
    connect(quit,SIGNAL(clicked()),this,SLOT(quit_clicked()));
    connect(save1,SIGNAL(clicked()),this,SLOT(save1_clicked()));
    connect(save2,SIGNAL(clicked()),this,SLOT(save2_clicked()));
    connect(zoomIn,SIGNAL(clicked()),this,SLOT(zoomIn_clicked()));
    connect(zoomOut,SIGNAL(clicked()),this,SLOT(zoomOut_clicked()));
    connect(webView,SIGNAL(clicked()),this,SLOT(webView_clicked()));
    connect(reset,SIGNAL(clicked()),this,SLOT(reset_clicked()));
    connect(movable,SIGNAL(stateChanged(int)),this,SLOT(move_checked(int)));
    connect(submit,SIGNAL(clicked()),this,SLOT(submit_clicked()));
    
    //create Pixmap & Painter
    pixmap=new QPixmap(QSize(YOKO,TATE));
    pixmap2=new QPixmap(QSize(720,20));
    painter=new QPainter(pixmap);
    painter2=new QPainter(pixmap2);

    //create_ColorBar
     first_color_bar();


    item=new Item(); //BinaryPicture
    item->setPixmap(*pixmap);
    item->setScale(scale);
    item->setFlag(QGraphicsItem::ItemIsMovable,true);

    item2=new QGraphicsPixmapItem(*pixmap2); //ColorBar
    item2->setScale(1.3);

    scene=new QGraphicsScene(QRect(0, 0, 1440, 720)); //BinaryPicture
    scene->addItem(item);

    scene2=new QGraphicsScene(QRect(0, 0, 720, 20));  //ColorBar
    scene2->addItem(item2);

    view=new QGraphicsView(scene);
    view->setBackgroundBrush(QBrush(Qt::gray));
    view2=new QGraphicsView(scene2);
    view2->setBackgroundBrush(QBrush(Qt::black));

    layout->addLayout(layout1,0,1); //Button etc.
    layout->addWidget(view,0,0); //BinaryPicture
    layout->addWidget(view2,1,0); //ColorBar

    //statusBar(FileName)
    lb=new QLabel();
    QStatusBar *statusBar = new QStatusBar();
    statusBar->addWidget(lb);

    //setLayout
    layout->addWidget(statusBar,2,0);
    setLayout(layout);
}
Пример #2
0
/*
 *  Constructs a MyForm as a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'.
 *
 */
MyForm::MyForm( QWidget* parent, const char* name, WFlags fl )
    : QMainWindow( parent, name, fl )
{
    (void)statusBar();
    QImage img;
    img.loadFromData( image1_data, sizeof( image1_data ), "PNG" );
    image1 = img;
    img.loadFromData( image2_data, sizeof( image2_data ), "PNG" );
    image2 = img;
    img.loadFromData( image3_data, sizeof( image3_data ), "PNG" );
    image3 = img;
    img.loadFromData( image4_data, sizeof( image4_data ), "PNG" );
    image4 = img;
    if ( !name )
	setName( "MyForm" );
    setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, 1, 1, sizePolicy().hasHeightForWidth() ) );
    setCentralWidget( new QWidget( this, "qt_central_widget" ) );

    QWidget* privateLayoutWidget = new QWidget( centralWidget(), "layout13" );
    privateLayoutWidget->setGeometry( QRect( 9, 5, 853, 453 ) );
    layout13 = new QHBoxLayout( privateLayoutWidget, 2, 2, "layout13"); 

    layout12 = new QGridLayout( 0, 1, 1, 0, 6, "layout12"); 

    vScroll = new QScrollBar( privateLayoutWidget, "vScroll" );
    vScroll->setMinValue( -40 );
    vScroll->setMaxValue( 40 );
    vScroll->setOrientation( QScrollBar::Vertical );

    layout12->addWidget( vScroll, 0, 1 );

    glarea = new GLPanel( privateLayoutWidget, "glarea" );
    glarea->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, 0, 0, glarea->sizePolicy().hasHeightForWidth() ) );
    glarea->setMinimumSize( QSize( 560, 420 ) );

    layout12->addWidget( glarea, 0, 0 );

    hScroll = new QScrollBar( privateLayoutWidget, "hScroll" );
    hScroll->setMinValue( -40 );
    hScroll->setMaxValue( 40 );
    hScroll->setOrientation( QScrollBar::Horizontal );

    layout12->addWidget( hScroll, 1, 0 );
    layout13->addLayout( layout12 );

    layout11 = new QGridLayout( 0, 1, 1, 0, 6, "layout11"); 

    stepMode = new QButtonGroup( privateLayoutWidget, "stepMode" );
    stepMode->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)1, 1, 1, stepMode->sizePolicy().hasHeightForWidth() ) );
    stepMode->setLineWidth( 1 );
    stepMode->setAlignment( int( QButtonGroup::AlignHCenter ) );
    stepMode->setExclusive( TRUE );

    localCF = new QRadioButton( stepMode, "localCF" );
    localCF->setGeometry( QRect( 11, 26, 107, 20 ) );
    QFont localCF_font(  localCF->font() );
    localCF->setFont( localCF_font ); 
    localCF->setChecked( TRUE );
    stepMode->insert( localCF, 1 );

    globalCF = new QRadioButton( stepMode, "globalCF" );
    globalCF->setGeometry( QRect( 125, 26, 124, 20 ) );
    stepMode->insert( globalCF, 2 );

    layout11->addWidget( stepMode, 3, 0 );

    layout34 = new QHBoxLayout( 0, 5, 5, "layout34"); 

    add_transf = new QPushButton( privateLayoutWidget, "add_transf" );
    add_transf->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, 0, 0, add_transf->sizePolicy().hasHeightForWidth() ) );
    layout34->addWidget( add_transf );

    del_transf = new QPushButton( privateLayoutWidget, "del_transf" );
    del_transf->setEnabled( FALSE );
    del_transf->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, 0, 0, del_transf->sizePolicy().hasHeightForWidth() ) );
    layout34->addWidget( del_transf );

    layout11->addLayout( layout34, 1, 0 );

    layout10 = new QHBoxLayout( 0, 2, 2, "layout10"); 

    trsfList = new QListView( privateLayoutWidget, "trsfList" );
    trsfList->addColumn( tr( "Command" ) );
    trsfList->header()->setClickEnabled( FALSE, trsfList->header()->count() - 1 );
    trsfList->addColumn( tr( "Arguments" ) );
    trsfList->setItemMargin( 4 );
    layout10->addWidget( trsfList );

    layout9 = new QVBoxLayout( 0, 3, 2, "layout9"); 

    upList = new QPushButton( privateLayoutWidget, "upList" );
    upList->setEnabled( FALSE );
    upList->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, 0, 0, upList->sizePolicy().hasHeightForWidth() ) );
    layout9->addWidget( upList );

    downList = new QPushButton( privateLayoutWidget, "downList" );
    downList->setEnabled( FALSE );
    layout9->addWidget( downList );

    run = new QPushButton( privateLayoutWidget, "run" );
    layout9->addWidget( run );

    step = new QPushButton( privateLayoutWidget, "step" );
    layout9->addWidget( step );

    reset = new QPushButton( privateLayoutWidget, "reset" );
    layout9->addWidget( reset );
    layout10->addLayout( layout9 );

    layout11->addLayout( layout10, 2, 0 );

    trans_tab = new QTabWidget( privateLayoutWidget, "trans_tab" );
    trans_tab->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, trans_tab->sizePolicy().hasHeightForWidth() ) );
    trans_tab->setMinimumSize( QSize( 0, 150 ) );

    tab = new QWidget( trans_tab, "tab" );

    QWidget* privateLayoutWidget_2 = new QWidget( tab, "layout2" );
    privateLayoutWidget_2->setGeometry( QRect( 0, 10, 230, 97 ) );
    layout2 = new QGridLayout( privateLayoutWidget_2, 1, 1, 7, 4, "layout2"); 

    textLabel3 = new QLabel( privateLayoutWidget_2, "textLabel3" );

    layout2->addWidget( textLabel3, 2, 0 );

    y_trans = new QSpinBox( privateLayoutWidget_2, "y_trans" );
    y_trans->setMaxValue( 99 );
    y_trans->setMinValue( -99 );

    layout2->addWidget( y_trans, 1, 1 );

    textLabel2 = new QLabel( privateLayoutWidget_2, "textLabel2" );

    layout2->addWidget( textLabel2, 1, 0 );

    x_trans = new QSpinBox( privateLayoutWidget_2, "x_trans" );
    x_trans->setMaxValue( 99 );
    x_trans->setMinValue( -99 );

    layout2->addWidget( x_trans, 0, 1 );

    textLabel1 = new QLabel( privateLayoutWidget_2, "textLabel1" );
    textLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)7, 0, 5, textLabel1->sizePolicy().hasHeightForWidth() ) );

    layout2->addWidget( textLabel1, 0, 0 );

    z_trans = new QSpinBox( privateLayoutWidget_2, "z_trans" );
    z_trans->setMinValue( -99 );

    layout2->addWidget( z_trans, 2, 1 );
    trans_tab->insertTab( tab, QString::fromLatin1("") );

    tab_2 = new QWidget( trans_tab, "tab_2" );

    QWidget* privateLayoutWidget_3 = new QWidget( tab_2, "layout2_2" );
    privateLayoutWidget_3->setGeometry( QRect( 0, 10, 230, 95 ) );
    layout2_2 = new QGridLayout( privateLayoutWidget_3, 1, 1, 7, 4, "layout2_2"); 

    textLabel3_2 = new QLabel( privateLayoutWidget_3, "textLabel3_2" );

    layout2_2->addWidget( textLabel3_2, 2, 0 );

    y_scale = new QSpinBox( privateLayoutWidget_3, "y_scale" );
    y_scale->setMinValue( -99 );
    y_scale->setValue( 1 );

    layout2_2->addWidget( y_scale, 1, 1 );

    textLabel2_2 = new QLabel( privateLayoutWidget_3, "textLabel2_2" );

    layout2_2->addWidget( textLabel2_2, 1, 0 );

    x_scale = new QSpinBox( privateLayoutWidget_3, "x_scale" );
    x_scale->setMinValue( -99 );
    x_scale->setValue( 1 );

    layout2_2->addWidget( x_scale, 0, 1 );

    textLabel1_2 = new QLabel( privateLayoutWidget_3, "textLabel1_2" );

    layout2_2->addWidget( textLabel1_2, 0, 0 );

    z_scale = new QSpinBox( privateLayoutWidget_3, "z_scale" );
    z_scale->setMinValue( -99 );
    z_scale->setValue( 1 );

    layout2_2->addWidget( z_scale, 2, 1 );
    trans_tab->insertTab( tab_2, QString::fromLatin1("") );

    TabPage = new QWidget( trans_tab, "TabPage" );

    QWidget* privateLayoutWidget_4 = new QWidget( TabPage, "layout7" );
    privateLayoutWidget_4->setGeometry( QRect( 14, 71, 220, 40 ) );
    layout7 = new QHBoxLayout( privateLayoutWidget_4, 3, 3, "layout7"); 

    textLabel1_3 = new QLabel( privateLayoutWidget_4, "textLabel1_3" );
    textLabel1_3->setMargin( 8 );
    textLabel1_3->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
    layout7->addWidget( textLabel1_3 );

    rot_angle = new QSpinBox( privateLayoutWidget_4, "rot_angle" );
    rot_angle->setMaxValue( 180 );
    rot_angle->setMinValue( -180 );
    layout7->addWidget( rot_angle );

    buttonGroup1 = new QButtonGroup( TabPage, "buttonGroup1" );
    buttonGroup1->setEnabled( TRUE );
    buttonGroup1->setGeometry( QRect( 13, 4, 225, 60 ) );
    buttonGroup1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)5, 0, 0, buttonGroup1->sizePolicy().hasHeightForWidth() ) );
    buttonGroup1->setMouseTracking( FALSE );
    buttonGroup1->setFocusPolicy( QButtonGroup::ClickFocus );
    buttonGroup1->setFrameShape( QButtonGroup::GroupBoxPanel );
    buttonGroup1->setFrameShadow( QButtonGroup::Sunken );
    buttonGroup1->setLineWidth( 1 );
    buttonGroup1->setMargin( 0 );
    buttonGroup1->setAlignment( int( QButtonGroup::AlignTop | QButtonGroup::AlignLeft ) );
    buttonGroup1->setExclusive( TRUE );
    buttonGroup1->setProperty( "selectedId", 1 );

    x_axis = new QRadioButton( buttonGroup1, "x_axis" );
    x_axis->setGeometry( QRect( 20, 25, 35, 20 ) );
    x_axis->setChecked( TRUE );
    buttonGroup1->insert( x_axis, 1 );

    z_axis = new QRadioButton( buttonGroup1, "z_axis" );
    z_axis->setGeometry( QRect( 180, 25, 34, 20 ) );
    buttonGroup1->insert( z_axis, 3 );

    y_axis = new QRadioButton( buttonGroup1, "y_axis" );
    y_axis->setGeometry( QRect( 100, 25, 35, 20 ) );
    buttonGroup1->insert( y_axis, 2 );
    trans_tab->insertTab( TabPage, QString::fromLatin1("") );

    layout11->addWidget( trans_tab, 0, 0 );
    layout13->addLayout( layout11 );

    // actions
    fileNewAction = new QAction( this, "fileNewAction" );
    fileNewAction->setIconSet( QIconSet( image1 ) );
    fileOpenAction = new QAction( this, "fileOpenAction" );
    fileOpenAction->setIconSet( QIconSet( image2 ) );
    fileSaveAction = new QAction( this, "fileSaveAction" );
    fileSaveAction->setIconSet( QIconSet( image3 ) );
    fileSaveAsAction = new QAction( this, "fileSaveAsAction" );
    filePrintAction = new QAction( this, "filePrintAction" );
    filePrintAction->setIconSet( QIconSet( image4 ) );
    fileExitAction = new QAction( this, "fileExitAction" );


    // toolbars


    // menubar
    MenuBar = new QMenuBar( this, "MenuBar" );


    fileMenu = new QPopupMenu( this );
    fileNewAction->addTo( fileMenu );
    fileOpenAction->addTo( fileMenu );
    fileSaveAction->addTo( fileMenu );
    fileSaveAsAction->addTo( fileMenu );
    fileMenu->insertSeparator();
    filePrintAction->addTo( fileMenu );
    fileMenu->insertSeparator();
    fileExitAction->addTo( fileMenu );
    MenuBar->insertItem( QString(""), fileMenu, 1 );

    languageChange();
    resize( QSize(864, 533).expandedTo(minimumSizeHint()) );
    clearWState( WState_Polished );

    // signals and slots connections
    connect( fileExitAction, SIGNAL( activated() ), this, SLOT( close() ) );
    connect( step, SIGNAL( clicked() ), this, SLOT( step_clicked() ) );
    connect( add_transf, SIGNAL( clicked() ), this, SLOT( add_transf_clicked() ) );
    connect( del_transf, SIGNAL( clicked() ), this, SLOT( del_transf_clicked() ) );
    connect( trsfList, SIGNAL( currentChanged(QListViewItem*) ), this, SLOT( trsfList_currentChanged(QListViewItem*) ) );
    connect( trsfList, SIGNAL( clicked(QListViewItem*) ), this, SLOT( trsfList_clicked(QListViewItem*) ) );
    connect( upList, SIGNAL( clicked() ), this, SLOT( upList_clicked() ) );
    connect( downList, SIGNAL( clicked() ), this, SLOT( downList_clicked() ) );
    connect( run, SIGNAL( clicked() ), this, SLOT( run_clicked() ) );
    connect( reset, SIGNAL( clicked() ), this, SLOT( reset_clicked() ) );
}