Example #1
0
  /*! \brief getMyCoordinate function
   *  stores the coordinate of the current processor in procCoords[*][rank]
   */
  void getMyCoordinate(/* nCoord_t &xyz[networkDim]*/){  // KDD Enable the argument rather
                               // KDD than writing into array here

    // Call RAAMP system to get coordinates and store in xyz (MD)
    // What is the RAAMP call?  (AG)
    // AG will return a view (pointer) to RAAMP's data.
    // We will copy it into xyz.

//KDD #if defined(HAVE_ZOLTAN2_LDMS)
//KDD #elif defined(HAVE_ZOLTAN2_TOPOMGR)
//KDD #elif defined(HAVE_ZOLTAN2_RCA)
//KDD #else

    // The code below may be good for the default constructor, perhaps,
    // but it should copy the data into xyz instead of the procCoords.
    int myRank = comm->getRank();

    int slice = int (pow( double(numProcs), double(1.0 / networkDim)) + 0.5 );

    int m = myRank;
    for (int i = 0; i < networkDim; ++i){
      procCoords[i][myRank] = m / int(pow(slice, double(networkDim - i - 1)));
      m = m % int(pow(double(slice), double(networkDim - i - 1)));
    }
//KDD #endif
  }
/*!
  Change one mouse pattern

  \param pattern Index of the pattern
  \param button Button
  \param state State

  \sa QMouseEvent
*/
void QwtEventPattern::setMousePattern(uint pattern, int button, int state)
{
    if ( pattern < (uint)d_mousePattern.count() ) {
        d_mousePattern[int(pattern)].button = button;
        d_mousePattern[int(pattern)].state = state;
    }
}
void GammaCompressor::compressUnsignedInt(ofstream * invertedFile, unsigned int number, unsigned char * bitCode, int * currentBit)
{
    int numberSizeByBit;
    int cpt;
    if (number > 0) {
        numberSizeByBit = int(floor(log(number) / log(2)))+1;
    }
    else {
        numberSizeByBit = 0;
    }
    cpt = numberSizeByBit;
    while (cpt > 1) {
        writeBit(invertedFile, bitCode, currentBit, true);
        cpt--;
    }
    writeBit(invertedFile, bitCode, currentBit, false);
    if (number == 0) {
        writeBit(invertedFile, bitCode, currentBit, false);
    }
    else if (number == 1) {
        writeBit(invertedFile, bitCode, currentBit, true);
    }
    else {
        cpt = numberSizeByBit-1;
        number =number % int(pow(2, cpt));
        while (cpt > 0) {
            writeBit(invertedFile, bitCode, currentBit, number / int(pow(2, cpt - 1)) == 1);
            number = number % int(pow(2, cpt-1));
            cpt--;
        }
    }

}
Example #4
0
//--------------------------------------------------------------
void startScene::loadXML(){

    XML.load("mySettings.xml");
    
    for (int i=0; i<9; i++) {
        ofImage temp;
        temp.loadImage("dogs2/"+ofToString(i)+".png");
        dogImages.push_back(temp);
    }
    
    int i= 0;
    if(XML.getName() == "PHOTO" && XML.setTo("val[0]"))
    {
        do {
            button  tempPhoto;
            buttons.push_back(tempPhoto);
            int x = int(XML.getValue<float>("X")*ofGetWidth());
            int y = int(XML.getValue<float>("Y")*ofGetHeight());
            int angle = int(XML.getValue<int>("ANGLE"));
            
            if (i>dogImages.size()-1) {
                i = 0;
            }
            buttons.back().setup(dogImages[i], x , y, angle);
            i++;
        }
        while(XML.setToSibling());
        XML.setToParent();
    }

}
Example #5
0
void String::unserialize(VariableUnserializer *uns,
                         char delimiter0 /* = '"' */,
                         char delimiter1 /* = '"' */) {
  int64_t size = uns->readInt();
  if (size >= RuntimeOption::MaxSerializedStringSize) {
    throw Exception("Size of serialized string (%d) exceeds max", int(size));
  }
  if (size < 0) {
    throw Exception("Size of serialized string (%d) must not be negative",
                    int(size));
  }

  char ch = uns->readChar();
  if (ch != ':') {
    throw Exception("Expected ':' but got '%c'", ch);
  }
  ch = uns->readChar();
  if (ch != delimiter0) {
    throw Exception("Expected '%c' but got '%c'", delimiter0, ch);
  }
  StringData *px = NEW(StringData)(int(size));
  MutableSlice buf = px->mutableSlice();
  assert(size <= buf.len);
  uns->read(buf.ptr, size);
  px->setSize(size);
  if (m_px) decRefStr(m_px);
  m_px = px;
  px->setRefCount(1);

  ch = uns->readChar();
  if (ch != delimiter1) {
    throw Exception("Expected '%c' but got '%c'", delimiter1, ch);
  }
}
Example #6
0
void Sample::update(const ofRectangle& vidRect,
                    const ofVec2f& vidSize,
                    const ofPixels& pixels) {
    
    _pos.set(vidRect.x + (vidRect.width * _vidPercent.x),
             vidRect.y + (vidRect.height * _vidPercent.y));
    
    // parse r, g, b, a values
    ofColor c = pixels.getColor(vidSize.x * _vidPercent.x,
                                vidSize.y * _vidPercent.y);
    
    _smoothedVals[0].addValue(c.r);
    _smoothedVals[1].addValue(c.g);
    _smoothedVals[2].addValue(c.b);
    
    val[0] = int(_smoothedVals[0].getValue());
    val[1] = int(_smoothedVals[1].getValue());
    val[2] = int(_smoothedVals[2].getValue());
    // http://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color
    // https://en.wikipedia.org/wiki/Relative_luminance
    val[3] = int((0.2126 * val[0] + 0.7152 * val[1] + 0.0722 * val[2])); // luminance
    
    vals[_valsIndex] = val;
    if (_valsIndex > BUFFER_SIZE - 1) {
        _valsIndex = 0;
    } else {
        _valsIndex++;
    }
}
Example #7
0
CBasePin* CBaseMuxerFilter::GetPin(int n)
{
	CAutoLock cAutoLock(this);

	if (n >= 0 && n < (int)m_pInputs.GetCount()) {
		if (POSITION pos = m_pInputs.FindIndex(n)) {
			return m_pInputs.GetAt(pos);
		}
	}

	n -= int(m_pInputs.GetCount());

	if (n == 0 && m_pOutput) {
		return m_pOutput;
	}

	n--;

	if (n >= 0 && n < (int)m_pRawOutputs.GetCount()) {
		if (POSITION pos = m_pRawOutputs.FindIndex(n)) {
			return m_pRawOutputs.GetAt(pos);
		}
	}

	n -= int(m_pRawOutputs.GetCount());

	return NULL;
}
Example #8
0
Weight &Weight::operator/=(const double &s) {
    double totalA = double (this->lbs * 16 + this->ozs) / s;
    this->lbs = int (totalA) / 16;
    this->ozs =int (totalA) % 16;
    
    return *this;
}
Example #9
0
 csColor GetPixel (float coord_x, float coord_y)
 {
   // Scale the texture coordinates.
   coord_x *= textureScale.x;
   coord_y *= textureScale.y;
 
   // Calculate the material coordinates.
   float matcoord_x_f = (coord_x * img_w);
   float matcoord_y_f = (coord_y * img_h);
   int matcoord_x = int (matcoord_x_f);
   int matcoord_y = int (matcoord_y_f);
 
   // Bilinearly filter from material.
   csColor p00 (GetPixelWrap (img, img_w, img_h,
     matcoord_x, matcoord_y));
   csColor p01 (GetPixelWrap (img, img_w, img_h,
     matcoord_x, matcoord_y+1));
   csColor p11 (GetPixelWrap (img, img_w, img_h,
     matcoord_x+1, matcoord_y+1));
   csColor p10 (GetPixelWrap (img, img_w, img_h,
     matcoord_x+1, matcoord_y));
 
   float f1 = matcoord_x_f - matcoord_x;
   float f2 = matcoord_y_f - matcoord_y;
 
   return csLerp (csLerp (p00, p10, f1), 
     csLerp (p01, p11, f1), f2);
 }
