uint8_t Gui::checkScheme(void) { uint8_t ex, ey, count, current; current = 0; for (count = 0; count < _size; count++) { ex = _scheme[count].col * FONT_WIDTH; ey = _scheme[count].row * FONT_HEIGHT; switch (_scheme[count].type) { case GUI_BUTTON: if (checkBox(ex, ey + 2, strlen(_scheme[count].string) * FONT_WIDTH + 11, FONT_HEIGHT + 9)) { return current + 1; } current++; break; case GUI_ARROW: if (checkBox(ex + 24, ey + 2, 23, 19)) { return current + 1; } else if (checkBox(ex + 3, ey + 18, 23, 19)) { return current + 2; } else if (checkBox(ex + 45, ey + 18, 23, 19)) { return current + 3; } else if (checkBox(ex + 24, ey + 34, 23, 19)) { return current + 4; } current += 4; break; } } return 0; }
bool SudokuBoardGenerator::checkConstraints(int row, int col, int value, SudokuFile &sf, std::vector<std::vector<int>> &board) { if (checkRow(row, value, sf.getN(), board) && checkColumn(col, value, sf.getN(), board) && checkBox(row, col, value, sf.getP(), sf.getQ(), board)) { return true; } return false; }
/* * Prueft ob Zahl schon vorhanden (ruft fuer jede Bedingung eine Unterfunktion auf * Rueckgabe: 0 fuer nicht gefunden * 1 fuer gefunden */ int check(int x, int y, int wert) { if(checkHorizontal(y, wert)) return 1; if(checkVertical(x, wert)) return 1; if(checkBox(x, y, wert)) return 1; return 0; }
void WItemDelegate::updateModelIndex(WWidget *widget, const WModelIndex& index) { WidgetRef w(widget); if (index.flags() & ItemIsUserCheckable) { IndexCheckBox *cb = checkBox(w, index, false, false); if (cb) cb->setIndex(index); } }
//-------------------------------------------------------------------------- void BoundingBoxTests::testCreator() { CPPUNIT_ASSERT_EQUAL(6_z * sizeof (float), sizeof (AABB3f)); CPPUNIT_ASSERT_EQUAL(6_z * sizeof (int32_t), sizeof (AABB3i)); CPPUNIT_ASSERT_EQUAL(6_z * sizeof (double), sizeof (AABB3g)); // Display std::cout << "Displaying AABBs" << std::endl << a1 << a2 << a3 << a4 << a5 << a6 << a7 << std::endl; // << i1 << i2 << i3 // Check lower corner of the box is <= to the upper corner CPPUNIT_ASSERT_EQUAL(true, isWellFormed(a1)); CPPUNIT_ASSERT_EQUAL(true, isWellFormed(a2)); CPPUNIT_ASSERT_EQUAL(true, isWellFormed(a3)); CPPUNIT_ASSERT_EQUAL(true, isWellFormed(a4)); checkBoxDummy(a8); CPPUNIT_ASSERT_EQUAL(true, isWellFormed(a5)); CPPUNIT_ASSERT_EQUAL(true, isWellFormed(a6)); CPPUNIT_ASSERT_EQUAL(true, isWellFormed(a7)); // Integer boxes CPPUNIT_ASSERT_EQUAL(true, isWellFormed(i1)); CPPUNIT_ASSERT_EQUAL(true, isWellFormed(i2)); CPPUNIT_ASSERT_EQUAL(true, isWellFormed(i3)); checkBox(i2, Vector2i(-2, -2), Vector2i(2, 2)); checkBox(i3, Vector2i(42, 42), Vector2i(42, 42)); // Change dimension a5.set({1,1,1}, {2,2,2}); CPPUNIT_ASSERT_EQUAL(true, eq(a5, a2)); CPPUNIT_ASSERT_EQUAL(true, eq(a7, a2)); // Getter CPPUNIT_ASSERT_EQUAL(true, vector::eq(a5.m_bbmin, a5.get(aabb::LowerCorner))); CPPUNIT_ASSERT_EQUAL(true, vector::eq(a5.m_bbmax, a5.get(aabb::UpperCorner))); CPPUNIT_ASSERT_EQUAL(true, vector::ne(a4.m_bbmin, a5.get(aabb::LowerCorner))); CPPUNIT_ASSERT_EQUAL(true, vector::ne(a4.m_bbmax, a5.get(aabb::UpperCorner))); // Try to malformed a AABB. Check security is triggered CPPUNIT_ASSERT_THROW(a5.set(Vector3f(2,2,2), Vector3f(1,1,1)), std::out_of_range); CPPUNIT_ASSERT_THROW(AABB3f({2,2,2}, {1,1,1}), std::out_of_range); CPPUNIT_ASSERT_THROW(AABB3f(Vector3f(2), Vector3f(1)), std::out_of_range); }
bool ShapeCollisionImage::collide(SimCollisionImage* image, CollisionSurfaceList *list ) { AssertFatal(collisionDetail!=-1, "ShapeCollisionImage::collide: collisionDetail not set or set improperly."); AssertFatal(shapeInst, "ShapeCollisionImage::collide: shape not set or set improperly."); TMat3F mat; switch (image->getType()) { case Sphere: { buildImageTransform(image,list,&mat); SimCollisionSphereImage* si = static_cast<SimCollisionSphereImage*>(image); return shapeInst->collideSphere (collisionDetail,si->center,si->radius,&mat,list, collisionLevel==CollideFaces); } case Box: { buildImageTransform(image,list,&mat); SimCollisionBoxImage* bi = static_cast<SimCollisionBoxImage*>(image); return checkBox(bi,&mat,list); } case Tube: { buildImageTransform(image,list,&mat); SimCollisionTubeImage* ti = static_cast<SimCollisionTubeImage*>(image); return shapeInst->collideTube (collisionDetail,ti->start,ti->end,ti->radius,&mat,list, collisionLevel==CollideFaces); } case Line: { // Collides line with TS3 shape // Lines always collide with the highest detail level. buildImageTransform(image,list,&mat); SimCollisionLineImage* li = static_cast<SimCollisionLineImage*>(image); return shapeInst->collideLine(0,li->start,li->end,&mat,list, collisionLevel==CollideFaces); } // case Terrain: { SimCollisionTerrImage* ti = static_cast<SimCollisionTerrImage*>(image); return checkTerrain(ti,list); } case Interior: { SimCollisionItrImage* ii = static_cast<SimCollisionItrImage*>(image); return checkInterior(ii,list); } case ShapeCollisionImageType: { ShapeCollisionImage* si = static_cast<ShapeCollisionImage*>(image); return checkShape(si,list); } default: AssertFatal(0,"ShapeCollisionImage:collide: Unrecognized type"); break; } return false; }
//-------------------------------------------------------------------------- void BoundingBoxTests::testCopy() { AABB3f old(a1); AABB3f tmp(old); a1 = a2; CPPUNIT_ASSERT_EQUAL((a1 == a2), true); a1 = AABB3f::UNIT_SCALE; CPPUNIT_ASSERT_EQUAL((a1 == a3), true); a1 = old; checkBox(a1, tmp.m_bbmin, tmp.m_bbmax); }
LRESULT OperaColorsPage::onInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { PropPage::translate((HWND)(*this), texts); PropPage::read(*this, items); PropPage::read(*this, items, listItems, GetDlgItem(IDC_OPERACOLORS_BOOLEANS)); ctrlList.Attach(GetDlgItem(IDC_OPERACOLORS_BOOLEANS)); crProgressDown = SETTING(DOWNLOAD_BAR_COLOR); crProgressUp = SETTING(UPLOAD_BAR_COLOR); crProgressTextDown = SETTING(PROGRESS_TEXT_COLOR_DOWN); crProgressTextUp = SETTING(PROGRESS_TEXT_COLOR_UP); ctrlProgressDownDrawer.Attach(GetDlgItem(IDC_PROGRESS_COLOR_DOWN_SHOW)); ctrlProgressUpDrawer.Attach(GetDlgItem(IDC_PROGRESS_COLOR_UP_SHOW)); CUpDownCtrl ctrlSpin; ctrlSpin.Attach(GetDlgItem(IDC_FLAT_SPIN)); ctrlSpin.SetRange(1, 5); ctrlSpin.Detach(); updateProgress(); crMenubarLeft = SETTING(MENUBAR_LEFT_COLOR); crMenubarRight = SETTING(MENUBAR_RIGHT_COLOR); ctrlLeftColor.Attach(GetDlgItem(IDC_SETTINGS_ODC_MENUBAR_LEFT)); ctrlRightColor.Attach(GetDlgItem(IDC_SETTINGS_ODC_MENUBAR_RIGHT)); ctrlTwoColors.Attach(GetDlgItem(IDC_SETTINGS_ODC_MENUBAR_USETWO)); ctrlBumped.Attach(GetDlgItem(IDC_SETTINGS_ODC_MENUBAR_BUMPED)); ctrlMenubarDrawer.Attach(GetDlgItem(IDC_SETTINGS_ODC_MENUBAR_COLOR)); checkBox(IDC_SETTINGS_ODC_MENUBAR_BUMPED, BOOLSETTING(MENUBAR_BUMPED)); checkBox(IDC_SETTINGS_ODC_MENUBAR_USETWO, BOOLSETTING(MENUBAR_TWO_COLORS)); BOOL b; onMenubarClicked(0, IDC_SETTINGS_ODC_MENUBAR_USETWO, 0, b); // Do specialized reading here return TRUE; }
int main(){ int puzzles; scanf("%d", &puzzles); int runs; for (runs = 0; runs < puzzles; ++runs) { int correctSolution = 1; // If this value is never changed, then the solution is correct. int field[SIZE][SIZE]; int i,j,k,l; for (i = 0; i < SIZE; ++i) { for (j = 0; j < SIZE; ++j) { scanf("%1d",&field[i][j]); // Reads in data } } i = 0; while(i <= 6 && correctSolution == 1){ j = i + 3; k = 0; while(k <= 6 && correctSolution == 1){ l = k + 3; correctSolution = checkBox(field,i,j,k,l); k += 3; } i += 3; } if(correctSolution == 1){ // If the solution is still correct to this point, all horizontal lines are checked. correctSolution = checkHorizontal(field); } if(correctSolution == 1){ // If the solution is still correct to this point, all vertical lines are checked. correctSolution = checkVertical(field); } if(correctSolution == 1){ printf("YES\n"); } else{ printf("NO\n"); } } return 0; }
//-------------------------------------------------------------------------- void BoundingBoxTests::testSwap() { swap(a1, a2); checkBox(a1, Vector3f(1,1,1), Vector3f(2,2,2)); checkBox(a2, Vector3f::ZERO, Vector3f::UNIT_SCALE); swap(a1, a2); checkBox(a2, Vector3f(1,1,1), Vector3f(2,2,2)); checkBox(a1, Vector3f::ZERO, Vector3f::UNIT_SCALE); swap(a2, a1); checkBox(a1, Vector3f(1,1,1), Vector3f(2,2,2)); checkBox(a2, Vector3f::ZERO, Vector3f::UNIT_SCALE); swap(a2, a1); checkBox(a2, Vector3f(1,1,1), Vector3f(2,2,2)); checkBox(a1, Vector3f::ZERO, Vector3f::UNIT_SCALE); }
void SpatialGraphKDNode::GetGridPoints( Vector2List& points, int& xPoints, int& yPoints ) { xPoints = 0; yPoints = 0; Vector2 vSmallestDimensions = Tree->GetSmallestDimensions(); Vector2 vMyBoxDimensions = BBox.Max - BBox.Min; /* if( vSmallestDimensions == vMyBoxDimensions ) { xPoints = 1; yPoints = 1; points.push_back( BBox.Centroid() ); return; } */ xPoints = static_cast<int>(vMyBoxDimensions.X / vSmallestDimensions.X); yPoints = static_cast<int>(vMyBoxDimensions.Y / vSmallestDimensions.Y); points.reserve(xPoints*yPoints); Vector2 vBottomLeftStartBox( BBox.Min.X, BBox.Max.Y - vSmallestDimensions.Y ); BoundingBox startBox( vBottomLeftStartBox, vBottomLeftStartBox + vSmallestDimensions); BoundingBox checkBox( startBox ); for( int yDim = 0; yDim < yPoints; yDim++ ) { for( int xDim = 0; xDim < xPoints; xDim++ ) { points.push_back( checkBox.Centroid() ); checkBox.Min.X += vSmallestDimensions.X; checkBox.Max.X += vSmallestDimensions.X; } checkBox.Min.X = startBox.Min.X; checkBox.Max.X = startBox.Max.X; checkBox.Min.Y -= vSmallestDimensions.Y; checkBox.Max.Y -= vSmallestDimensions.Y; } }
int isLegal(sudokuGrid game, int candidateCell, int trialValue){ int rowStart = (candidateCell/9)*9; int columnStart = candidateCell % 9; int i, k, temp; int topLeft; int topLeftElement; for(i = rowStart; i < (rowStart +9); i++){ if((candidateCell != i) && (trialValue == game[i])){ return FALSE; } } for(i = columnStart; i < 81; i+=9){ if((candidateCell != i) && (trialValue == game[i])){ return FALSE; } } if(candidateCell >= 0 && candidateCell < 27){ topLeftElement = 0 + topLeftColumn(game, candidateCell); }else if(candidateCell >= 27 && candidateCell < 54){ topLeftElement = 27 + topLeftColumn(game, candidateCell); }else if(candidateCell >= 54 && candidateCell < 81){ topLeftElement = 54 + topLeftColumn(game, candidateCell); } for(k = 0; k < 3; k++){ int randCell = topLeftElement + k; temp = checkBox(randCell, game, candidateCell, trialValue); if(!temp){ return FALSE; } } return TRUE; }
bool DialogMsg::ShowUIOKDoNotShowOption( const QString& title,const QString& msg ) { QCheckBox checkBox( tr( "Do not show this dialog again" ),this ) ; this->setFixedSize( 270,110 ) ; checkBox.setGeometry( 30,40,251,31 ) ; m_ui->label->setGeometry( 10,10,251,31 ) ; m_ui->label->setFixedSize( m_ui->label->size() ) ; m_ui->pbOk->setGeometry( 100,70,75,31 ) ; m_ui->pbYes->setHidden( true ) ; m_ui->pbNo->setHidden( true ) ; m_ui->pbOk->setHidden( false ) ; this->HideLabels() ; this->ShowUI( title,msg ) ; return checkBox.isChecked() ; }
short PATTIMURA_Open(PATTIMURA_Context *ctx, const unsigned char *cipherKey, short keyBits, unsigned char mode, const unsigned char *userBox) { short ret; if(!ctx) return 1; memset(ctx, 0, sizeof(PATTIMURA_Context)); if((mode <= PATTIMURA_FREE) || (mode >= PATTIMURA_MODES)) return 1; ctx->mode = mode; if(checkBox(userBox)){ return 1; } ret = PATTIMURA_InitTable(ctx, cipherKey, keyBits, userBox); if((ret == 0) && ((ctx->mode == PATTIMURA_CBC_DEC) || (ctx->mode == PATTIMURA_ECB_DEC))) PATTIMURA_InverseTable(ctx->tw); return ret; }
void WItemDelegate::updateModelIndex(WWidget *widget, const WModelIndex& index) { WidgetRef w(widget); if (index.flags() & ItemIsUserCheckable) { IndexCheckBox *cb = checkBox(w, index, false, false); if (cb) cb->setIndex(index); } if (index.flags() & ItemHasDeferredTooltip) { IndexText *text = dynamic_cast<IndexText *>(widget); if (text) text->setIndex(index); IndexAnchor *anchor = dynamic_cast<IndexAnchor *>(widget); if (anchor) anchor->setIndex(index); IndexContainerWidget *c = dynamic_cast<IndexContainerWidget *>(widget); if (c) c->setIndex(index); } }
//-------------------------------------------------------------------------- void BoundingBoxTests::testOperations() { // Check the center CPPUNIT_ASSERT_EQUAL(true, vector::eq(Vector3f(1.5f, 1.5f, 1.5f), a2.center())); CPPUNIT_ASSERT_EQUAL(true, vector::eq(Vector3f(0), a4.center())); Vector3f c(AABB3f::DUMMY.center()); for (size_t i = 0_z; i < 3_z; ++i) { CPPUNIT_ASSERT_EQUAL(true, std::isnan(c[i])); } // Check volume comparaison CPPUNIT_ASSERT_EQUAL(1.0f, a2.volume()); CPPUNIT_ASSERT_EQUAL(4.0f * 4.0f * 4.0f, (a2 * 4.0f).volume()); a5 = a2 * 4.0f; CPPUNIT_ASSERT_EQUAL(true, (a5 > a2)); CPPUNIT_ASSERT_EQUAL(false, (a5 < a2)); CPPUNIT_ASSERT_EQUAL(true, (a2 >= a3)); CPPUNIT_ASSERT_EQUAL(true, (a2 <= a3)); CPPUNIT_ASSERT_EQUAL(true, (a2 == a3)); CPPUNIT_ASSERT_EQUAL(true, (a6 > a3)); // Check if a point is contained or not to an AABB. CPPUNIT_ASSERT_EQUAL(true, a2.contains(Vector3f(1.5f, 1.5f, 1.5f))); CPPUNIT_ASSERT_EQUAL(true, a2.contains(a2.center())); CPPUNIT_ASSERT_EQUAL(false, a2.contains(a2.center() * 3.0f)); CPPUNIT_ASSERT_EQUAL(true, a6.contains(a2.center() * 3.0f)); // Box containing others CPPUNIT_ASSERT_EQUAL(true, a1.contains(a1)); CPPUNIT_ASSERT_EQUAL(false, a8.contains(a1)); CPPUNIT_ASSERT_EQUAL(true, a6.contains(a1)); CPPUNIT_ASSERT_EQUAL(false, AABB3f(0, 1).contains(AABB3f(1, 2))); // corner case // Clamp //checkBox(clamp(a1, a1.m_bbmin, a1.m_bbmax), a1.m_bbmin, a1.m_bbmax); //checkBox(clamp(a1 * 4.0f, a1.m_bbmin, a1.m_bbmax), a1.m_bbmin, a1.m_bbmax); // Box collisions CPPUNIT_ASSERT_EQUAL(false, a2.collides(a4)); CPPUNIT_ASSERT_EQUAL(true, a2.collides(AABB3f(Vector3f(2,2,2), Vector3f(3,3,3)))); CPPUNIT_ASSERT_EQUAL(true, a6.collides(a4)); checkBox(intersection(a3, a3), a3.m_bbmin, a3.m_bbmax); checkBox(merge(a3, a3), a3.m_bbmin, a3.m_bbmax); checkBox(intersection(a3, a6), a3.m_bbmin, a3.m_bbmax); checkBox(merge(a6, a6), a6.m_bbmin, a6.m_bbmax); checkBox(merge(a6, a3), a6.m_bbmin, a6.m_bbmax); checkBox(merge(a3, a6), a6.m_bbmin, a6.m_bbmax); checkBox(intersection(a6, a3), a3.m_bbmin, a3.m_bbmax); checkBox(intersection(a3, a6), a3.m_bbmin, a3.m_bbmax); checkBox(merge(a2, a3), a3.m_bbmin, a2.m_bbmax); // Try intersection with disjoint AABB. checkBoxDummy(intersection(a2, a3)); checkBoxDummy(intersection(a5, a3)); // Check intersecation at an AABB corner. checkBox(intersection(a7, AABB3f(0, 1)), Vector3f(1), Vector3f(1)); checkBox(intersection(AABB3f(0, 1), AABB3f(-1, 0)), Vector3f(0), Vector3f(0)); // AABB collisions CPPUNIT_ASSERT_EQUAL(true, a4.collides(a4)); CPPUNIT_ASSERT_EQUAL(false, a4.collides(a2)); CPPUNIT_ASSERT_EQUAL(false, a2.collides(a4)); CPPUNIT_ASSERT_EQUAL(true, a2.collides(AABB3f(Vector3f(2,2,2), Vector3f(3,3,3)))); CPPUNIT_ASSERT_EQUAL(true, a6.collides(a4)); CPPUNIT_ASSERT_EQUAL(true, a4.collides(a6)); // CPPUNIT_ASSERT_EQUAL(std::numeric_limits<float>::infinity(), a6.volume()); CPPUNIT_ASSERT_EQUAL(true, vector::eq(Vector3f(std::numeric_limits<float>::infinity()), a6.size())); }
/*------------------------------------------------------------------------------ | Dialog::createControlsFromTemplate | ------------------------------------------------------------------------------*/ Dialog& Dialog :: createControlsFromTemplate( ) { PDLGTEMPLATE pdlgt; /* Dialog Template Pointer */ void* pvStart; /* Dialog Template Item Pointer */ register unsigned long cItems, /* Dialog Items Counter */ ulRc, /* Return code */ i; /* Loop Counter */ /* Set mouse pointer to "wait" in case template */ /* is large */ IPointerHandle oldPointer = mousePointer(); ISystemPointerHandle systemPointer( ISystemPointerHandle::wait ); setMousePointer( systemPointer ); /* Try reading in the dialog template for the */ /* given dialog ID */ ulRc = DosGetResource( 0, RT_DIALOG, this->ulId, (void **)&pdlgt ); if ( ulRc != 0 ) { /* Dialog template not found; reset mouse */ /* pointer and throw exception */ setMousePointer( oldPointer ); ITHROWSYSTEMERROR( ulRc, "DosGetResource", IErrorInfo::accessError, IException::recoverable ); } /* Save pointer to the start of the dlg template */ pvStart = (void *)pdlgt; /* Save the number of controls found within the */ /* dialog template */ cItems = pdlgt->adlgti[0].cChildren + 1; /* Read in and create an Open Class Library C++ */ /* object for each of the controls within the */ /* dialog template */ for ( i = 1; i < cItems; i++ ) { /* Obtain the id of the control */ unsigned long ulId = (unsigned long)(pdlgt->adlgti[i].id & 0xffff); /* Skip the control if its id is -1 */ if ( ulId != 0xffff ) { /* Check to see if a custom control is specified */ /* or if a standard PM control class is being */ /* used */ if ( pdlgt->adlgti[i].cchClassName ) { /* Since a length for the class name present, */ /* a custom control class name is being used for */ /* the control. Point to the memory location */ /* where the class name is found within the */ /* dialog template information. */ customControl( ulId, ((char *)pvStart + pdlgt->adlgti[i].offClassName) ); } else { /* No class name length given indicating that a */ /* standard PM class is being used. The class */ /* name is stored as an index value. For */ /* example, the class for static's is defined as */ /* */ /* #define WC_STATIC ((PSZ)0xffff0005L) */ /* */ /* The values within the dialog template for */ /* the static class would be */ /* */ /* adlgti[i].cchClassName = 0 */ /* adlgti[i].offClassName = 5 */ /* */ /* Therefore, the value of offClassName field */ /* must be used as an index that is used to */ /* actually select the class name. */ switch ( pdlgt->adlgti[i].offClassName ) { case WINCLASS_BUTTON : { unsigned long ulStyle = pdlgt->adlgti[i].flStyle & BS_PRIMARYSTYLES; switch ( ulStyle ) { case BS_PUSHBUTTON: { if ( pdlgt->adlgti[i].flStyle & (BS_BITMAP | BS_ICON) ) { IGraphicPushButton* pGraphicPushButton = new IGraphicPushButton( ulId, this ); pGraphicPushButton->setAutoDeleteObject( true ); graphicPushButton( pGraphicPushButton ); } else { IPushButton* pPushButton = new IPushButton( ulId, this ); pPushButton->setAutoDeleteObject( true ); this->pushButton( pPushButton ); } } break; case BS_CHECKBOX: case BS_AUTOCHECKBOX: { ICheckBox* pCheckBox = new ICheckBox( ulId, this ); pCheckBox->setAutoDeleteObject( true ); checkBox( pCheckBox ); } break; case BS_RADIOBUTTON: case BS_AUTORADIOBUTTON: { IRadioButton* pRadioButton = new IRadioButton( ulId, this ); pRadioButton->setAutoDeleteObject( true ); radioButton( pRadioButton ); } break; case BS_3STATE: case BS_AUTO3STATE: { I3StateCheckBox* p3StateCheckBox = new I3StateCheckBox( ulId, this ); p3StateCheckBox->setAutoDeleteObject( true ); threeStateCheckBox( p3StateCheckBox ); } break; case BS_USERBUTTON: { customButton( ulId ); } break; } //end switch } //WINCLASS_BUTTON break; case WINCLASS_SCROLLBAR : { IScrollBar* pScrollBar = new IScrollBar( ulId, this ); pScrollBar->setAutoDeleteObject( true ); scrollBar( pScrollBar ); } break; case WINCLASS_LISTBOX : { IListBox* pListBox = new IListBox( ulId, this ); pListBox->setAutoDeleteObject( true ); listBox( pListBox ); } break; case WINCLASS_ENTRYFIELD : { IEntryField* pEntryField = new IEntryField( ulId, this ); pEntryField->setAutoDeleteObject( true ); entryField( pEntryField ); } break; case WINCLASS_STATIC : { unsigned long ulStyle = pdlgt->adlgti[i].flStyle & (SS_TEXT | SS_GROUPBOX | SS_ICON | SS_BITMAP); switch ( ulStyle ) { case SS_TEXT: { IStaticText* pStaticText = new IStaticText( ulId, this ); pStaticText->setAutoDeleteObject( true ); staticText( pStaticText ); } break; case SS_GROUPBOX: { IGroupBox* pGroupBox = new IGroupBox( ulId, this ); pGroupBox->setAutoDeleteObject( true ); groupBox( pGroupBox ); } break; case SS_ICON: { IIconControl* pIcon = new IIconControl( ulId, this ); pIcon->setAutoDeleteObject( true ); iconControl( pIcon ); } break; case SS_BITMAP: { IBitmapControl* pBitmap = new IBitmapControl( ulId, this ); pBitmap->setAutoDeleteObject( true ); bitmapControl( pBitmap ); } break; } //end switch } //WINCLASS_STATIC break; case WINCLASS_COMBOBOX : { IComboBox* pComboBox = new IComboBox( ulId, this ); pComboBox->setAutoDeleteObject( true ); comboBox( pComboBox ); } break; case WINCLASS_MLE : { IMultiLineEdit* pMLE = new IMultiLineEdit( ulId, this ); pMLE->setAutoDeleteObject( true ); mle( pMLE ); } break; case WINCLASS_SPINBUTTON : { if ( pdlgt->adlgti[i].flStyle & SPBS_NUMERICONLY ) { INumericSpinButton* pNumericSpinButton = new INumericSpinButton( ulId, this ); pNumericSpinButton->setAutoDeleteObject( true ); numericSpinButton( pNumericSpinButton ); } else { ITextSpinButton* pTextSpinButton = new ITextSpinButton( ulId, this ); pTextSpinButton->setAutoDeleteObject( true ); textSpinButton( pTextSpinButton ); } } break; case WINCLASS_CONTAINER : { IContainerControl* pContainer = new IContainerControl( ulId, this ); pContainer->setAutoDeleteObject( true ); container( pContainer ); } break; case WINCLASS_SLIDER : { if ( pdlgt->adlgti[i].flStyle & SLS_READONLY ) { IProgressIndicator* pProgressIndicator = new IProgressIndicator( ulId, this ); pProgressIndicator->setAutoDeleteObject( true ); progressIndicator( pProgressIndicator ); } else { ISlider* pSlider = new ISlider( ulId, this ); pSlider->setAutoDeleteObject( true ); slider( pSlider ); } } break; case WINCLASS_VALUESET : //No valueset class - see OS/2 C++ Class Library Power GUI //Programming with C Set++ for an implementation of a //valueset class. break; case WINCLASS_NOTEBOOK : { INotebook* pNotebook = new INotebook( ulId, this ); pNotebook->setAutoDeleteObject( true ); notebook( pNotebook ); } break; case WINCLASS_CIRCULARSLIDER : { ICircularSlider* pCircularSlider = new ICircularSlider( ulId, this ); pCircularSlider->setAutoDeleteObject( true ); circularSlider( pCircularSlider ); } break; } //end switch } //end if } //end if - id != -1 } //end for /* Release the memory allocated for the dlg */ /* template before returning */ DosFreeResource( pvStart ); /* Reset mouse pointer */ setMousePointer( oldPointer ); return( *this ); } //Dialog::createControlsFromTemplate
bool TextLocation::locateRecogBox() { // Verify edgeAndBlack image int clusterNum = 0; CvRect box; bool havebox = getBoundingBox(m_edgeAndBlackImg, clusterNum, box); if (havebox) checkBox(m_edgeAndBlackImg, box); // Draw boxes /*for (unsigned int i = 0; i < boxes.size(); ++i) { cvRectangle( outImg, cvPoint(boxes[i].x, boxes[i].y), cvPoint(boxes[i].x + boxes[i].width, boxes[i].y + boxes[i].height), CV_RGB(255, 0, 255), 3); }*/ CvRect verifiedBox = cvRect(0, 0, 0, 0); bool edgeAndBlackGood = verifyBox(m_edgeAndBlackImg, clusterNum, box, verifiedBox); /*if (edgeAndBlackGood) { cvRectangle( outImg, cvPoint(verifiedBox.x, verifiedBox.y), cvPoint(verifiedBox.x + verifiedBox.width, verifiedBox.y + verifiedBox.height), CV_RGB(255, 0, 255), 3); }*/ // Verify edge image int clusterNum2 = 0; CvRect box2; bool edgeGood = false; CvRect verifiedBox2 = cvRect(0, 0, 0, 0); if (thrImgMode == ADVANCED_EDGE) { bool havebox = getBoundingBox(m_advancedEdgeImg, clusterNum2, box2); if (havebox) checkBox(m_advancedEdgeImg, box2); edgeGood = verifyBox(m_advancedEdgeImg, clusterNum2, box2, verifiedBox2); } else if (thrImgMode == SIMPLE_EDGE) { bool havebox = getBoundingBox(m_simpleEdgeImg, clusterNum2, box2); if (havebox) checkBox(m_simpleEdgeImg, box2); edgeGood = verifyBox(m_simpleEdgeImg, clusterNum2, box2, verifiedBox2); } // Draw boxes2 /*for (unsigned int i = 0; i < boxes2.size(); ++i) { cvRectangle( outImg, cvPoint(boxes2[i].x, boxes2[i].y), cvPoint(boxes2[i].x + boxes2[i].width, boxes2[i].y + boxes2[i].height), CV_RGB(0, 255, 255), 1); }*/ /*if (edgeGood) { cvRectangle( outImg, cvPoint(verifiedBox2.x, verifiedBox2.y), cvPoint(verifiedBox2.x + verifiedBox2.width, verifiedBox2.y + verifiedBox2.height), CV_RGB(0, 255, 255), 3); }*/ if (edgeAndBlackGood) { vector<int> segLines(0); getSegLines(m_edgeAndBlackImg, verifiedBox, segLines); getSegRects(m_edgeAndBlackImg, segLines, verifiedBox, this->segRects); return true; } else if (edgeGood) { if (thrImgMode == ADVANCED_EDGE) { vector<int> segLines(0); getSegLines(m_advancedEdgeImg, verifiedBox2, segLines); getSegRects(m_advancedEdgeImg, segLines, verifiedBox2, this->segRects); } else if (thrImgMode == SIMPLE_EDGE) { vector<int> segLines(0); getSegLines(m_simpleEdgeImg, verifiedBox2, segLines); getSegRects(m_simpleEdgeImg, segLines, verifiedBox2, this->segRects); } return true; } else return false; }
int main (void) { bowl_init (); #if 0 twoButtonBox ("some sample text", "confirmation", "yes", "no"); #elif 0 problemBox (MSG_SILO_PROBLEM, MSG_PROBLEM); #elif 0 for (;;) { pleaseWaitBox (MSG_RUNNING_LILO); sleep (2); } #elif 0 inputBox (MSG_LINUX_AND_SWAP, MSG_NO_SWAP_PARTITION, "/dev/sda1"); #elif 1 { char buf[128]; enterDirBox ("Enter a directory", "Here you must type the directory name", "/debian", buf, 128); } #elif 1 { struct d_choices opt[30]; int i; for (i = 0; i < 30; i++) { opt[i].tag = malloc (16); sprintf (opt[i].tag, "таг %d", i); opt[i].string = malloc (128); sprintf (opt[i].string, "item %d", i); opt[i].state = i; } menuBox ("This is a little text", "I'm the title", opt, 30, 1); } #elif 1 { char *choices[30]; char values[30]; char *valuesp; int i; for (i = 0; i < 30; i++) { choices[i] = malloc (128); sprintf (choices[i], "item %d", i); values[i] = i % 2 ? '*' : ' '; } valuesp = values; checkBox ("This is a little text", "I'm the title", 10, 50, choices, &valuesp, 30); } #elif 0 { int i; scaleBox ("Installing rescue floppy...", "Please wait", 10, SCALE_CREATE); for (i = 0; i <= 10; i++) { scaleBox (NULL, NULL, i, SCALE_REFRESH); sleep (1); } } #elif 1 bowl_new_text (MSG_BAD_FLOPPY MSG_LINUX_AND_SWAP); bowl_title (MSG_NO_SWAP_PARTITION); bowl_new_button (MSG_YES, 0); bowl_new_button (MSG_NO, 0); bowl_new_button (_("Cancel"), 0); bowl_new_button ("Quit", 0); bowl_new_button ("Help", 0); bowl_layout (); bowl_run (); #endif return 0; }
int main(int argc, char** argv) { int i,j, leafSum=0; struct timeval start,end; /*Original function generation 3-D points (x,y,z) that belong on the first octant of the unit sphere in three-dimentional space */ generator(); box = (Box*)malloc(sizeof(Box)); if(box==NULL){ exit(3);} gettimeofday(&start, NULL); /*BEGINNING OF CALCULATIONS - INITIALIZATION OF THE ROOT */ box[0].boxid = 1; box[0].level = 0; box[0].parent = 0; box[0].center[0] = 0.5; box[0].center[1] = 0.5; box[0].center[2] = 0.5; box[0].length = 1; box[0].start=0; box[0].n=N; box[0].points = (int*)malloc(N*sizeof(int)); for(i=0;i<N;i++){ box[0].points[i]=i; } for(i=0;i<26;i++){ box[0].colleague[i]=0; } /*MAIN THREAD BEGINS THREAD EXECUTING CALCULATING OCTREES!!*/ checkBox(0); printf("\n\nTotal n measured in boxes = %d",totalPoints); /*OPTIONAL - JUST FOR VERIFICATION*/ for(i=0;i<leafCounter;i++){ leafSum+=leaf[i].n; } printf("\nTotal n measured in leaves is %d",leafSum); gettimeofday(&end, NULL); divisionTime = ((end.tv_sec * 1000000 + end.tv_usec) -(start.tv_sec * 1000000 + start.tv_usec)); /*******FIND COLLEAGUES - PTHREADS VERSION*******/ gettimeofday(&start, NULL); remove("colleagues.txt"); findLevels(); findColleagues(); gettimeofday(&end, NULL); colleaguesTime = ((end.tv_sec * 1000000 + end.tv_usec) -(start.tv_sec * 1000000 + start.tv_usec)); createB(); gettimeofday(&start, NULL); /* printf("\nSaving in files..."); boxesFile(); leavesFile(); alphaFile(); betaFile(); timeFile(); colleaguesFile(); */ gettimeofday(&end, NULL); filesTime = ((end.tv_sec * 1000000 + end.tv_usec) -(start.tv_sec * 1000000 + start.tv_usec)); printf("\n\nOctree Division time is %d",divisionTime); printf("\nColleagues finding time is %d",colleaguesTime); printf("\nSaving data in files time is %d",filesTime); printf("\nTotal calculation time is %d",divisionTime+colleaguesTime+filesTime); printf("\n\n***END OF PROGRAM***"); return (EXIT_SUCCESS); }
void createOctants(Box *cube) { //printf("\nInside createOctans(parrent id = %d)",cube->boxid); int i=0,j=0,temp; /*BOX MUTEX LOCK*/ /*This cube will be a parent of 8 others. We need to save his data so the 8 children can access it!*/ #pragma omp critical(boxMutex) {box = (Box*)realloc(box,(8+idCounter)*sizeof(Box)); /*Give the appropriate values at box[] referring to nodes*/ for(i=0; i<8; i++) { idCounter++; box[idCounter-1].boxid=idCounter;// boxid of new child box[cube->boxid-1].child[i]=idCounter; // pass the data of the child in parent box //printf("\nChild %d of parent id = %d has id = %d",i+1,cube->boxid,box[cube->boxid-1].child[i]); box[idCounter-1].length=cube->length/2; box[idCounter-1].parent=cube->boxid; box[idCounter-1].level=cube->level+1; box[idCounter-1].n = 0; box[idCounter-1].childIndex = i; box[idCounter-1].colleagueCounter = 0; for(j=0;j<26;j++){ box[idCounter-1].colleague[j]=0; }} if(cube->level+1 > maxLevel){ maxLevel = cube->level+1;} cube->counter=idCounter; box[cube->counter-8].center[0]=cube->center[0]-cube->length/4;//0.25 box[cube->counter-8].center[1]=cube->center[1]-cube->length/4;//0.25 box[cube->counter-8].center[2]=cube->center[2]-cube->length/4;//0.25 box[cube->counter-7].center[0]=cube->center[0]-cube->length/4;//0.25 box[cube->counter-7].center[1]=cube->center[1]-cube->length/4;//0.25 box[cube->counter-7].center[2]=cube->center[2]+cube->length/4;//0.75 box[cube->counter-6].center[0]=cube->center[0]+cube->length/4;//0.75 box[cube->counter-6].center[1]=cube->center[1]-cube->length/4;//0.25 box[cube->counter-6].center[2]=cube->center[2]-cube->length/4;//0.25 box[cube->counter-5].center[0]=cube->center[0]+cube->length/4;//0.75 box[cube->counter-5].center[1]=cube->center[1]-cube->length/4;//0.25 box[cube->counter-5].center[2]=cube->center[2]+cube->length/4;//0.75 box[cube->counter-4].center[0]=cube->center[0]-cube->length/4;//0.25 box[cube->counter-4].center[1]=cube->center[1]+cube->length/4;//0.75 box[cube->counter-4].center[2]=cube->center[2]-cube->length/4;//0.25 box[cube->counter-3].center[0]=cube->center[0]-cube->length/4;//0.25 box[cube->counter-3].center[1]=cube->center[1]+cube->length/4;//0.75 box[cube->counter-3].center[2]=cube->center[2]+cube->length/4;//0.75 box[cube->counter-2].center[0]=cube->center[0]+cube->length/4;//0.75 box[cube->counter-2].center[1]=cube->center[1]+cube->length/4;//0.75 box[cube->counter-2].center[2]=cube->center[2]-cube->length/4;//0.25 box[cube->counter-1].center[0]=cube->center[0]+cube->length/4;//0.75 box[cube->counter-1].center[1]=cube->center[1]+cube->length/4;//0.75 box[cube->counter-1].center[2]=cube->center[2]+cube->length/4;//0.75 } /*BOX MUTEX UNLOCK*/ // printf("\nSequential call of checkBox from the 8 chlidren of parent %d",cube->boxid); temp = cube->counter; #pragma omp parallel shared(temp) private(i) { #pragma omp for schedule(dynamic,1) nowait for (i=temp-8;i<temp;i++) { //printf("\n%d",i); checkBox(i); } } return; }
WWidget *WItemDelegate::update(WWidget *widget, const WModelIndex& index, WFlags<ViewItemRenderFlag> flags) { bool editing = widget && widget->find("t") == 0; if (flags & RenderEditing) { if (!editing) { widget = createEditor(index, flags); WInteractWidget *iw = dynamic_cast<WInteractWidget *>(widget); if (iw) { // Disable drag & drop and selection behaviour iw->mouseWentDown().preventPropagation(); iw->clicked().preventPropagation(); } } } else { if (editing) widget = 0; } WidgetRef widgetRef(widget); bool isNew = false; if (!(flags & RenderEditing)) { if (!widgetRef.w) { isNew = true; IndexText *t = new IndexText(index); t->setObjectName("t"); if (index.isValid() && !(index.flags() & ItemIsXHTMLText)) t->setTextFormat(PlainText); t->setWordWrap(true); widgetRef.w = t; } if (!index.isValid()) return widgetRef.w; bool haveCheckBox = false; boost::any checkedData = index.data(CheckStateRole); if (!checkedData.empty()) { haveCheckBox = true; CheckState state = (checkedData.type() == typeid(bool) ? (boost::any_cast<bool>(checkedData) ? Checked : Unchecked) : (checkedData.type() == typeid(CheckState) ? boost::any_cast<CheckState>(checkedData) : Unchecked)); IndexCheckBox *icb = checkBox(widgetRef, index, true, index.flags() & ItemIsTristate); icb->setCheckState(state); icb->setEnabled(index.flags() & ItemIsUserCheckable); } else if (!isNew) delete checkBox(widgetRef, index, false); boost::any linkData = index.data(LinkRole); if (!linkData.empty()) { WLink link = boost::any_cast<WLink>(linkData); IndexAnchor *a = anchorWidget(widgetRef, index); a->setLink(link); if (link.type() == WLink::Resource) a->setTarget(TargetNewWindow); } IndexText *t = textWidget(widgetRef, index); WString label = asString(index.data(), textFormat_); if (label.empty() && haveCheckBox) label = WString::fromUTF8(" "); t->setText(label); std::string iconUrl = asString(index.data(DecorationRole)).toUTF8(); if (!iconUrl.empty()) { iconWidget(widgetRef, index, true)->setImageLink(WLink(iconUrl)); } else if (!isNew) delete iconWidget(widgetRef, index, false); } if (index.flags() & ItemHasDeferredTooltip){ widgetRef.w->setDeferredToolTip(true, (index.flags() & ItemIsXHTMLText) ? XHTMLText : PlainText); } else { WString tooltip = asString(index.data(ToolTipRole)); if (!tooltip.empty() || !isNew) widgetRef.w->setToolTip(tooltip, (index.flags() & ItemIsXHTMLText) ? XHTMLText : PlainText); } WT_USTRING sc = asString(index.data(StyleClassRole)); if (flags & RenderSelected) sc += WT_USTRING::fromUTF8 (" " + WApplication::instance()->theme()->activeClass()); if (flags & RenderEditing) sc += WT_USTRING::fromUTF8(" Wt-delegate-edit"); widgetRef.w->setStyleClass(sc); if (index.flags() & ItemIsDropEnabled) widgetRef.w->setAttributeValue("drop", WString::fromUTF8("true")); else if (!widgetRef.w->attributeValue("drop").empty()) widgetRef.w->setAttributeValue("drop", WString::fromUTF8("f")); return widgetRef.w; }
//-------------------------------------------------------------------------- void BoundingBoxTests::testArithmetic() { AABB3f a = AABB3f({1,1,1}, {2,2,2}); AABB3f b = AABB3f({-2,-2,-2}, {-1,-1,-1}); checkBox(-a, Vector3f(-2), Vector3f(-1)); checkBox(+(-a), Vector3f(-2), Vector3f(-1)); checkBox(-b, Vector3f(1), Vector3f(2)); checkBox(+(-b), Vector3f(1), Vector3f(2)); checkBox(a + 1.0f, Vector3f(2,2,2), Vector3f(3,3,3)); checkBox(a - 1.0f, Vector3f(0,0,0), Vector3f(1,1,1)); checkBox(a * 2.0f, a.m_bbmin * 2.0f, a.m_bbmax * 2.0f); checkBox(a / 2.0f, a.m_bbmin / 2.0f, a.m_bbmax / 2.0f); // Suppressed because too dangerous: can create malformed AABB //Vector3f v = Vector3f(1,2,3); //checkBox(a + v, Vector3f(2,3,4), Vector3f(3,4,5)); //checkBox(v + a, Vector3f(2,3,4), Vector3f(3,4,5)); //checkBox(a - v, Vector3f(0,-1,-2), Vector3f(1,0,-1)); //checkBox(v - a, Vector3f(0,1,2), Vector3f(-1,0,1)); checkBox(1.0f + a, Vector3f(2), Vector3f(3)); checkBox(1.0f - a, Vector3f(-1), Vector3f(0)); checkBox(2.0f * a, a.m_bbmin * 2.0f, a.m_bbmax * 2.0f); checkBox(2.0f / a, 2.0f / a.m_bbmax, 2.0f / a.m_bbmin); // Suppressed because too dangerous: error of logic // Merge (and not the sum of box corners) //checkBox(a + a, a.m_bbmin, a.m_bbmax); // Union (and not the sum of box corners) //checkBox(a - a, a.m_bbmin, a.m_bbmax); }
bool PlayerCollisionImage::collide(SimCollisionImage* image, CollisionSurfaceList *list ) { AssertFatal(collisionDetail!=-1, "PlayerCollisionImage::collide: collisionDetail not set or set improperly."); AssertFatal(shapeInst, "PlayerCollisionImage::collide: shape not set or set improperly."); // Test collision of image argument against this image. // Collision surfaces are returned in this image space. // Build the transform which goes from image space to the // space in which the testing will take place. TMat3F mat; list->stepVector.set(0,0,-1); // Do the tests... switch (image->getType()) { case Sphere: { buildImageTransform(image,list,&mat); SimCollisionSphereImage* si = static_cast<SimCollisionSphereImage*>(image); return shapeInst->collideSphere (collisionDetail,si->center,si->radius,&mat,list, collisionLevel==CollideFaces); } case Box: { buildImageTransform(image,list,&mat); SimCollisionBoxImage* bi = static_cast<SimCollisionBoxImage*>(image); return checkBox(bi,&mat,list); } case Tube: { buildImageTransform(image,list,&mat); SimCollisionTubeImage* ti = static_cast<SimCollisionTubeImage*>(image); return shapeInst->collideTube (collisionDetail,ti->start,ti->end,ti->radius,&mat,list, collisionLevel==CollideFaces); } case Line: { Point3F a,b; RealF hit; SimCollisionLineImage *line = static_cast<SimCollisionLineImage *>(image); Parent::buildImageTransform(image, &mat); m_mul(line->start, mat, &a); m_mul(line->end, mat, &b); if(m_lineAABox(a, b, crouchBox.fMin, crouchBox.fMax, hit)) { CollisionSurface surface; surface.time = hit; surface.position.x = line->start.x + (hit * (line->end.x - line->start.x)); surface.position.y = line->start.y + (hit * (line->end.y - line->start.y)); surface.position.z = line->start.z + (hit * (line->end.z - line->start.z)); surface.distance = m_distf(surface.position, line->start); surface.normal.set(0, 0, 1); // incomplete and wrong surface.material = surface.surface = 0; list->tWorld.identity(); list->push_back(surface); return (true); } return (false); #if 0 // Collides line with bounding box (axis-aligned) -- easier to hit // than line/TS3, more accurate than line/Sphere float rTime = 0.0f; Point3F objStart, objEnd; Parent::buildImageTransform(image, &mat); SimCollisionLineImage *line = static_cast<SimCollisionLineImage *>(image); m_mul(line->start, mat, &objStart); m_mul(line->end, mat, &objEnd); return (m_lineAABox(objStart, objEnd, bbox.fMin, bbox.fMax, rTime) && rTime > 0.0f); #endif #if 0 // Collides line with sphere -- temporary "fix" to make it a little //easier to hit others SimCollisionSphereImage sphere; sphere.center = this->sphere.center; sphere.radius = this->sphere.radius; sphere.transform = transform; SimCollisionLineImage *line = static_cast<SimCollisionLineImage *>(image); return (line->collide(&sphere, list)); #endif #if 0 // Collides line with TS3 shape -- very difficult to hit buildImageTransform(image,list,&mat); SimCollisionLineImage* li = static_cast<SimCollisionLineImage*>(image); return shapeInst->collideLine (collisionDetail,li->start,li->end,&mat,list, collisionLevel==CollideFaces); #endif } // case Terrain: { SimCollisionTerrImage* ti = static_cast<SimCollisionTerrImage*>(image); return checkTerrain(ti,list); } case Interior: { SimCollisionItrImage* ii = static_cast<SimCollisionItrImage*>(image); return checkInterior(ii,list); } case ShapeCollisionImageType: { ShapeCollisionImage* si = static_cast<ShapeCollisionImage*>(image); return checkShape(si,list); } case PlayerCollisionImageType: { PlayerCollisionImage* pi = static_cast<PlayerCollisionImage*>(image); return checkPlayer(pi,list); } default: AssertFatal(0,"PlayerCollisionImage:collide: Unrecognized type"); break; } return false; }