void PixelWidget::keyPressEvent(QKeyEvent *e) { switch (e->key()) { case Qt::Key_Plus: increaseZoom(); break; case Qt::Key_Minus: decreaseZoom(); break; case Qt::Key_PageUp: setGridSize(m_gridSize + 1); break; case Qt::Key_PageDown: setGridSize(m_gridSize - 1); break; case Qt::Key_G: toggleGrid(); break; case Qt::Key_C: if (e->modifiers() & Qt::ControlModifier) copyToClipboard(); break; case Qt::Key_S: if (e->modifiers() & Qt::ControlModifier) { releaseKeyboard(); saveToFile(); } break; case Qt::Key_Control: grabKeyboard(); break; } }
void MonitorProperties::setPointOfView(MonitorProperties::PointOfView pov) { if (pov == m_pointOfView) return; if (m_pointOfView == Undefined) { QVector3D gSize = gridSize(); float units = gridUnits() == MonitorProperties::Meters ? 1000.0 : 304.8; if (gSize.z() == 0) { // convert the grid size first switch (pov) { case TopView: setGridSize(QVector3D(gSize.x(), GRID_DEFAULT_HEIGHT, gSize.y())); break; case RightSideView: case LeftSideView: setGridSize(QVector3D(GRID_DEFAULT_WIDTH, gSize.x(), gSize.x())); break; default: break; } } foreach (quint32 fid, fixtureItemsID()) { QVector3D pos = fixturePosition(fid); QVector3D newPos; switch (pov) { case TopView: { newPos = QVector3D(pos.x(), 1000, pos.y()); } break; case RightSideView: { newPos = QVector3D(0, pos.y(), (gridSize().z() * units) - pos.x()); } break; case LeftSideView: { newPos = QVector3D(0, pos.y(), pos.x()); } break; default: newPos = QVector3D(pos.x(), (gridSize().y() * units) - pos.y(), 1000); break; } setFixturePosition(fid, newPos); }
void Sheet::setPuzzle(const Puzzle &puzzle) { setUpdatesEnabled(false); int W = puzzle.grid.width, H = puzzle.grid.height; QSize new_size(W, H); if(grid_size != new_size) setGridSize(QSize(W, H)); for(int n = 0; n < W*H; ++n) { int v = puzzle.grid.vars[n]; if(v >= 0) { cellAt(n).setOpen(true); cellAt(n).setCands(puzzle.state.cand[v]); cellAt(n - W).setVsum(puzzle.state.sum[puzzle.state.vgrp[v]]); cellAt(n - 1).setHsum(puzzle.state.sum[puzzle.state.hgrp[v]]); } else { cellAt(n).setOpen(false); cellAt(n).setHsum(0); cellAt(n).setVsum(0); } } setUpdatesEnabled(true); }
int NgonGridData::setDataProperty(int property, void const* value, int numElements) { if (property == GRID_SIZE) { return setGridSize((int const*) value); } else if (property == X_COORDINATES) { setDataX((double const*) value, numElements); } else if (property == Y_COORDINATES) { setDataY((double const*) value, numElements); } else if (property == Z_COORDINATES) { setDataZ((double const*) value, numElements); } else if (property == Z_COORDINATES_SHIFT) { setZCoordinatesShift((double const*) value); } else { return NgonData::setDataProperty(property, value, numElements); } return 1; }
//------------------------------------------------------------------------------ // setMap() - sets our parent map. //------------------------------------------------------------------------------ void MapDrawer::setMap(CadrgMap* map) { bool done = false; if (myMap != 0 && myMap != map) { for (int i = 0; i < MAX_PAGERS; i++) { if (pagers[i] != 0) pagers[i]->flushTextures(); myMap->unref(); } myMap = map; myMap->ref(); done = true; } else if (myMap == 0 && map != 0) { myMap = map; myMap->ref(); done = true; } if (done) { setGridSize(myMap->getMaxTableSize()); for (int i = 0; i < MAX_PAGERS; i++) { if (pagers[i] != 0) pagers[i]->setMap(myMap); } } }
void MyFracWindow::readParameters() { KConfig* config = kapp->config(); config->setGroup("Parameters"); _sliderIterations->setValue(config->readNumEntry("Iterations", 2)); _sliderQuality->setValue(config->readNumEntry("Quality", 5)); _sliderScale->setValue(config->readNumEntry("Scale", 15)); _sliderOffset->setValue(config->readNumEntry("Offset", 0)); _sliderScroll->setValue(config->readNumEntry("Scroll", 25)); _sliderHeight->setValue(config->readNumEntry("Height", 20)); _comboGrid->setCurrentItem(config->readNumEntry("Grid", 1)); setGridSize(_comboGrid->currentItem()); QColor black(0, 0, 0); _colorButton->setColor(config->readColorEntry("Background", &black)); QStringList list = config->readListEntry("Gradient"); if (list.size() == 4) { Gradient gradient(list[0] == "hsv"); gradient.getSpline(0).fromString(list[1]); gradient.getSpline(1).fromString(list[2]); gradient.getSpline(2).fromString(list[3]); setGradient(gradient); } else setGradient(_presets.getDefault()); QSize defSize(800, 600); _imageSize = config->readSizeEntry("ImageSize", &defSize); _imageMime = config->readEntry("ImageMime", "image/png"); _imagePath = config->readEntry("ImagePath"); }
int ready_Output_Device(int frame) { int size; if (force_cellsz) { grid_sz = (int)(view_size / cell_sz); V_MAX(grid_sz, 1); /* must be non-zero */ setGridSize(grid_sz); prnt_Status(); } /* Calculate size of frame buffer image (pixels across square image). */ if (movie.m_noframes > 1 && ! movie.m_fullscreen) /* Fit frames of movie. */ size = MovieSize(grid_sz, movie.m_noframes); else if (force_fbsz && ! DiskFile(fb_file)) size = fb_size; /* user-specified size */ else size = grid_sz; /* just 1 pixel/ray */ if (movie.m_noframes > 1 && movie.m_fullscreen) { char framefile[MAX_LN]; /* We must be doing full-screen frames. */ size = grid_sz; (void) snprintf(framefile, MAX_LN, "%s.%04d", prefix, frame); if (! fb_Setup(framefile, size)) return 0; } else { if (frame == movie.m_curframe && ! fb_Setup(fb_file, size)) return 0; fb_Zoom_Window(); } return 1; }
bool MainView2D::initialize2DProperties() { setGridSize(m_monProps->gridSize()); m_gridItem = qobject_cast<QQuickItem*>(contextItem()->findChild<QObject *>("twoDContents")); if (m_gridItem == NULL) { qDebug() << "ERROR: got invalid twoDContents" << m_gridItem; return false; } return true; }
ThumbnailView::ThumbnailView(QWidget* parent):QListView(parent) { setViewMode(QListView::IconMode); setFlow(QListView::LeftToRight); model = new QStandardItemModel(4,1); setModel(model); setIconSize(QSize(300,200)); resize(1250,500); setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); initialize(); setGridSize(QSize(width()/4,250)); }
MainView2D::MainView2D(QQuickView *view, Doc *doc, QObject *parent) : PreviewContext(view, doc, "2D", parent) , m_gridItem(NULL) , m_monProps(doc->monitorProperties()) { setGridSize(m_monProps->gridSize()); setGridScale(1.0); setCellPixels(100); setContextResource("qrc:/2DView.qml"); setContextTitle(tr("2D View")); fixtureComponent = new QQmlComponent(m_view->engine(), QUrl("qrc:/Fixture2DItem.qml")); if (fixtureComponent->isError()) qDebug() << fixtureComponent->errors(); }
void ObjectsScene::setGridOptions(bool show_grd, bool align_objs_grd, bool show_pag_dlm) { bool redef_grid=(ObjectsScene::show_grid!=show_grd || ObjectsScene::show_page_delim!=show_pag_dlm || grid.style()==Qt::NoBrush); ObjectsScene::show_grid=show_grd; ObjectsScene::show_page_delim=show_pag_dlm; ObjectsScene::align_objs_grid=align_objs_grd; if(redef_grid) { grid.setStyle(Qt::NoBrush); setGridSize(ObjectsScene::grid_size); } }
IconView::IconView( QWidget* parent ) : QListView(parent),m_pixmap(0),m_actionCollection(this) { setViewMode( QListView::IconMode ); setFlow( QListView::TopToBottom ); setSelectionRectVisible( true ); setGridSize( QSize( 64, 64 ) ); setSpacing( 2 ); setUniformItemSizes( true ); setEditTriggers( QAbstractItemView::EditKeyPressed ); setSelectionMode( QAbstractItemView::ExtendedSelection ); setFrameShape( QFrame::NoFrame ); setAutoFillBackground( true ); // setAttribute(Qt::WA_PaintOutsidePaintEvent); // setStyleSheet( "background-color: transparent" ); setObjectName( "iconview" ); /// lazy initialization QTimer::singleShot( 0, this, SLOT(init()) ); }
void WaterPlane::unpackUpdate(NetConnection* con, BitStream* stream) { Parent::unpackUpdate(con, stream); U32 inGridSize; stream->read( &inGridSize ); setGridSize( inGridSize ); F32 inGridElementSize; stream->read( &inGridElementSize ); setGridElementSize( inGridElementSize ); if( stream->readFlag() ) // UpdateMask { float posZ; stream->read( &posZ ); Point3F newPos = getPosition(); newPos.z = posZ; setPosition( newPos ); } }
int NgonGridMatplotData::setDataProperty(int property, void const* value, int numElements) { if (property == GRID_SIZE) { return setGridSize((int const*) value); } else if (property == MATPLOT_BOUNDS) { setBounds((double const*) value); } else if (property == Z_COORDINATES) { setDataZ((double const*) value, numElements); } else { return NgonGridData::setDataProperty(property, value, numElements); } return 1; }
// ---------------- ActionListView: ActionListView::ActionListView(ActionModel *model, QWidget *parent) : QListView(parent), m_model(model) { setDragEnabled(true); setAcceptDrops(true); setDropIndicatorShown(true); setDragDropMode(DragDrop); setModel(model); setTextElideMode(Qt::ElideMiddle); connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(slotActivated(QModelIndex))); // We actually want 'Static' as the user should be able to // drag away actions only (not to rearrange icons). // We emulate that by not accepting our own // drag data. 'Static' causes the list view to disable drag and drop // on the viewport. setMovement(Snap); setViewMode(IconMode); setIconSize(QSize(iconModeIconSize, iconModeIconSize)); setGridSize(QSize(4 * iconModeIconSize, 2 * iconModeIconSize)); setSpacing(iconModeIconSize / 3); }
DIALOG_SET_GRID::DIALOG_SET_GRID( wxFrame* aCaller, EDA_UNITS_T* aGridUnits, EDA_UNITS_T aBoardUnits, wxRealPoint* aUserSize, wxPoint* aOrigin, int* aFastGrid1, int* aFastGrid2, const wxArrayString& aGridChoices ): DIALOG_SET_GRID_BASE( aCaller ), m_callers_grid_units( *aGridUnits ), m_callers_board_units( aBoardUnits ), m_callers_user_size( *aUserSize ), m_callers_origin( *aOrigin ), m_callers_fast_grid1( *aFastGrid1 ), m_callers_fast_grid2( *aFastGrid2 ) { m_TextPosXUnits->SetLabel( GetUnitsLabel( m_callers_board_units ) ); m_TextPosYUnits->SetLabel( GetUnitsLabel( m_callers_board_units ) ); m_sdbSizer1OK->SetDefault(); // set OK button as default response to 'Enter' key setGridUnits( m_callers_grid_units ); setGridSize( m_callers_user_size ); setGridOrigin( m_callers_origin ); setGridForFastSwitching( aGridChoices, m_callers_fast_grid1, m_callers_fast_grid2 ); GetSizer()->SetSizeHints( this ); Fit(); Centre(); }
void MainView2D::setPointOfView(int pointOfView) { qDebug() << "Point of view:" << pointOfView; if (pointOfView == m_monProps->pointOfView()) return; m_monProps->setPointOfView(MonitorProperties::PointOfView(pointOfView)); emit pointOfViewChanged(pointOfView); setGridSize(m_monProps->gridSize()); for (Fixture *fixture : m_doc->fixtures()) { for (quint32 subID : m_monProps->fixtureIDList(fixture->id())) { quint16 headIndex = m_monProps->fixtureHeadIndex(subID); quint16 linkedIndex = m_monProps->fixtureLinkedIndex(subID); quint32 itemID = FixtureUtils::fixtureItemID(fixture->id(), headIndex, linkedIndex); updateFixturePosition(itemID, m_monProps->fixturePosition(fixture->id(), headIndex, linkedIndex)); } } }
void MaterialView::resizeEvent(QResizeEvent *e) { QListView::resizeEvent(e); setGridSize(QSize()); }
void ZBlockGrid::setGridSize(const ZIntPoint &s) { setGridSize(s.getX(), s.getY(), s.getZ()); }
bool RemapRawSlabs::setFile(QList<QString> fl) { m_fileName = fl; { m_slices.clear(); QFileInfo fi(fl[0]); QString hdrflnm; hdrflnm = QFileDialog::getOpenFileName(0, "Load text header file", fi.absolutePath(), "Files (*.*)"); int nfX0, nfY0, nfZ0; if (hdrflnm.isEmpty()) { uchar nvt0; QFile fd(m_fileName[0]); fd.open(QFile::ReadOnly); fd.read((char*)&nvt0, sizeof(unsigned char)); fd.read((char*)&nfX0, sizeof(int)); fd.read((char*)&nfY0, sizeof(int)); fd.read((char*)&nfZ0, sizeof(int)); fd.close(); m_voxelType = _UChar; if (nvt0 == 0) m_voxelType = _UChar; if (nvt0 == 1) m_voxelType = _Char; if (nvt0 == 2) m_voxelType = _UShort; if (nvt0 == 3) m_voxelType = _Short; if (nvt0 == 4) m_voxelType = _Int; if (nvt0 == 8) m_voxelType = _Float; m_headerBytes = m_skipBytes = 13; int nslices = nfX0; m_slices.append(nslices); for (int nf=1; nf<m_fileName.count(); nf++) { uchar nvt; int nfX, nfY, nfZ; QFile fd(m_fileName[nf]); fd.open(QFile::ReadOnly); fd.read((char*)&nvt, sizeof(unsigned char)); fd.read((char*)&nfX, sizeof(int)); fd.read((char*)&nfY, sizeof(int)); fd.read((char*)&nfZ, sizeof(int)); fd.close(); if (nvt != nvt0 || nfY != nfY0 || nfZ != nfZ0) { QMessageBox::information(0, "", "Raw File format does not match"); return false; } nslices += nfX; m_slices.append(nslices); } } else { // load header information from a text file int nvt0, nvt; int nfX, nfY, nfZ; QFile fd(hdrflnm); fd.open(QFile::ReadOnly | QFile::Text); QTextStream in(&fd); QString line = (in.readLine()).simplified(); QStringList words = line.split(" ", QString::SkipEmptyParts); if (words.count() >= 2) { int nvt0 = words[0].toInt(); m_voxelType = _UChar; if (nvt0 == 0) m_voxelType = _UChar; if (nvt0 == 1) m_voxelType = _Char; if (nvt0 == 2) m_voxelType = _UShort; if (nvt0 == 3) m_voxelType = _Short; if (nvt0 == 4) m_voxelType = _Int; if (nvt0 == 8) m_voxelType = _Float; m_headerBytes = m_skipBytes = words[1].toInt(); } else { QMessageBox::information(0, "", QString("Expecting voxeltype and headerbytes\nGot this %1").arg(line)); return false; } int nslices = 0; while (!in.atEnd()) { line = (in.readLine()).simplified(); words = line.split(" ", QString::SkipEmptyParts); if (words.count() >= 3) { nfX = words[0].toInt(); nfY = words[1].toInt(); nfZ = words[2].toInt(); if (nslices == 0) { nfY0 = nfY; nfZ0 = nfZ; } else { if (nfY0 != nfY || nfZ0 != nfZ) { QMessageBox::information(0, "", QString("Slice size not same :: %1 %2 : %3 %4").\ arg(nfY0).arg(nfZ0).arg(nfY).arg(nfZ)); return false; } } nslices += nfX; m_slices.append(nslices); } else { QMessageBox::information(0, "", QString("Expecting dimensions\nGot this %1").arg(line)); return false; } } } setGridSize(m_slices[m_slices.count()-1], nfY0, nfZ0); } //------------------------------ m_bytesPerVoxel = 1; if (m_voxelType == _UChar) m_bytesPerVoxel = 1; else if (m_voxelType == _Char) m_bytesPerVoxel = 1; else if (m_voxelType == _UShort) m_bytesPerVoxel = 2; else if (m_voxelType == _Short) m_bytesPerVoxel = 2; else if (m_voxelType == _Int) m_bytesPerVoxel = 4; else if (m_voxelType == _Float) m_bytesPerVoxel = 4; if (m_voxelType == _UChar || m_voxelType == _Char || m_voxelType == _UShort || m_voxelType == _Short) { findMinMaxandGenerateHistogram(); } else { findMinMax(); generateHistogram(); } m_rawMap.append(m_rawMin); m_rawMap.append(m_rawMax); m_pvlMap.append(0); m_pvlMap.append(255); return true; }
int main() { //prototypes for main void printTitle(), setGridSize(), clearGrid(int grid[column_size][row_size]), playerTurn(int player, int grid[column_size][row_size]); int checkWinner(int grid[column_size][row_size]), continueGame(); //variable initilisation. int player, winner; printTitle(); do { //construction of new game player = 1; //resets player winner = 0; // resets winner setGridSize(); int grid[column_size][row_size]; // constructs grid clearGrid(grid); // sets all grid values to 0 clearScreen(); //game plays out inside until winner or draw. while(winner == 0) { playerTurn(player, grid); winner = checkWinner(grid); if(winner == 0) { //switches player if(player == 1) { player = 2; } else { player = 1; } } else { //clears screen and prints grid between turns. clearScreen(); printGrid(grid); spacer(); //spacer called repeatedly to move print to center of console printf("\n\n"); spacer(); if(winner != 3) //checks if winner was a player or a draw. A winner of '3' is a draw { printf("Winner is Player %d!!!", winner); } else { printf("Draw!!!"); } } } //starts a new game if true }while(continueGame()); return(0); }
/************************************************ * Widget Listing: * Creation of the list of drawed lovely buttons ************************************************/ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent ) : QListWidget( _parent ) { /* We need the parent to know the options checked */ parent = qobject_cast<ToolbarEditDialog *>(_parent); assert( parent ); /* Normal options */ setViewMode( QListView::IconMode ); setSpacing( 8 ); setGridSize( QSize(90, 50) ); setWrapping( true ); setWordWrap( true ); setTextElideMode( Qt::ElideNone ); setDragEnabled( true ); /* All the buttons do not need a special rendering */ for( int i = 0; i < BUTTON_MAX; i++ ) { QListWidgetItem *widgetItem = new QListWidgetItem( this ); widgetItem->setText( qtr( nameL[i] ) ); QPixmap pix( iconL[i] ); widgetItem->setIcon( pix.scaled( 16, 16, Qt::KeepAspectRatio, Qt::SmoothTransformation ) ); widgetItem->setData( Qt::UserRole, QVariant( i ) ); addItem( widgetItem ); } /* Spacers are yet again a different thing */ QListWidgetItem *widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space" ), qtr( "Spacer" ), this ); widgetItem->setData( Qt::UserRole, WIDGET_SPACER ); addItem( widgetItem ); widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space" ), qtr( "Expanding Spacer" ), this ); widgetItem->setData( Qt::UserRole, WIDGET_SPACER_EXTEND ); addItem( widgetItem ); /** * For all other widgets, we create then, do a pseudo rendering in * a pixmaps for the view, and delete the object * * A lot of code is retaken from the Abstract, but not exactly... * So, rewrite. * They are better ways to deal with this, but I doubt that this is * necessary. If you feel like you have the time, be my guest. * -- * jb **/ for( int i = SPLITTER; i < SPECIAL_MAX; i++ ) { QWidget *widget = NULL; QListWidgetItem *widgetItem = new QListWidgetItem( this ); switch( i ) { case SPLITTER: { QFrame *line = new QFrame( this ); line->setFrameShape( QFrame::VLine ); line->setFrameShadow( QFrame::Raised ); line->setLineWidth( 0 ); line->setMidLineWidth( 1 ); widget = line; } widgetItem->setText( qtr("Splitter") ); break; case INPUT_SLIDER: { SeekSlider *slider = new SeekSlider( Qt::Horizontal, this ); widget = slider; } widgetItem->setText( qtr("Time Slider") ); break; case VOLUME: { SoundWidget *snd = new SoundWidget( this, p_intf, parent->getOptions() & WIDGET_SHINY ); widget = snd; } widgetItem->setText( qtr("Volume") ); break; case VOLUME_SPECIAL: { QListWidgetItem *widgetItem = new QListWidgetItem( this ); widgetItem->setText( qtr("Small Volume") ); widgetItem->setIcon( QIcon( ":/toolbar/volume-medium" ) ); widgetItem->setData( Qt::UserRole, QVariant( i ) ); addItem( widgetItem ); } continue; case TIME_LABEL: { QLabel *timeLabel = new QLabel( "12:42/2:12:42", this ); widget = timeLabel; } widgetItem->setText( qtr("Time") ); break; case MENU_BUTTONS: { QWidget *discFrame = new QWidget( this ); //discFrame->setLineWidth( 1 ); QHBoxLayout *discLayout = new QHBoxLayout( discFrame ); discLayout->setSpacing( 0 ); discLayout->setMargin( 0 ); QToolButton *prevSectionButton = new QToolButton( discFrame ); prevSectionButton->setIcon( QIcon( ":/toolbar/dvd_prev" ) ); prevSectionButton->setToolTip( qtr("Previous chapter") ); discLayout->addWidget( prevSectionButton ); QToolButton *menuButton = new QToolButton( discFrame ); menuButton->setIcon( QIcon( ":/toolbar/dvd_menu" ) ); menuButton->setToolTip( qtr("Go to the DVD menu") ); discLayout->addWidget( menuButton ); QToolButton *nextButton = new QToolButton( discFrame ); nextButton->setIcon( QIcon( ":/toolbar/dvd_next" ) ); nextButton->setToolTip( qtr("Next chapter") ); discLayout->addWidget( nextButton ); widget = discFrame; } widgetItem->setText( qtr("DVD menus") ); break; case TELETEXT_BUTTONS: { QWidget *telexFrame = new QWidget( this ); QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame ); telexLayout->setSpacing( 0 ); telexLayout->setMargin( 0 ); QToolButton *telexOn = new QToolButton( telexFrame ); telexOn->setIcon( QIcon( ":/toolbar/tv" ) ); telexLayout->addWidget( telexOn ); QToolButton *telexTransparent = new QToolButton; telexTransparent->setIcon( QIcon( ":/toolbar/tvtelx" ) ); telexTransparent->setToolTip( qtr("Teletext transparency") ); telexLayout->addWidget( telexTransparent ); QSpinBox *telexPage = new QSpinBox; telexLayout->addWidget( telexPage ); widget = telexFrame; } widgetItem->setText( qtr("Teletext") ); break; case ADVANCED_CONTROLLER: { AdvControlsWidget *advControls = new AdvControlsWidget( p_intf, this ); widget = advControls; } widgetItem->setText( qtr("Advanced Buttons") ); break; case PLAYBACK_BUTTONS: { widget = new QWidget; DeckButtonsLayout *layout = new DeckButtonsLayout( widget ); BrowseButton *prev = new BrowseButton( widget, BrowseButton::Backward ); BrowseButton *next = new BrowseButton( widget ); RoundButton *play = new RoundButton( widget ); layout->setBackwardButton( prev ); layout->setForwardButton( next ); layout->setRoundButton( play ); } widgetItem->setText( qtr("Playback Buttons") ); break; case ASPECT_RATIO_COMBOBOX: widget = new AspectRatioComboBox( p_intf ); widgetItem->setText( qtr("Aspect ratio") ); break; case SPEED_LABEL: widget = new SpeedLabel( p_intf, this ); widgetItem->setText( qtr("Playback speed") ); break; case TIME_LABEL_ELAPSED: widget = new QLabel( "2:42", this ); widgetItem->setText( qtr("Elapsed time") ); break; case TIME_LABEL_REMAINING: widget = new QLabel( "-2:42", this ); widgetItem->setText( qtr("Total/Remaining time") ); break; default: msg_Warn( p_intf, "This should not happen %i", i ); break; } if( widget == NULL ) continue; widgetItem->setIcon( QIcon( QPixmap::grabWidget( widget ) ) ); widget->hide(); widgetItem->setData( Qt::UserRole, QVariant( i ) ); addItem( widgetItem ); delete widget; } }
void Settings::setGridSize(qreal uniformSize) { setGridSize(QSizeF(uniformSize, uniformSize)); }
WidgetArea::WidgetArea(QWidget *parent) : QFrame(parent), m_menu(new QMenu(this)), m_undoStack(this) { m_widgetIdCounter = 0; m_skipNextMove = false; m_prev = NULL; m_show_grid = sConfig.get(CFG_BOOL_ANALYZER_SHOW_GRID); m_grid = sConfig.get(CFG_BOOL_ANALYZER_ENABLE_GRID) ? sConfig.get(CFG_QUINT32_ANALYZER_GRID_SIZE) : 1; m_enablePlacementLines = sConfig.get(CFG_BOOL_ANALYZER_PLACEMENT_LINES); m_active_bookmk = NULL; m_bookmk_ids = 0; m_show_bookmk = sConfig.get(CFG_BOOL_ANALYZER_SHOW_BOOKMARKS); m_draggin = false; setCursor(Qt::OpenHandCursor); QAction *addPoint = m_menu->addAction(tr("Add bookmark...")); m_actShowBookmk = m_menu->addAction(tr("Show bookmarks")); m_actShowBookmk->setCheckable(true); m_actShowBookmk->setChecked(m_show_bookmk); m_menu->addSeparator(); QMenu *gridMenu = m_menu->addMenu(tr("Grid")); m_actEnableGrid = gridMenu->addAction(tr("Enable grid")); m_actShowGrid = gridMenu->addAction(tr("Show grid")); QAction *gridSize = gridMenu->addAction(tr("Set grid size...")); QAction *align = gridMenu->addAction(tr("Align widgets to the grid")); m_actEnableGrid->setCheckable(true); m_actEnableGrid->setChecked(m_grid != 1); m_actShowGrid->setCheckable(true); m_actShowGrid->setChecked(m_show_grid); QAction *linesAct = m_menu->addAction(tr("Enable placement lines")); linesAct->setCheckable(true); linesAct->setChecked(m_enablePlacementLines); m_menu->addSeparator(); m_actTitleVisibility = m_menu->addAction(tr("Show widget's title bar")); QAction *lockAll = m_menu->addAction(tr("Lock all widgets")); QAction *unlockAll = m_menu->addAction(tr("Unlock all widgets")); m_actShowPreview = m_menu->addAction(tr("Show preview while moving the area")); m_actEnableSearch = m_menu->addAction(tr("Enable quick search (spacebar)")); m_actTitleVisibility->setCheckable(true); m_actTitleVisibility->setChecked(true); m_actShowPreview->setCheckable(true); m_actShowPreview->setChecked(sConfig.get(CFG_BOOL_ANALYZER_SHOW_PREVIEW)); m_actEnableSearch->setCheckable(true); m_actEnableSearch->setChecked(sConfig.get(CFG_BOOL_ANALYZER_SEARCH_WIDGET)); m_menu->addSeparator(); QAction *undo = m_menu->addAction(tr("Undo"), &m_undoStack, SLOT(undo()), QKeySequence("Ctrl+Z")); QAction *redo = m_menu->addAction(tr("Redo"), &m_undoStack, SLOT(redo()), QKeySequence("Shift+Ctrl+Z")); undo->setEnabled(false); redo->setEnabled(false); addAction(undo); addAction(redo); m_bookmk_menu = new QMenu(this); QAction *keyseqAct = m_bookmk_menu->addAction(tr("Change shortcut")); QAction *rmPntAct = m_bookmk_menu->addAction(tr("Remove")); connect(m_actEnableGrid, SIGNAL(toggled(bool)), SLOT(enableGrid(bool))); connect(m_actEnableGrid, SIGNAL(toggled(bool)), m_actShowGrid, SLOT(setEnabled(bool))); connect(m_actEnableGrid, SIGNAL(toggled(bool)), gridSize, SLOT(setEnabled(bool))); connect(m_actShowGrid, SIGNAL(toggled(bool)), SLOT(showGrid(bool))); connect(m_actEnableSearch, SIGNAL(triggered(bool)), SLOT(enableSearchClicked(bool))); connect(m_actEnableSearch, SIGNAL(toggled(bool)), SLOT(enableSearchToggled(bool))); connect(gridSize, SIGNAL(triggered()), SLOT(setGridSize())); connect(align, SIGNAL(triggered()), SLOT(alignWidgets())); connect(linesAct, SIGNAL(toggled(bool)), SLOT(enableLines(bool))); connect(m_actTitleVisibility, SIGNAL(triggered(bool)), SLOT(titleVisibilityAct(bool))); connect(m_actShowPreview, SIGNAL(toggled(bool)), SLOT(setShowPreview(bool))); connect(lockAll, SIGNAL(triggered()), SLOT(lockAll())); connect(unlockAll, SIGNAL(triggered()), SLOT(unlockAll())); connect(&m_undoStack, SIGNAL(undoAvailable(bool)), undo, SLOT(setEnabled(bool))); connect(&m_undoStack, SIGNAL(redoAvailable(bool)), redo, SLOT(setEnabled(bool))); connect(&m_bookmk_mapper, SIGNAL(mapped(int)), SLOT(jumpToBookmark(int))); connect(keyseqAct, SIGNAL(triggered()), SLOT(changeBookmarkSeq())); connect(rmPntAct, SIGNAL(triggered()), SLOT(removeBookmark())); connect(addPoint, SIGNAL(triggered()), SLOT(addBookmark())); connect(m_actShowBookmk, SIGNAL(toggled(bool)), SLOT(setShowBookmarks(bool))); }
void Settings::setGridSize(int uniformSize) { setGridSize((qreal)uniformSize); }
/* * ResizeChild - resize the draw area of the child window */ void ResizeChild( WPI_PARAM2 lparam, HWND hwnd, BOOL firsttime ) { short min_width; short width; short height; img_node *node; short x_adjustment; short y_adjustment; short new_width; short new_height; WPI_POINT point_size; WPI_POINT max; HWND frame; HMENU hmenu; WPI_RECT rc; WPI_RECT rect; frame = _wpi_getframe( hwnd ); width = LOWORD( lparam ); #ifdef __OS2_PM__ height = SHORT2FROMMP( lparam ); #else height = HIWORD( lparam ); #endif GetClientRect( hwnd, &rc ); GetWindowRect( hwnd, &rect ); if( frame != NULL ) { GetClientRect( frame, &rc ); GetWindowRect( frame, &rect ); } max.x = _wpi_getsystemmetrics( SM_CXSCREEN ); max.y = _wpi_getsystemmetrics( SM_CYSCREEN ); x_adjustment = _wpi_getwidthrect( rect ) - _wpi_getwidthrect( rc ); y_adjustment = _wpi_getheightrect( rect ) - _wpi_getheightrect( rc ); #if 1 min_width = MIN_DRAW_WIN_WIDTH; #else // fudge factor to allow some of title bar to show min_width = (short)(2 * _wpi_getsystemmetrics( SM_CXSIZE )) + x_adjustment + 8; #endif #ifdef __OS2_PM__ y_adjustment++; #endif node = SelectImage( hwnd ); if( node == NULL ) { return; } // the following assumes that max.x >> min_width point_size.x = max.x / node->width; if( point_size.x > width / node->width ) point_size.x = width / node->width; if( point_size.x < min_width / node->width + 1 ) point_size.x = min_width / node->width + 1; point_size.y = max.y / node->height; if( point_size.y > height / node->height ) point_size.y = height / node->height; if( point_size.y < 1 ) point_size.y = 1; if( ImgedConfigInfo.square_grid ) { if( point_size.x > point_size.y ) point_size.x = point_size.y; if( point_size.x < min_width / node->width + 1 ) { point_size.x = min_width / node->width + 1; } if( point_size.x > max.y / node->height ) { hmenu = GetMenu( _wpi_getframe( HMainWindow ) ); CheckSquareGrid( hmenu ); } else { point_size.y = point_size.x; } } new_width = (short)(point_size.x * node->width + x_adjustment); new_height = (short)(point_size.y * node->height + y_adjustment); pointSize = point_size; if( pointSize.x * node->width != width || pointSize.y * node->height != height ) { SetWindowPos( frame, HWND_TOP, 0, 0, new_width, new_height, SWP_SIZE | SWP_ZORDER | SWP_NOMOVE | SWP_SHOWWINDOW ); setGridSize( pointSize.x, pointSize.y ); } if( !firsttime ) { BlowupImage( node->hwnd, NULL ); } } /* ResizeChild */
void SimulationMainWindow1D::createActions(){ exitAct = new QAction(tr("E&xit"), this); exitAct->setShortcuts(QKeySequence::Quit); exitAct->setStatusTip(tr("Exit the application")); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); aboutAct = new QAction(tr("&About"), this); aboutAct->setStatusTip(tr("Show the application's About box")); connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); aboutQtAct = new QAction(tr("About &Qt"), this); aboutQtAct->setStatusTip(tr("Show the Qt library's About box")); connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); connect(aboutQtAct, SIGNAL(triggered()), this, SLOT(aboutQt())); // Simulation menu actions runAct = new QAction(tr("&Run"), this); runAct->setShortcut(tr("Ctrl+Alt+R")); runAct->setStatusTip(tr("Running the simulation")); connect(runAct, SIGNAL(triggered()), this, SLOT(runSimulation())); pauseAct = new QAction(tr("&Pause"), this); pauseAct->setShortcut(tr("Ctrl+Alt+P")); pauseAct->setStatusTip(tr("Pause the simulation")); connect(pauseAct, SIGNAL(triggered()), this, SLOT(pauseSimulation())); restartAct = new QAction(tr("&Restart"), this); restartAct->setShortcut(tr("Ctrl+Alt+N")); restartAct->setStatusTip(tr("Restart the simulation")); connect(restartAct, SIGNAL(triggered()), this, SLOT(restartSimulation())); // Input manu actions gridSizeAct = new QAction(tr("&Grid Size"), this); connect(gridSizeAct, SIGNAL(triggered()), this, SLOT(setGridSize())); toleranceAct = new QAction(tr("&Error Tolerance"), this); connect(toleranceAct, SIGNAL(triggered()), this, SLOT(setTolerance())); delaySecAct = new QAction(tr("&Animation Delay"), this); connect(delaySecAct, SIGNAL(triggered()), this, SLOT(setDelaySec())); realizationTimeStepAct = new QAction(tr("&Realization Time Step"), this); connect(realizationTimeStepAct, SIGNAL(triggered()), this, SLOT(setRealizationTimeStep())); // Setting the initial condition setICSinAct = new QAction(tr("&Sin"), this); setICSinAct->setCheckable(true); connect(setICSinAct, SIGNAL(triggered()), this, SLOT(setICSin())); setICStepAct = new QAction(tr("&Step"), this); setICStepAct->setCheckable(true); connect(setICStepAct, SIGNAL(triggered()), this, SLOT(setICStep())); setICRndNoiseAct = new QAction(tr("&Random Noise"), this); setICRndNoiseAct->setCheckable(true); connect(setICRndNoiseAct, SIGNAL(triggered()), this, SLOT(setICRndNoise())); icGroup = new QActionGroup(this); icGroup->addAction(setICSinAct); icGroup->addAction(setICStepAct); icGroup->addAction(setICRndNoiseAct); setICSinAct->setChecked(true); // Setting main solver setLaxFriedrichsAct = new QAction(tr("Lax-FriedRichs Scheme"), this); setLaxFriedrichsAct->setCheckable(true); connect(setLaxFriedrichsAct, SIGNAL(triggered()), this, SLOT(setLaxFriedrichsScheme())); setRK4Act = new QAction(tr("RK4 Scheme"), this); setRK4Act->setCheckable(true); connect(setRK4Act, SIGNAL(triggered()), this,SLOT(setRK4Scheme())); setMacCormackAct = new QAction(tr("MacCormack Scheme"), this); setMacCormackAct->setCheckable(true); connect(setMacCormackAct, SIGNAL(triggered()), this, SLOT(setMacCormackScheme())); setForwardEulerAct = new QAction(tr("Forward Euler Scheme"), this); setForwardEulerAct->setCheckable(true); connect(setForwardEulerAct, SIGNAL(triggered()), this, SLOT(setForwardEulerScheme())); setKurganovTadmor2000Act = new QAction(tr("Kurganov-Tadmor Scheme"), this); setKurganovTadmor2000Act->setCheckable(true); connect(setKurganovTadmor2000Act, SIGNAL(triggered()), this, SLOT(setKurganovTadmor2000Scheme())); setRK4KurganovTadmor2000Act = new QAction(tr("RK4 Kurganov-Tadmor Scheme"), this); setRK4KurganovTadmor2000Act->setCheckable(true); connect(setRK4KurganovTadmor2000Act, SIGNAL(triggered()), this, SLOT(setRK4KurganovTadmor2000Scheme())); setKurganovTadmor2ndOrder2000Act = new QAction(tr("2nd Order Kurganov-Tadmor Scheme"), this); setKurganovTadmor2ndOrder2000Act->setCheckable(true); connect(setKurganovTadmor2ndOrder2000Act, SIGNAL(triggered()), this, SLOT(setKurganovTadmor2ndOrder2000Scheme())); solverGroup = new QActionGroup(this); solverGroup->addAction(setMacCormackAct); solverGroup->addAction(setForwardEulerAct); solverGroup->addAction(setLaxFriedrichsAct); solverGroup->addAction(setKurganovTadmor2000Act); solverGroup->addAction(setRK4KurganovTadmor2000Act); solverGroup->addAction(setKurganovTadmor2ndOrder2000Act); solverGroup->addAction(setRK4Act); setRK4Act->setChecked(true); // Setting flux solver setMUSCLSAct = new QAction(tr("MUSCL Scheme"), this); setMUSCLSAct->setCheckable(true); connect(setMUSCLSAct, SIGNAL(triggered()), this, SLOT(setMUSCLSScheme())); setLinearReconstructionAct = new QAction(tr("Linear Reconstruction Scheme"), this); setLinearReconstructionAct->setCheckable(true); connect(setLinearReconstructionAct, SIGNAL(triggered()), this, SLOT(setLinearReconstructionScheme())); setPiecewiseParabolicReconstructionAct = new QAction(tr("Piecewise Parabolic Reconstruction Scheme"), this); setPiecewiseParabolicReconstructionAct->setCheckable(true); connect(setPiecewiseParabolicReconstructionAct, SIGNAL(triggered()), this, SLOT(setPiecewiseParabolicReconstructionScheme())); fluxGroup = new QActionGroup(this); fluxGroup->addAction(setMUSCLSAct); fluxGroup->addAction(setPiecewiseParabolicReconstructionAct); fluxGroup->addAction(setLinearReconstructionAct); setLinearReconstructionAct->setChecked(true); }
/*! * This is a convenience function that updates things so our items will be * drawn correctly. This should be called, e.g., after our widget is resized, * or some size property is changed. */ void CSIconListWidget::resizeItems() { setGridSize(QSize(getItemWidth(), getItemHeight())); }
Sheet::Sheet(QUndoStack &undo_stack, QSize size, QWidget *parent) : QWidget(parent), undo_stack(undo_stack) { initialize(); setGridSize(size); }
int QListView::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QAbstractItemView::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 1) qt_static_metacall(this, _c, _id, _a); _id -= 1; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< Movement*>(_v) = movement(); break; case 1: *reinterpret_cast< Flow*>(_v) = flow(); break; case 2: *reinterpret_cast< bool*>(_v) = isWrapping(); break; case 3: *reinterpret_cast< ResizeMode*>(_v) = resizeMode(); break; case 4: *reinterpret_cast< LayoutMode*>(_v) = layoutMode(); break; case 5: *reinterpret_cast< int*>(_v) = spacing(); break; case 6: *reinterpret_cast< QSize*>(_v) = gridSize(); break; case 7: *reinterpret_cast< ViewMode*>(_v) = viewMode(); break; case 8: *reinterpret_cast< int*>(_v) = modelColumn(); break; case 9: *reinterpret_cast< bool*>(_v) = uniformItemSizes(); break; case 10: *reinterpret_cast< int*>(_v) = batchSize(); break; case 11: *reinterpret_cast< bool*>(_v) = wordWrap(); break; case 12: *reinterpret_cast< bool*>(_v) = isSelectionRectVisible(); break; } _id -= 13; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setMovement(*reinterpret_cast< Movement*>(_v)); break; case 1: setFlow(*reinterpret_cast< Flow*>(_v)); break; case 2: setWrapping(*reinterpret_cast< bool*>(_v)); break; case 3: setResizeMode(*reinterpret_cast< ResizeMode*>(_v)); break; case 4: setLayoutMode(*reinterpret_cast< LayoutMode*>(_v)); break; case 5: setSpacing(*reinterpret_cast< int*>(_v)); break; case 6: setGridSize(*reinterpret_cast< QSize*>(_v)); break; case 7: setViewMode(*reinterpret_cast< ViewMode*>(_v)); break; case 8: setModelColumn(*reinterpret_cast< int*>(_v)); break; case 9: setUniformItemSizes(*reinterpret_cast< bool*>(_v)); break; case 10: setBatchSize(*reinterpret_cast< int*>(_v)); break; case 11: setWordWrap(*reinterpret_cast< bool*>(_v)); break; case 12: setSelectionRectVisible(*reinterpret_cast< bool*>(_v)); break; } _id -= 13; } else if (_c == QMetaObject::ResetProperty) { _id -= 13; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 13; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 13; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 13; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 13; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 13; } #endif // QT_NO_PROPERTIES return _id; }