Example #10
0
void CListBox::paint()
{
    liststart = (selected/listmaxshow)*listmaxshow;
    int lastnum =  liststart + listmaxshow;

    if(lastnum<10)
        numwidth = g_Fonts->channellist_number->getRenderWidth("0");
    else if(lastnum<100)
        numwidth = g_Fonts->channellist_number->getRenderWidth("00");
    else if(lastnum<1000)
        numwidth = g_Fonts->channellist_number->getRenderWidth("000");
    else if(lastnum<10000)
        numwidth = g_Fonts->channellist_number->getRenderWidth("0000");
    else // if(lastnum<100000)
        numwidth = g_Fonts->channellist_number->getRenderWidth("00000");

    for(unsigned int count=0; count<listmaxshow; count++)
    {
        paintItem(count);
    }

    int ypos = y+ theight;
    int sb = fheight* listmaxshow;
    frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb,  COL_MENUCONTENT+ 1);

    int sbc= ((getItemCount()- 1)/ listmaxshow)+ 1;
    float sbh= (sb- 4)/ sbc;
    int sbs= (selected/listmaxshow);

    frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ int(sbs* sbh) , 11, int(sbh),  COL_MENUCONTENT+ 3);
}
Example #11
0
int FWadCollection::FindLumpMulti (const char **names, int *lastlump, bool anyns, int *nameindex)
{
	LumpRecord *lump_p;

	assert(lastlump != NULL && *lastlump >= 0);
	lump_p = &LumpInfo[*lastlump];
	while (lump_p < &LumpInfo[NumLumps])
	{
		FResourceLump *lump = lump_p->lump;

		if (anyns || lump->Namespace == ns_global)
		{
			
			for(const char **name = names; *name != NULL; name++)
			{
				if (!strnicmp(*name, lump->Name, 8))
				{
					int lump = int(lump_p - &LumpInfo[0]);
					*lastlump = lump + 1;
					if (nameindex != NULL) *nameindex = int(name - names);
					return lump;
				}
			}
		}
		lump_p++;
	}

	*lastlump = NumLumps;
	return -1;
}
void PanelAppletOverlay::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event)

    QStyleOption op;
    op.initFrom(this);

    bool hovered = op.state & QStyle::State_MouseOver;
    bool mover = mouseGrabber() == this;
    if (!hovered || mover) {
        return;
    }

    QPainter p(this);
    KIcon icon("transform-move");
    int iconSize;
    QRect iconRect;


    if (!m_applet) {
        return;
    }

    if (m_orientation == Qt::Horizontal) {
        iconSize = qMin(qMin(height(), int(m_applet->size().width())), 64);
        iconRect = QRect(rect().center() - QPoint(iconSize / 2, iconSize / 2), QSize(iconSize, iconSize));
    } else {
        iconSize = qMin(qMin(width(), int(m_applet->size().height())), 64);
        iconRect = QRect(rect().center() - QPoint(iconSize / 2, iconSize / 2), QSize(iconSize, iconSize));
    }

    p.drawPixmap(iconRect, icon.pixmap(iconSize, iconSize));
}
void GL_ToggleControl::draw(int& parentHorPos2,int& parentVertPos2,btScalar deltaTime)
{

	int controlHorPos = int(m_toggleBody->getWorldTransform().getOrigin()[0]+m_parentWindow->getScreenWidth()/2);
	int controlVertPos = int(m_toggleBody->getWorldTransform().getOrigin()[1]+m_parentWindow->getScreenHeight()/2);
	
	int parentHorPos = controlHorPos-8;
	int parentVertPos = controlVertPos-8;

	unsigned int grey = 0xff6f6f6f;
	
	drawRect(parentHorPos, parentVertPos, parentHorPos+16, parentVertPos+16, grey, grey, grey, grey);
	
	int borderSize = 2;
	unsigned int white = 0xffefefef;
	drawRect(parentHorPos+borderSize, parentVertPos+borderSize, parentHorPos+16-borderSize, parentVertPos+16-borderSize, white,white,white,white);
	
	
	if (m_active)
	{
		//unsigned int red = 0xff8f0000;
	//	unsigned int white = 0xff8f0000;
		unsigned int black = 0xff1f1f1f;
		borderSize = 4;
		drawRect(parentHorPos+borderSize, parentVertPos+borderSize, parentHorPos+16-borderSize, parentVertPos+16-borderSize, black,black,black,black);
	} 
	
	btVector3 rgb(1,1,1);

	GLDebugDrawStringInternal(parentHorPos2,parentVertPos+16,m_toggleText,rgb);
	parentVertPos2+=20;
	
}
Example #14
0
/*! \brief Updates relevant fields of the class member fHeader with the
		properties of the most recently decoded video frame.

	It is assumed that this function is called only	when the following asserts
	hold true:
		1. We actually got a new picture decoded by the video decoder.
		2. fHeader wasn't updated for the new picture yet. You MUST call this
		   method only once per decoded video frame.
		3. This function MUST be called before
		   _DeinterlaceAndColorConvertVideoFrame() as the later one relys on an
		   updated fHeader.
		4. There will be at maximumn only one decoded video frame in our cache
		   at any single point in time. Otherwise you couldn't tell to which
		   cached decoded video frame the properties in fHeader relate to.
		5. AVCodecContext is still valid for this video frame (This is the case
		   when this function is called immediately after
		   avcodec_decode_video2().
*/
void
AVCodecDecoder::_UpdateMediaHeaderForVideoFrame()
{
	fHeader.type = B_MEDIA_RAW_VIDEO;
	fHeader.file_pos = 0;
	fHeader.orig_size = 0;
	fHeader.start_time = fRawDecodedPicture->reordered_opaque;
	fHeader.u.raw_video.display_line_width = fRawDecodedPicture->width;
	fHeader.u.raw_video.display_line_count = fRawDecodedPicture->height;
	fHeader.u.raw_video.bytes_per_row
		= CalculateBytesPerRowWithColorSpaceAndVideoWidth(fOutputColorSpace,
			fRawDecodedPicture->width);
	fHeader.u.raw_video.field_gamma = 1.0;
	fHeader.u.raw_video.field_sequence = fFrame;
	fHeader.u.raw_video.field_number = 0;
	fHeader.u.raw_video.pulldown_number = 0;
	fHeader.u.raw_video.first_active_line = 1;
	fHeader.u.raw_video.line_count = fRawDecodedPicture->height;

	ConvertAVCodecContextToVideoAspectWidthAndHeight(*fContext,
		fHeader.u.raw_video.pixel_width_aspect,
		fHeader.u.raw_video.pixel_height_aspect);

	TRACE("[v] start_time=%02d:%02d.%02d field_sequence=%lu\n",
		int((fHeader.start_time / 60000000) % 60),
		int((fHeader.start_time / 1000000) % 60),
		int((fHeader.start_time / 10000) % 100),
		fHeader.u.raw_video.field_sequence);
}
Example #15
0
bool CollisionX(glm::vec3 move,int &i)
{
	int k = ((move + m_eye).x - m_eye.x > 0.05);
	i = int(floor((m_eye + move).x + 2 * k)) / 4;
	
	return M[i][int(floor(m_eye.z)/4)] == '#';
}
double arrondi( double d, unsigned precision =0 )
 {
  double mult {1.} ;
  while (precision-->0) mult *= 10. ;
  if (d>0) { return int(d*mult+.5)/mult ; }
  else { return int(d*mult-.5)/mult ; }
 }
