#include "application.h"
#include <qimage.h>
#include <qpixmap.h>
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include <qpopupmenu.h>
#include <qmenubar.h>
#include <qtextedit.h>
#include <qfile.h>
#include <qfiledialog.h>
#include <qstatusbar.h>
#include <qmessagebox.h>
#include <qprinter.h>
#include <qapplication.h>
#include <qaccel.h>
#include <qtextstream.h>
#include <qpainter.h>
#include <qpaintdevicemetrics.h>
#include <qwhatsthis.h>
#include <qaction.h>
#include <qsimplerichtext.h>
#include<qtextcodec.h>
#include<newton.h>
#include<qcombobox.h>
#include<qlabel.h>
#include <qgl.h>
#include <globjwin.h>
#include <qlayout.h>
#include"glbox2.h"
#include "filesave.xpm"
#include "fileopen.xpm"
#include "fileprint.xpm"
ApplicationWindow::ApplicationWindow()
: QMainWindow( 0, "example application main window", WDestructiveClose )
{ QTextCodec *codec = QTextCodec::codecForName("GBK");
gl=new GLObjectWindow();
g=new myWidget1();
w=new myWidget();
w->nm=new CNewton(8);
e=new QTextEdit(this);
QString str= codec->toUnicode("牛顿插值法");
QString str1= codec->toUnicode("三次样条插值法");
QString str2= codec->toUnicode("克里金插值法");
QString strText13 = codec->toUnicode("请选择插值方法:");
QPixmap pixmap1;
pixmap1.load("qt.bmp");
this->setIcon(pixmap1);
QString strText7 = codec->toUnicode("Qt - 层速度计算软件模块");
this->setCaption(strText7);
printer = new QPrinter( QPrinter::HighResolution );
QAction * fileNewAction;
QAction * fileOpenAction;
QAction * fileSaveAction,*displayAction,*displayAction1 ,* fileSaveAsAction, * filePrintAction;
QAction * fileCloseAction, * fileQuitAction,*about,*newtonAction,*sanciAction,*keliAction;
//插值动作
newtonAction = new QAction(str, CTRL+Key_F, this, "new" );
sanciAction = new QAction(str1, CTRL+Key_J, this, "new" );
keliAction = new QAction(str2, CTRL+Key_A, this, "new" );
QString strText00 = codec->toUnicode("&新建");
fileNewAction = new QAction(strText00, CTRL+Key_N, this, "new" );
connect( fileNewAction, SIGNAL( activated() ) , this,
SLOT( newDoc() ) );
QString strText0 = codec->toUnicode("&装载初始数据");
QPixmap pixmap0;
pixmap0.load("load1.bmp");
fileOpenAction = new QAction(pixmap0, strText0,
CTRL+Key_O, this, "open" );
connect( fileOpenAction, SIGNAL( activated() ) , this, SLOT( choose() ) );
const char * fileOpenText = "<p><img source=\"fileopen\"> "
"单击此按钮会装载初始层速度数据";
QString fileOpenText1 = codec->toUnicode(fileOpenText);
QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen",
fileOpenAction->iconSet().pixmap() );
fileOpenAction->setWhatsThis( fileOpenText1 );
QString strText2 = codec->toUnicode("&插入层位数据");
QPixmap pixmap2;
pixmap2.load("insert.bmp");
fileSaveAction = new QAction( pixmap2,
strText2, CTRL+Key_S, this, "save" );
connect( fileSaveAction, SIGNAL( activated() ) , this, SLOT( choose1() ) );
const char * fileSaveText = "<p>单击此按钮会插入层位数据.</p>";
QString fileSaveText1 = codec->toUnicode(fileSaveText);
fileSaveAction->setWhatsThis( fileSaveText1 );
QString strText01 = codec->toUnicode("&显示各地层速度");
QPixmap display;
display.load("display.bmp");
displayAction = new QAction(display,strText01, CTRL+Key_M, this, "dispaly" );
connect( displayAction, SIGNAL( activated() ) , this,
SLOT( display() ) );
QString st0=codec->toUnicode("单击此按钮会显示最终层速度");
displayAction->setWhatsThis(st0);
QString strText02 = codec->toUnicode("&三维显示");
QPixmap display01;
display01.load("opengl.bmp");
displayAction1 = new QAction(display01,strText02, CTRL+Key_F, this, "dispaly1" );
connect( displayAction1, SIGNAL( activated() ) , this,
SLOT( opengl() ) );
QString st01=codec->toUnicode("单击此按钮会三维立体显示");
displayAction1->setWhatsThis(st01);
QPixmap about1;
about1.load("about.bmp");
about = new QAction(about1,strText02 ,CTRL+Key_L, this, "dispaly" );
connect( about, SIGNAL( activated() ) , this,
SLOT( aboutQt() ) );
QString strText3 = codec->toUnicode("&保存");
fileSaveAsAction = new QAction( QPixmap(filesave), strText3, 0, this,
"save as" );
connect( fileSaveAsAction, SIGNAL( activated() ) , this,
SLOT( saveAs() ) );
fileSaveAsAction->setWhatsThis( fileSaveText );
QString strText4 = codec->toUnicode("&打印");
filePrintAction = new QAction( "Print File", QPixmap( fileprint ),
strText4, CTRL+Key_P, this, "print" );
connect( filePrintAction, SIGNAL( activated() ) , this,
SLOT( print() ) );
const char * filePrintText = "单击此按钮会打印数据";
QString filePrintText1 = codec->toUnicode(filePrintText);
filePrintAction->setWhatsThis( filePrintText1 );
QString strText5 = codec->toUnicode("&关闭");
fileCloseAction = new QAction( "Close", strText5, CTRL+Key_W, this,
"close" );
connect( fileCloseAction, SIGNAL( activated() ) , this,
SLOT( close() ) );
QString strText6 = codec->toUnicode("&退出");
QPixmap pixmap11;
pixmap11.load("quit.bmp");
fileQuitAction = new QAction( pixmap11,strText6, CTRL+Key_Q, this,
"quit" );
connect( fileQuitAction, SIGNAL( activated() ) , qApp,
SLOT( closeAllWindows() ) );
// 用所有动作组织一个工具栏
QToolBar * fileTools = new QToolBar( this, "file operations" );
fileTools->setLabel( "File Operations" );
fileOpenAction->addTo( fileTools );
fileSaveAction->addTo( fileTools );
displayAction->addTo(fileTools);
displayAction1->addTo(fileTools);
fileSaveAsAction->addTo(fileTools);
filePrintAction->addTo(fileTools);
about->addTo(fileTools);
(void)QWhatsThis::whatsThisButton( fileTools );
fileQuitAction->addTo(fileTools);
// 在菜单上增加动作
QPopupMenu * file = new QPopupMenu( this );
QString strText17 = codec->toUnicode("&文件(F)");
menuBar()->insertItem(strText17, file );
fileNewAction->addTo( file );
fileOpenAction->addTo( file );
fileSaveAction->addTo( file );
displayAction->addTo(file);
displayAction1->addTo(file);
file->insertSeparator();
fileSaveAsAction->addTo( file );
filePrintAction->addTo( file );
file->insertSeparator();
fileCloseAction->addTo( file );
fileQuitAction->addTo( file );
menuBar()->insertSeparator();
// 在菜单选择插值方法
QPopupMenu * insert = new QPopupMenu( this );
QString s = codec->toUnicode("&选择插值方法(B)");
menuBar()->insertItem(s, insert );
newtonAction->addTo(insert);
sanciAction->addTo(insert);
keliAction->addTo(insert);
// 增加一个帮助菜单
QPopupMenu * help = new QPopupMenu( this );
QString strText8 = codec->toUnicode("&帮助(H)");
menuBar()->insertItem(strText8, help );
QString strText9 = codec->toUnicode("&关于本软件");
QString strText10 = codec->toUnicode("&关于QT");
QString strText11= codec->toUnicode("&这是什么?");
help->insertItem( strText9, this, SLOT(about()), Key_F1 );
help->insertItem( strText10, this, SLOT(aboutQt()) );
help->insertSeparator();
help->insertItem( strText11, this, SLOT(whatsThis()),
SHIFT+Key_F1 );
// 定义中心窗体
e->hide();
e->setFocus();
statusBar()->message( "Ready", 2000 );
this->setFixedSize(500,500);
//增加显示框
QFrame* f = new QFrame( this, "frame" );
f->setFrameStyle( QFrame::Sunken | QFrame::Panel );
f->setLineWidth( 4 );
f->setGeometry(30,40,450,480);
GLBox2* c = new GLBox2( f, "glbox");
c->setGeometry(5,5,