void YbToolButton::leaveEvent(QEvent *e) { if(m_isCheckable){ if(isEnabled() && !m_isChecked){ setDefaultState(); } }else{ } }
int main(int argc, char *argv[]) { QApplication a(argc, argv); EvalMainWindow *w; DataAccumulator *dac; SoftwareUpdater *updater; int aRet; setOpenMPThreads(); QCoreApplication::setOrganizationName(Globals::ORG_NAME); QCoreApplication::setApplicationName(Globals::SOFTWARE_NAME); QCoreApplication::setApplicationVersion(Globals::VERSION_STRING()); EMT::registerAll(); CrashHandler::install(); DoubleToStringConvertor::initialize(); try { w = new EvalMainWindow(nullptr); dac = new DataAccumulator(w->plot(), nullptr); updater = new SoftwareUpdater(nullptr); } catch (...) { QMessageBox::critical(nullptr, QObject::tr("Initialization"), QObject::tr("Unable to allocate basic data structures")); aRet = EXIT_FAILURE; goto out; } HVLCalculator::initialize(); setupBindings(w, dac); w->show(); dac->announceDefaultState(); loadUserSettings(dac, updater); setDefaultState(w); dac->checkForCrashRecovery(); updater->checkAutomatically(); w->connectToSoftwareUpdater(updater); aRet = a.exec(); saveUserSettings(dac, updater); out: CrashHandler::uninstall(); return aRet; }
HOMERServoController::HOMERServoController(USART_TypeDef *USARTx) : SSC32ServoController(USARTx, numServo) { setDefaultState(); bool set = positionIsSet(); while (!set) { for (uint32_t i = 0; i < 4000000; ++i) asm("nop"); set = positionIsSet(); } }
/*! * Copies reference to given node and tries to load state. * If unsuccesfull, creates default state and saves (translates) it to node. */ void setNode(xmlNodePtr& node_) { node = node_; try { // Try to load state from node. loadStateFromNode(node); } catch (exception& e_) { cout << "Configuration:" << e_.what() << endl; // Set default values and save them to node. setDefaultState(); saveStateToNode(node); }//: catch /// \todo Add synchronization. }
YbToolButton::YbToolButton(QPixmap pixmap, QPixmap checkedPixmap, QString text,QWidget *parent, bool isCheckable) : m_pixmap(pixmap), m_checkedPixmap(checkedPixmap), QWidget(parent), m_isCheckable(isCheckable), m_isChecked(false) { boldFont.setBold(true); m_picLabel = new QLabel; m_textLabel = new QLabel(text); setDefaultState(); setAutoFillBackground(true); setMinimumHeight(40); setMinimumWidth(250); QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->addSpacing(20); mainLayout->addWidget(m_picLabel, 0, Qt::AlignVCenter); mainLayout->addSpacing(15); mainLayout->addWidget(m_textLabel, 0, Qt::AlignVCenter); setLayout(mainLayout); }
bool Device_D3D10::initD3D( void ) { HRESULT hr = S_OK; // `获得窗口大小` RECT rc; GetClientRect( m_hWnd, &rc ); UINT width = rc.right - rc.left; UINT height = rc.bottom - rc.top; UINT createDeviceFlags = 0; #ifdef _DEBUG createDeviceFlags |= D3D10_CREATE_DEVICE_DEBUG; #endif // `设置Frontbuffer/Backbuffer大小及格式` DXGI_SWAP_CHAIN_DESC sd; ZeroMemory( &sd, sizeof(sd) ); sd.BufferCount = 1; sd.BufferDesc.Width = width; sd.BufferDesc.Height = height; sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; sd.BufferDesc.RefreshRate.Numerator = 60; sd.BufferDesc.RefreshRate.Denominator = 1; sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; sd.OutputWindow = m_hWnd; sd.SampleDesc.Count = 1; sd.SampleDesc.Quality = 0; //sd.SwapEffect = DXGI_SWAP_EFFECT_SEQUENTIAL; //sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; sd.Windowed = TRUE; // `打开Frontbuffer/Backbuffer` hr = D3D10CreateDeviceAndSwapChain( NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, D3D10_SDK_VERSION, &sd, &m_pSwapChain, &m_pd3dDevice ); if( FAILED(hr) ) return false; // `取出第一个display buffer` ID3D10Texture2D *pBuffer = NULL; hr = m_pSwapChain->GetBuffer( 0, __uuidof( ID3D10Texture2D ), (LPVOID*)&pBuffer ); if( FAILED(hr) ) return false; // `打开一个合乎display buffer格式的RenderTargetView` hr = m_pd3dDevice->CreateRenderTargetView( pBuffer, NULL, &m_pRenderTargetView ); pBuffer->Release(); if( FAILED( hr ) ) return false; // `设置Depth/Stencil buffer的数据格式` D3D10_TEXTURE2D_DESC descDepth; descDepth.Width = width; descDepth.Height = height; descDepth.MipLevels = 1; descDepth.ArraySize = 1; descDepth.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; descDepth.SampleDesc.Count = 1; descDepth.SampleDesc.Quality = 0; descDepth.Usage = D3D10_USAGE_DEFAULT; descDepth.BindFlags = D3D10_BIND_DEPTH_STENCIL; descDepth.CPUAccessFlags = 0; descDepth.MiscFlags = 0; // `分配Depth/Stencil buffer的空间` hr = m_pd3dDevice->CreateTexture2D( &descDepth, NULL, &m_pDepthStencil ); if( FAILED(hr) ) return false; // `设置Depth/Stencil View的格式` D3D10_DEPTH_STENCIL_VIEW_DESC descDSV; descDSV.Format = descDepth.Format; descDSV.ViewDimension = D3D10_DSV_DIMENSION_TEXTURE2D; descDSV.Texture2D.MipSlice = 0; // `打开DepthStencil Buffer的View` hr = m_pd3dDevice->CreateDepthStencilView( m_pDepthStencil, &descDSV, &m_pDepthStencilView ); if( FAILED(hr) ) return false; setDefaultState(); // `设置绘图的结果会存放在什么地方` // RenderTargetView = RGBA Color Buffer resource // DepthStencilView = Depth/Stencil Buffer resource m_pd3dDevice->OMSetRenderTargets(1, &m_pRenderTargetView, m_pDepthStencilView); setDefaultState(); // `Viewport用来指定3D绘图的画布范围, 在此把Viewport设置成和整个窗口一样大` D3D10_VIEWPORT vp; vp.Width = width; vp.Height = height; vp.MinDepth = 0.0f; vp.MaxDepth = 1.0f; vp.TopLeftX = 0; vp.TopLeftY = 0; m_pd3dDevice->RSSetViewports( 1, &vp ); return true; }
MainWindow::MainWindow() : QMainWindow(), actionNextDive(0), actionPreviousDive(0), helpView(0), state(VIEWALL), survey(0) { Q_ASSERT_X(m_Instance == NULL, "MainWindow", "MainWindow recreated!"); m_Instance = this; ui.setupUi(this); read_hashes(); // Define the States of the Application Here, Currently the states are situations where the different // widgets will change on the mainwindow. // for the "default" mode MainTab *mainTab = new MainTab(); DiveListView *diveListView = new DiveListView(); ProfileWidget2 *profileWidget = new ProfileWidget2(); #ifndef NO_MARBLE GlobeGPS *globeGps = new GlobeGPS(); #else QWidget *globeGps = NULL; #endif PlannerSettingsWidget *plannerSettings = new PlannerSettingsWidget(); DivePlannerWidget *plannerWidget = new DivePlannerWidget(); PlannerDetails *plannerDetails = new PlannerDetails(); LocationInformationWidget *locationInformation = new LocationInformationWidget(); // what is a sane order for those icons? we should have the ones the user is // most likely to want towards the top so they are always visible // and the ones that someone likely sets and then never touches again towards the bottom profileToolbarActions << ui.profCalcCeiling << ui.profCalcAllTissues << // start with various ceilings ui.profIncrement3m << ui.profDcCeiling << ui.profPhe << ui.profPn2 << ui.profPO2 << // partial pressure graphs ui.profRuler << ui.profScaled << // measuring and scaling ui.profTogglePicture << ui.profTankbar << ui.profMod << ui.profNdl_tts << // various values that a user is either interested in or not ui.profEad << ui.profSAC << ui.profHR << // very few dive computers support this ui.profTissues; // maybe less frequently used QToolBar *toolBar = new QToolBar(); Q_FOREACH (QAction *a, profileToolbarActions) toolBar->addAction(a); toolBar->setOrientation(Qt::Vertical); toolBar->setIconSize(QSize(24,24)); QWidget *profileContainer = new QWidget(); QHBoxLayout *profLayout = new QHBoxLayout(); profLayout->setSpacing(0); profLayout->setMargin(0); profLayout->setContentsMargins(0,0,0,0); profLayout->addWidget(toolBar); profLayout->addWidget(profileWidget); profileContainer->setLayout(profLayout); registerApplicationState("Default", mainTab, profileContainer, diveListView, globeGps ); registerApplicationState("AddDive", mainTab, profileContainer, diveListView, globeGps ); registerApplicationState("EditDive", mainTab, profileContainer, diveListView, globeGps ); registerApplicationState("PlanDive", plannerWidget, profileContainer, plannerSettings, plannerDetails ); registerApplicationState("EditPlannedDive", plannerWidget, profileContainer, diveListView, globeGps ); registerApplicationState("EditDiveSite",locationInformation, profileContainer, diveListView, globeGps ); setApplicationState("Default"); ui.multiFilter->hide(); setWindowIcon(QIcon(":subsurface-icon")); if (!QIcon::hasThemeIcon("window-close")) { QIcon::setThemeName("subsurface"); } connect(dive_list(), SIGNAL(currentDiveChanged(int)), this, SLOT(current_dive_changed(int))); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(readSettings())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), diveListView, SLOT(update())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), diveListView, SLOT(reloadHeaderActions())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), information(), SLOT(updateDiveInfo())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), divePlannerWidget(), SLOT(settingsChanged())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), divePlannerSettingsWidget(), SLOT(settingsChanged())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), TankInfoModel::instance(), SLOT(update())); connect(ui.actionRecent1, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool))); connect(ui.actionRecent2, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool))); connect(ui.actionRecent3, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool))); connect(ui.actionRecent4, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool))); connect(information(), SIGNAL(addDiveFinished()), graphics(), SLOT(setProfileState())); connect(DivePlannerPointsModel::instance(), SIGNAL(planCreated()), this, SLOT(planCreated())); connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled())); connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan())); connect(mainTab, SIGNAL(requestDiveSiteEdit(uint32_t)), this, SLOT(enableDiveSiteEdit(uint32_t))); connect(locationInformation, SIGNAL(informationManagementEnded()), this, SLOT(setDefaultState())); connect(locationInformation, SIGNAL(informationManagementEnded()), information(), SLOT(showLocation())); connect(locationInformation, SIGNAL(coordinatesChanged()), globe(), SLOT(repopulateLabels())); #ifdef NO_PRINTING plannerDetails->printPlan()->hide(); ui.menuFile->removeAction(ui.actionPrint); #endif #ifndef USE_LIBGIT23_API ui.menuFile->removeAction(ui.actionCloudstorageopen); ui.menuFile->removeAction(ui.actionCloudstoragesave); qDebug() << "disabled / made invisible the cloud storage stuff"; #endif ui.mainErrorMessage->hide(); graphics()->setEmptyState(); initialUiSetup(); readSettings(); diveListView->reload(DiveTripModel::TREE); diveListView->reloadHeaderActions(); diveListView->setFocus(); globe()->reload(); diveListView->expand(dive_list()->model()->index(0, 0)); diveListView->scrollTo(dive_list()->model()->index(0, 0), QAbstractItemView::PositionAtCenter); divePlannerWidget()->settingsChanged(); divePlannerSettingsWidget()->settingsChanged(); #ifdef NO_MARBLE ui.menuView->removeAction(ui.actionViewGlobe); #else connect(globe(), SIGNAL(coordinatesChanged()), locationInformation, SLOT(updateGpsCoordinates())); #endif #ifdef NO_USERMANUAL ui.menuHelp->removeAction(ui.actionUserManual); #endif memset(©PasteDive, 0, sizeof(copyPasteDive)); memset(&what, 0, sizeof(what)); updateManager = new UpdateManager(this); undoStack = new QUndoStack(this); QAction *undoAction = undoStack->createUndoAction(this, tr("&Undo")); QAction *redoAction = undoStack->createRedoAction(this, tr("&Redo")); undoAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Z)); redoAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z)); QList<QAction*>undoRedoActions; undoRedoActions.append(undoAction); undoRedoActions.append(redoAction); ui.menu_Edit->addActions(undoRedoActions); ReverseGeoLookupThread *geoLookup = ReverseGeoLookupThread::instance(); connect(geoLookup, SIGNAL(started()),information(), SLOT(disableGeoLookupEdition())); connect(geoLookup, SIGNAL(finished()), information(), SLOT(enableGeoLookupEdition())); }
Sign::Sign() : QVector<int>() { setDefaultState(); }