Example #17
0
bool CollisionZ(glm::vec3 move, int &j)
{
	int k = ((move + m_eye).z - m_eye.z > 0.05);
	j = int(floor((m_eye + move).z + 2 * k)) / 4;

	return M[int(floor(m_eye.x)/4)][j] == '#';
}
Example #18
0
/** Prepare the result image with the given instantiated net and the corresponding label image tiles */
void Analysis::prepareResultImage()
{
  iNodeRoot_->setNewID(1);
  emit message("Preparing result map");
  if (!iNodeRoot_->labelImage()) {
    qDebug("Analysis::prepareResultImage: no labelimage");
    return;
  }
  int size_x =
    int ((geoImageList_->geoEast() -
          geoImageList_->geoWest()) / labelImageList_->maxResolution());
  int size_y =
    int ((geoImageList_->geoNorth() -
          geoImageList_->geoSouth()) / labelImageList_->maxResolution());
  GeoImage *img = new GeoImage("result.plm", "result", size_x, size_y,
                               geoImageList_->geoWest(),
                               geoImageList_->geoNorth(),
                               geoImageList_->geoEast(),
                               geoImageList_->geoSouth());
  if (!img->mergeInto(*(iNodeRoot_->labelImage()), 0,
                      iNodeRoot_->attributeInt("id"),
                      iNodeRoot_->attributeInt("IDStart"))) {
    iNodeRoot_->attribute("status", "deleted");
  }
  iNodeRoot_->mergeResultImage(*img);
  img->write();
  map_ = img;
  emit sigMapView(iNodeRoot_, map_);
#ifdef DEBUGMSG
  qDebug("Analysis::prepareResultImage: image=(%dx%d)", size_x, size_y);
#endif
}
void PulsingColorAnimation::sinusSignal(double time) {
    double fac = std::sin(pulsation() * (time - delay()));
    /*
    QColor meanHSV = meanColor().toHsv();
    QColor varHSV = varColor().toHsv();
    int h = meanHSV.hue() + int(fac * varHSV.hue());
    if (h>255) h=255;
    if (h<0) h=0;
    int s = meanHSV.saturation() + int(fac * varHSV.saturation());
    if (s>255) s=255;
    if (s<0) s=0;
    int v = meanHSV.value() + int(fac * varHSV.value());
    if (v>255) v=255;
    if (v<0) v=0;
    m_color.setHsv(h, s, v) ;
    */

    int r = meanColor().red() + int(fac * varColor().red());
    if (r>255) r-=255;
    if (r<0) r+=255;
    int g = meanColor().green() + int(fac * varColor().green());
    if (g>255) g-=255;
    if (g<0) g+=255;
    int b = meanColor().blue() + int(fac * varColor().blue());
    if (b>255) b-=255;
    if (b<0) b+=255;
    m_color.setRgb(r, g, b);

}
Example #20
0
void
Profiler::PrintTree(TypeNode *node, TypeNode *baseNode, int column, TimeStamp freq)
{
    const UnitData *base        = baseNode->GetValue();

    for(int i = 0; i < PhaseCount; i++)
    {
        if(node->ChildExistsAt(i))
        {
            UnitData *data = node->GetChildAt(i)->GetValue();
#ifdef ENABLE_DEBUG_CONFIG_OPTIONS
            if( int(data->incl * 100 / base->incl) >= Configuration::Global.flags.ProfileThreshold) // threshold
#endif
            {

                Output::SkipToColumn(column);

                Output::Print(L"%-*s %7.1f %5d %7.1f %5d %7.1f %7.1f %5d\n",
                              (Profiler::PhaseNameWidth-column), PhaseNames[i],
                              (double)data->incl / freq ,                    // incl
                              int(data->incl * 100 / base->incl ),        // incl %
                              (double)data->excl / freq ,                    // excl
                              int(data->excl * 100 / base->incl ),        // excl %
                              (double)data->max  / freq ,                    // max
                              (double)data->incl / ( freq * data->count ),   // mean
                              int(data->count)                            // count
                             );
            }

            PrintTree(node->GetChildAt(i), baseNode, column + Profiler::TabWidth, freq);
        }
    }
}
void
BorderFontEffect::blit(SDL_Surface* target, const FT_Bitmap& brush, int x_pos, int y_pos) const
{
  SDL_LockSurface(target);
  
  int start_x = std::max(0, -x_pos);
  int start_y = std::max(0, -y_pos);
  
  int end_x = std::min(brush.width, target->w  - x_pos);
  int end_y = std::min(brush.rows,  target->h - y_pos);

  unsigned char* target_buf = static_cast<unsigned char*>(target->pixels);

  int target_pitch = target->pitch;

  for (int y = start_y; y < end_y; ++y)
    for (int x = start_x; x < end_x; ++x)
      {
        int target_pos = (y + y_pos) * target_pitch + 4*(x + x_pos);
        int brush_pos  = y * brush.pitch + x;
            
        target_buf[target_pos + 0] = int(float(y)/brush.width * 255);
        target_buf[target_pos + 1] = int(float(y)/brush.width * 255);
        target_buf[target_pos + 2] = 255;
        target_buf[target_pos + 3] = brush.buffer[brush_pos];
      }
    
  SDL_UnlockSurface(target);

}
Example #22
0
// Convert a HYPRE_Int to int
inline int to_int(HYPRE_Int i)
{
#ifdef HYPRE_BIGINT
    MFEM_ASSERT(HYPRE_Int(int(i)) == i, "overflow converting HYPRE_Int to int");
#endif
    return int(i);
}
Example #23
0
QPoint EmptyMapAdapter::coordinateToDisplay(const QPointF& coordinate) const
{
    qreal x = (coordinate.x()+180) * (numberOfTiles*mytilesize)/360.; // coord to pixel!
    qreal y = (1-(log(tan(PI/4+deg_rad(coordinate.y())/2)) /PI)) /2  * (numberOfTiles*mytilesize);

    return QPoint(int(x), int(y));
}
Example #24
0
// -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
// The timer periods for each note in the MIDI scale live here. The frequencies
// have been multiplied by 3 to obtain perfect fifths via frequency division.
// The notes are also offset to map the most precise pitches to the default range
// of the AKAI MPK49 performance controller. Beware of the high notes, the processor
// isn't fast enough to play all of them.
//
unsigned int NoteManager::getPeriodForNoteNumber(byte inNoteNumber)
{
  static const unsigned int noteCounts[] = {
    10192, 9620, 9080, 8570, 8089, 7635, 7206, 6802, 6420, 6060, 5719, 5398, 5095, 4809, 4539, 4284, 4044, 
    3817, 3603, 3400, 3209, 3029, 2859, 2699, 2547, 2404, 2269, 2142, 2021, 1908, 1801, 1700, 1604, 1514, 
    1429, 1349, 1273, 1202, 1134, 1070, 1010, 953, 900, 849, 802, 757, 714, 674, 636, 600, 567, 535, 505, 
    476, 449, 424, 400, 378, 357, 336, 318, 300, 283, 267, 252, 238, 224, 212, 200, 188, 178, 168, 158, 
    149, 141, 133, 125, 118, 112, 105, 99, 94, 88, 83, 79, 74, 70, 66, 62, 59, 55, 52, 49, 46, 44, 41, 39, 
    37, 34, 32, 31, 29, 27, 26, 24, 23, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 12, 11, 10, 10, 9, 8, 8, 7, 
    7, 6, 6, 6    
  };
  
  DEBUGSERIALWRITE("NoteManager::getPeriodForNoteNumber(");
  DEBUGSERIALPRINT(int(inNoteNumber), DEC);
  DEBUGSERIALWRITE("): ");
  
  inNoteNumber = (inNoteNumber < noteOffset) ? (inNoteNumber % octave) : (inNoteNumber - noteOffset);

  DEBUGSERIALPRINT(int(inNoteNumber), DEC);
  DEBUGSERIALWRITE(" ");

  const unsigned int periodForNoteNumber = noteCounts[inNoteNumber];

  DEBUGSERIALPRINTLN(int(periodForNoteNumber), DEC);
 
  return periodForNoteNumber; 
}
int main( int argc, char** argv )
{
	PrintBanner();

	if ( argc > 1 )
	{
		LoadDensityMap( argv[1] );
	}

	// prepare PRNG
	gen.seed( time( NULL ) );

	std::vector<sPoint> Points = GeneratePoissonPoints( MinDistance, k, NumPoints );

	// prepare BGR image
	cv::Mat	Img(cv::Size(ImageSize,ImageSize),CV_8UC1);
	Img.setTo(0);

	for ( auto i = Points.begin(); i != Points.end(); i++ )
	{
		int x = int( i->x * ImageSize );
		int y = int( i->y * ImageSize );
		if ( g_DensityMap )
		{
			// dice
			float R = RandomFloat();
			float P = g_DensityMap[ x + y * ImageSize ];
			if ( R > P ) continue;
		}
		Img.ptr<uchar>(y)[x]	=	255;
	}
	cv::imwrite("Poisson.bmp",Img);

	return 0;
}
Example #26
0
void BrowCtx::zoom( double factor)
{ 
  if ( fabs(factor) < DBL_EPSILON)
    return;

  mw.zoom_factor_x *= factor;
  mw.zoom_factor_y *= factor;
  if ( mw.offset_x != 0)
    mw.offset_x = int( (mw.offset_x - mw.window_width / 2.0 * ( 1.0/factor - 1)) 
		* factor);
  if ( mw.offset_y != 0)
    mw.offset_y = int( (mw.offset_y  - mw.window_height / 2.0 * ( 1.0/factor - 1)) 
		* factor);
  mw.offset_x = max( mw.offset_x, 0);
  mw.offset_y = max( mw.offset_y, 0);
  if ( (x_right - x_left) * mw.zoom_factor_x <= mw.window_width)
    mw.offset_x = 0;
  if ( (y_high - y_low) * mw.zoom_factor_y <= mw.window_height)
    mw.offset_y = 0;
  a.zoom();
  clear( &mw);
  draw( &mw, 0, 0, mw.window_width, mw.window_height);
  nav_zoom();
  change_scrollbar();
}
Example #27
0
/*!
  Change one key pattern

  \param pattern Index of the pattern
  \param key Key
  \param state State

  \sa QKeyEvent
*/
void QwtEventPattern::setKeyPattern(uint pattern, int key, int state)
{
    if ( pattern < (uint)d_keyPattern.count() ) {
        d_keyPattern[int(pattern)].key = key;
        d_keyPattern[int(pattern)].state = state;
    }
}
Example #28
0
int main(void)
{

	int (*ptr)[2];
	int torf[2][2] = {12, 14, 16};
	ptr = torf;

 	// **ptr = 16
	// **(ptr+1) = 0





	int (*ptr2)[2];
	int fort[2][2] = { {12}, {14,16} };
	ptr2 = fort;

	// **ptr2 = 14
	// **(ptr2+1) = 16


	printf("**ptr is %d and **(ptr+2) is %d\n", **ptr, **(ptr+1));
	printf("**ptr2 is %d and **(ptr2+2) is %d\n", **ptr2, **(ptr2+1));

	return 0;

}
Example #29
0
/* If the directory specified by path does not exist, create it with
 * the given mode. If we fail for any reason, terminate with error.  */
