FlowVis 1.0
|
00001 #include "MainWindow.h" 00002 00003 MainWindow::MainWindow(QMainWindow * parent): 00004 QMainWindow(parent) 00005 { 00006 00007 #ifdef _WIN32 00008 AllocConsole(); 00009 00010 freopen("CONIN$","rb",stdin); // reopen stdin handle as console window input 00011 freopen("CONOUT$","wb",stdout); // reopen stout handle as console window output 00012 freopen("CONOUT$","wb",stderr); // reopen stderr handle as console window output 00013 #endif 00014 00015 Init(); 00016 ConnectSignals(); 00017 } 00018 00019 MainWindow::~MainWindow() 00020 { 00021 00022 } 00023 00024 void MainWindow::Init() 00025 { 00026 setWindowTitle("Flow Visualizer 3000"); 00027 00028 00029 QWidget* main = new QWidget(); 00030 00031 renderer = new RenderWidget(); 00032 renderer->setMinimumSize(800,800); 00033 00034 layerManager = new LayerManagerWidget(); 00035 settings = new SettingsWidget(); 00036 00037 QHBoxLayout* layout = new QHBoxLayout(); 00038 00039 00040 QVBoxLayout* box1 = new QVBoxLayout(); 00041 box1->addWidget(layerManager); 00042 box1->addStretch(); 00043 00044 QVBoxLayout* box2 = new QVBoxLayout(); 00045 box2->addWidget(settings); 00046 box2->addStretch(); 00047 00048 QTabWidget *tab = new QTabWidget(); 00049 tab->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding); 00050 tab->addTab(layerManager,"Layers"); 00051 tab->addTab(settings,"Settings"); 00052 00053 layout->setMargin(0); 00054 layout->addWidget(renderer); 00055 layout->addWidget(tab,Qt::AlignTop); 00056 00057 //QGridLayout* gridLayout = new QGridLayout(); 00058 // 00059 //QVBoxLayout* box = new QVBoxLayout(); 00060 //TransferSettingsWidget* t1 = new TransferSettingsWidget(); 00061 //TransferSettingsWidget* t2 = new TransferSettingsWidget(); 00062 //t1->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 00063 //t2->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 00064 00065 //box->addWidget(new LayerManagerWidget()); 00066 // 00067 //box->addStretch(); 00068 // 00069 // 00070 //gridLayout->setMargin(0); 00074 //gridLayout->addWidget(renderer,0,0); 00075 //gridLayout->addLayout(box,0,1); 00076 00077 loadAction = new QAction(tr("&Open"), this); 00078 loadAction->setShortcut(tr("Ctrl+O")); 00079 00080 configLoad = new QAction(tr("&Load"), this); 00081 configLoad->setShortcut(tr("Ctrl+L")); 00082 00083 configSave = new QAction(tr("&Save"), this); 00084 configSave->setShortcut(tr("Ctrl+S")); 00085 00086 QMenu* menu = menuBar()->addMenu("&File"); 00087 menu->addAction(loadAction); 00088 00089 QMenu* menu2 = menuBar()->addMenu("&Config"); 00090 menu2->addAction(configLoad); 00091 menu2->addAction(configSave); 00092 00093 main->setLayout(layout); 00094 setCentralWidget(main); 00095 } 00096 00097 void MainWindow::ConnectSignals() 00098 { 00099 QObject::connect(layerManager,SIGNAL(layerChannelChanged(int,int)), 00100 renderer,SLOT(layerChannelChanged(int,int)),Qt::QueuedConnection); 00101 00102 QObject::connect(layerManager,SIGNAL(layerTypeChanged(int,int)), 00103 renderer,SLOT(layerTypeChanged(int,int)),Qt::QueuedConnection); 00104 00105 QObject::connect(layerManager,SIGNAL(layerTransferImageChanged(const QImage,int)), 00106 renderer,SLOT(layerTransferImageChanged(const QImage,int)),Qt::QueuedConnection); 00107 00108 QObject::connect(layerManager,SIGNAL(layerPosChanged(int,int)), 00109 renderer,SLOT(layerMove(int,int)),Qt::QueuedConnection); 00110 00111 QObject::connect(layerManager,SIGNAL(layerAdded(int)), 00112 renderer,SLOT(layerAdd(int)),Qt::QueuedConnection); 00113 00114 QObject::connect(layerManager,SIGNAL(layerRemoved(int)), 00115 renderer,SLOT(layerRemove(int)),Qt::QueuedConnection); 00116 00117 QObject::connect(settings,SIGNAL(sliderChanged(int,int)), 00118 renderer,SLOT(settingsSliderChanged(int,int)),Qt::QueuedConnection); 00119 QObject::connect(settings,SIGNAL(streamlineModeChanged(int)), 00120 renderer,SLOT(settingsSLModeChanged(int)),Qt::QueuedConnection); 00121 00122 QObject::connect(renderer,SIGNAL(dataLoaded(int)), 00123 layerManager,SLOT(channelCountChanged(int)),Qt::QueuedConnection); 00124 00125 QObject::connect(loadAction,SIGNAL(triggered()),renderer, 00126 SLOT(loadDataFile()), Qt::QueuedConnection); 00127 00128 QObject::connect(configSave,SIGNAL(triggered()),layerManager, 00129 SLOT(saveToFile()), Qt::QueuedConnection); 00130 00131 QObject::connect(configLoad,SIGNAL(triggered()),layerManager, 00132 SLOT(loadFromFile()), Qt::QueuedConnection); 00133 00134 QObject::connect(settings,SIGNAL(streamlineComputeClicked()),renderer,SLOT(settingsSLCompute()), Qt::QueuedConnection); 00135 00136 QObject::connect(settings,SIGNAL(streamlineInterpolationChanged(int)),renderer,SLOT(settingsSLInverpolationChanged(int)), Qt::QueuedConnection); 00137 00138 QObject::connect(settings,SIGNAL(needSliderValue(int)),renderer,SLOT(settingsEmitSliderValue(int)), Qt::QueuedConnection); 00139 00140 QObject::connect(renderer,SIGNAL(emitSettingValues(int,int)),settings,SLOT(updateSlider(int,int)), Qt::QueuedConnection); 00141 }