void EApplyNumeric::init() { if (box) delete box; if (buttonPos == Qt::Horizontal) box = new QHBoxLayout(this); else if (buttonPos == Qt::Vertical) box = new QVBoxLayout(this); else box = new QHBoxLayout(this); box->setMargin(0); box->setSpacing(0); if (!data) data = new ENumeric(this, intDig, decDig); if (!button) button = new EApplyButton(this); box->addWidget(data, 3); box->addWidget(button, 1); setMinimumWidth(data->minimumWidth() + button->minimumWidth()); data->setDigitsFontScaleEnabled(d_fontScaleEnabled ? ESimpleLabel::Height : ESimpleLabel::None); button->setFontScaleMode(EPushButton::WidthAndHeight); connect(data, SIGNAL(valueChanged(double)), this, SLOT(numericValueChanged(double))); /* map ENumeric valueChanged() signal into EApplyNumeric omonimous signal */ connect(data, SIGNAL(valueChanged(double)), this, SIGNAL(valueChanged(double))); connect(button, SIGNAL(clicked()), this, SLOT(applyValue())); }
void sceneMaterial::internalUpdate ( manager* pManager, TimeType tval ) { if ( mKeys.size () < 2 ) return; //if ( getExponent () > 1.0f ) //tval = useExponent ( pManager, tval ); // Handle interp between appropriate keys. key out; out.mTimeStamp = tval; //for ( size_t num = 0; num < mKeys.size (); ++num ) // printf ( "key %d = %f\n", num, mKeys[ num ].mTimeStamp ); //Range range = equal_range ( mKeys.begin (), mKeys.end (), out ); Keys::iterator next = lower_bound ( mKeys.begin (), mKeys.end (), out ); Keys::iterator prev = next; if ( prev != mKeys.begin () ) --prev; else return; float mdiff = next->mTimeStamp - prev->mTimeStamp; float mtval = tval / mdiff; //pni::math::vec4 out ( pni::math::vec4::NoInit ); out.combine ( 1.0f - mtval, *prev, mtval, *next ); //printf ( "%x tval = %f, mtval = %f, mdiff = %f\n", this, tval, mtval, mdiff ); applyValue ( out ); }
void FieldView::contextMenuEvent(QContextMenuEvent* event) { QMenu menu(this); QModelIndex index = currentIndex(); if(index.isValid()) { menu.addAction(m_applyValueOnSelection); menu.addAction(m_applyValueOnAllLines); menu.addSeparator(); menu.addAction(m_defineCode); if(nullptr != m_canvasList) { menu.addSeparator(); menu.addAction(m_delItem); } } auto showSubMenu = menu.addMenu(tr("Show")); showSubMenu->addAction(m_showAllGroup); showSubMenu->addAction(m_showEsteticGroup); showSubMenu->addAction(m_showIdGroup); showSubMenu->addAction(m_showValueGroup); showSubMenu->addAction(m_showGeometryGroup); auto hideSubMenu = menu.addMenu(tr("Show/Hide")); auto columnCount = m_model->columnCount(QModelIndex()); for(int i = 0; i < columnCount;++i) { auto name = m_model->headerData(i,Qt::Horizontal,Qt::DisplayRole).toString(); auto act = hideSubMenu->addAction(name); act->setCheckable(true); act->setChecked(!isColumnHidden(i)); connect(act, SIGNAL(triggered(bool)) , m_mapper, SLOT(map())); m_mapper->setMapping(act,i); } QAction* act = menu.exec(event->globalPos()); if(act == m_delItem) { auto itemData = static_cast<Field*>(index.internalPointer()); DeleteFieldCommand* deleteCommand = new DeleteFieldCommand(itemData,m_canvasList->at(*m_currentPage),m_model,*m_currentPage); m_undoStack->push(deleteCommand); } else if( m_applyValueOnAllLines == act) { applyValue(index,false); } else if(m_applyValueOnSelection == act) { applyValue(index,true); } else if(m_defineCode == act) { defineItemCode(index); } else if(m_resetCode == act) { if(!index.isValid()) return; Field* field = m_model->getFieldFromIndex(index); if(nullptr != field) { field->setGeneratedCode(QStringLiteral("")); } } }
// Sets up and runs the parallel kenken solver void runParallel(unsigned P) { int i, pid; long long myNodeCount; job_t* myJob; cell_t* myCells; constraint_t* myConstraints; struct timeval startCompTime, endCompTime; // Begin parallel omp_set_num_threads(P); // Run algorithm #pragma omp parallel default(shared) private(i, pid, myNodeCount, myJob, \ myCells, myConstraints) { // Initialize local variables and data-structures pid = omp_get_thread_num(); myNodeCount = 0; myConstraints = (constraint_t*)calloc(sizeof(constraint_t), numConstraints); if (!myConstraints) unixError("Failed to allocate memory for myConstraints"); myCells = (cell_t*)calloc(sizeof(cell_t), totalNumCells); if (!myCells) unixError("Failed to allocate memory for myCells"); myJob = (job_t*)malloc(sizeof(job_t)); if (!myJob) unixError("Failed to allocate memory for myJob"); // Record start of computation time #pragma omp single gettimeofday(&startCompTime, NULL); // Get and complete new job until none left, or solution found while (getNextJob(pid, myJob)) { memcpy(myConstraints, constraints, numConstraints * sizeof(constraint_t)); memcpy(myCells, cells, totalNumCells * sizeof(cell_t)); for (i = 0; i < myJob->length; i++) applyValue(myCells, myConstraints, myJob->assignments[i].cellIndex, myJob->assignments[i].value); if (ADD_TO_QUEUE(&(jobQueues[pid]), myJob)) { myNodeCount++; // Guarenteed to succeed given ADD_TO_QUEUE(...) returned true addToQueue(myJob->length, myCells, myConstraints, &(jobQueues[pid]), myJob->assignments, AVAILABLE(&jobQueues[pid])); } else solve(myJob->length, myCells, myConstraints, &myNodeCount); } #pragma omp critical nodeCount += myNodeCount; } // Calculate computation time gettimeofday(&endCompTime, NULL); compTime = TIME_DIFF(endCompTime, startCompTime); }