void
mksfsdir (str path, mode_t mode, struct stat *sbp, uid_t uid)
{
  assert (path[0] == '/');

  mode_t m = umask (0);
  struct stat sb;
  if (stat (path, &sb) < 0) {
    if (errno != ENOENT || (mkdir (path, mode) < 0 && errno != EEXIST))
      fatal ("%s: %m\n", path.cstr ());
    if (chown (path, uid, sfs_gid) < 0) {
      int saved_errno = errno;
      rmdir (path);
      fatal ("chown (%s): %s\n", path.cstr (), strerror (saved_errno));
    }
    if (stat (path, &sb) < 0)
      fatal ("stat (%s): %m\n", path.cstr ());
  }
  umask (m);

  if (!S_ISDIR (sb.st_mode))
    fatal ("%s: not a directory\n", path.cstr ());
  if (sb.st_uid != uid)
    fwarn << path << ": owned by uid " << sb.st_uid
	  << ", should be uid " << uid << "\n";
  if (sb.st_gid != sfs_gid)
    fwarn << path << ": has gid " << sb.st_gid
	  << ", should be gid " << sfs_gid << "\n";
  if (sb.st_mode & 07777 & ~mode)
    fwarn ("%s: mode 0%o, should be 0%o\n",
	   path.cstr (), int (sb.st_mode & 07777), int (mode));

  if (sbp)
    *sbp = sb;
}
Example #30
0
void MainWindow::populateScene()
{
    scene = new QGraphicsScene;

    QImage image(":/qt4logo.png");

    // Populate scene
    int xx = 0;
    int nitems = 0;
    for (int i = -11000; i < 11000; i += 110) {
        ++xx;
        int yy = 0;
        for (int j = -7000; j < 7000; j += 70) {
            ++yy;
            qreal x = (i + 11000) / 22000.0;
            qreal y = (j + 7000) / 14000.0;

            QColor color(image.pixel(int(image.width() * x), int(image.height() * y)));
            QGraphicsItem *item = new Chip(color, xx, yy);
            item->setPos(QPointF(i, j));
            scene->addItem(item);

            ++nitems;
        }
    }
}