Ejemplo n.º 1
0
		void insertEntryInLine    (std::size_t line, std::size_t index, double value)
		{
			// Inserts an entry at (line, index) if possible
			if (line < size() && index < lineSize(line))
			{
				contents.at(line).insert(contents.at(line).begin() + index, value);
			}
		}
Ejemplo n.º 2
0
		void removeEntry          (std::size_t line, std::size_t index)
		{
			// Removes an entry from the file if it exists
			if (line < size() && index < lineSize(line))
			{
				contents.at(line).erase(contents.at(line).begin() + index);
			}
		}
Ejemplo n.º 3
0
		void setEntry             (std::size_t line, std::size_t index, double value)
		{
			// Sets the entry located at (line, index) to value
			if (line < size() && index < lineSize(line))
			{
				contents.at(line).at(index) = value;
			}
		}
Ejemplo n.º 4
0
		void removeEntries        (std::size_t line, std::size_t lowerBound, std::size_t upperBound)
		{
			// Removes the entries at locations [lowerBound, upperBound] in the line-th line in the file
			if (line < size())
			{
				FWPF::validateBounds(lowerBound, upperBound);
				if (lowerBound < lineSize(line))
				{
					if (upperBound < lineSize(line))
					{
						contents.at(line).erase(contents.at(line).begin() + lowerBound, contents.at(line).begin() + 1 + upperBound);
					}
					else
					{
						contents.at(line).erase(contents.at(line).begin() + lowerBound, contents.at(line).begin() + lineSize(line));
					}
				}
			}
		}
Ejemplo n.º 5
0
		std::string                            getLineAsString         (std::size_t line) const
		{
			// Returns a line in the file as a string
			if (line < size())
			{
				std::string result;
				std::stringstream stream;
				for (unsigned int i = 0; i < lineSize(line) - 1; ++i)
				{
					stream << contents.at(line).at(i) << " ";
				}
				if (lineSize(line))
				{
					stream << contents.at(line).at(lineSize(line) - 1);
				};
				std::getline(stream, result);
				return result;
			}
			return "";
		}
Ejemplo n.º 6
0
Archivo: filters.c Proyecto: mtqp/xorga
void cRoberts( const unsigned char* src, unsigned char *dst, int width, int height, int xorder, int yorder ) {
	int x, y, k;
	int line = lineSize(width,4);

	for( y = 0 ; y < height-1 ; y++ )
		for( x = 0 ; x < width-1 ; x++ ) {
			k =xorder * apply_mask( &src[line*(y-1)+x-1], line, OPERADOR_ROBERTS_X, 2 );
			k+=yorder * apply_mask( &src[line*(y-1)+x-1], line, OPERADOR_ROBERTS_Y, 2 );
			dst[line*y+x]=toCharS(k);
		}
}
Ejemplo n.º 7
0
Archivo: filters.c Proyecto: mtqp/xorga
void cPrewitt( const unsigned char* src, unsigned char *dst, int width, int height, int xorder, int yorder ) {
	int x, y, k;
	int line = lineSize(width,4);

	for( y = 1 ; y < height-1 ; y++ )
		for( x = 1 ; x < width-1 ; x++ ) {
			k =xorder * apply_mask( &src[line*(y-1)+x-1], line, OPERADOR_PREWITT_X, 3 );
			k+=yorder * apply_mask( &src[line*(y-1)+x-1], line, OPERADOR_PREWITT_Y, 3 );
			dst[line*y+x]=toCharS(k);
		}
}
Ejemplo n.º 8
0
		void removeEntryInLines   (std::size_t index, std::size_t lowerBound, std::size_t upperBound)
		{
			// Removes the index-th entry in the lines [lowerBound, upperBound]
			FWPF::validateBounds(lowerBound, upperBound);
			for (unsigned int i = lowerBound; i < size() && i <= upperBound; ++i)
			{
				if (index < lineSize(i))
				{
					contents.at(i).erase(contents.at(i).begin() + index);
				}
			}
		}
Ejemplo n.º 9
0
Archivo: filters.c Proyecto: mtqp/xorga
/**
 * cX - procesa la imagen con el operador X
 *		src	array de pixels ordenados (grayscale)
 *		dst	array de pixels final
 *		width	ancho (en pixels) de la imagen
 *		height	alto (en pixels) de la imagen
 *		xorder	orden de la derivada x
 *		yorder	orden de la derivada y
 */
void cSobel( const unsigned char* src, unsigned char *dst, int width, int height, int xorder, int yorder ) {
	int x, y, k;
	int line = lineSize(width,4);

	for( y = 1 ; y < height-1 ; y++ )
		for( x = 1 ; x < width-1 ; x++ ) {
			k=0;
			if( xorder != 0 )
				k =toCharS(apply_mask( &src[line*(y-1)+x-1], line, OPERADOR_SOBEL_X, 3 ));
			if( yorder != 0 )
				k+=toCharS(apply_mask( &src[line*(y-1)+x-1], line, OPERADOR_SOBEL_Y, 3 ));
			dst[line*y+x]=toCharS(k);
		}
}
Ejemplo n.º 10
0
FloatRect RunResolver::Run::rect() const
{
    auto& run = m_iterator.simpleRun();
    auto& resolver = m_iterator.resolver();
    float baseline = computeBaselinePosition();
    FloatPoint position = linePosition(run.logicalLeft, baseline - resolver.m_ascent);
    FloatSize size = lineSize(run.logicalLeft, run.logicalRight, resolver.m_ascent + resolver.m_descent + resolver.m_visualOverflowOffset);
    bool moveLineBreakToBaseline = false;
    if (run.start == run.end && m_iterator != resolver.begin() && m_iterator.inQuirksMode()) {
        auto previousRun = m_iterator;
        --previousRun;
        moveLineBreakToBaseline = !previousRun.simpleRun().isEndOfLine;
    }
    if (moveLineBreakToBaseline)
        return FloatRect(FloatPoint(position.x(), baseline), FloatSize(size.width(), std::max<float>(0, resolver.m_ascent - resolver.m_baseline.toFloat())));
    return FloatRect(position, size);
}
Ejemplo n.º 11
0
		void removeEmptyLines     ()
		{
			std::size_t begin = 0;
			std::size_t end = size();
			while (begin < end)
			{
				if (lineSize(begin) == 0)
				{
					contents.erase(contents.begin() + begin);
					--end;
				}
				else
				{
					++begin;
				}
			}
		}
Ejemplo n.º 12
0
/**
* Places the dialog items according to the current visible window position.
* When hiding items, uses SetExtent() instead of just SetPosition() in order to call
* SizeChanged() of the moved item. For example, this is needed for the editor to
* change its cursor accordingly.
*
* @param aRect Rectangle of the form window
* @param aTop Number of items above the window
* @param aMiddle Number of items inside the window
* @param aBottom Number of items below the window
*
* Parameter value equal to -1 means that the parameter is not defined and will be
* calculated automatically. Normally, either the top number or the bottom one
* is only defined. If @a aTop is defined, the items will be placed from top downwards, leaving
* @a aTop items above the window. If @a aBottom is defined, the items will be placed from bottom
* upwards, leaving @a aBottom items below the window.
*
* This function panics, if neither @a aTop nor @a aBottom are defined.
*
* The function first checks if the provided @a aTop and @a aBottom are consistent with
* the item sizes and the given window rectangle. If they are not, they will be
* corrected. Usually, @a aTop and @a aBottom come out of sync with the item sizes
* after the dynamic layout change.
*/
void CEikCapCArray::SetRect(const TRect& aRect, TInt aTop, TInt /*aMiddle*/, TInt aBottom)
{
    TAknLayoutRect formtLayoutRect;
    formtLayoutRect.LayoutRect(aRect, AknLayoutScalable_Avkon::listscroll_form_pane().LayoutLine());
    formtLayoutRect.LayoutRect(formtLayoutRect.Rect(), AknLayoutScalable_Avkon::list_form_gen_pane().LayoutLine());
    TRect formRect = formtLayoutRect.Rect();

    CEikCapCArrayExtension *extension_or_null = ExtensionOrNull();
    if (extension_or_null)
    {
        extension_or_null->iRect = formRect;
    }

    // controls need to be placed in real locations if physics is enabled
    if ( Count() > 0 )
    {
        CEikCaptionedControl* control = (*this)[0];

        if ( control->DialogPage()->IsForm() )
        {
            SetRealRect( aRect, aTop, aBottom );
            return;
        }
    }

    TBool topDefined = EFalse;   // top or bottom number defined?
    if( aTop > -1 )
    {
        topDefined = ETrue;
    }
    else if( aBottom > -1 )
    {
        topDefined = EFalse;
    }
    else    // aBottom == aTop == -1
    {
        User::Panic( _L("CEikCapCArray::SetRect(): Neither top nor bottom items number defined"), EAknPanicInvalidValue );
    }
    const TInt count = Count();
    const TInt rectHeight = aRect.Height();
    /**
    * Special invisible points are used for placing the items that are
    * outside the window. CCoeControl's invisible flag cannot be used,
    * as it is controlled by third-party applications.
    */
    const TPoint topInvisPoint( -10000, -10000 );
    const TPoint bottomInvisPoint( 10000, 10000 );

    CEikCaptionedControl *firstCapCC = count > 0 ? (*this)[0] : NULL;
    if( firstCapCC && firstCapCC->iIsFormControl )  // Forms
    {
        CEikCaptionedControl *selectedLine( NULL );
        if( firstCapCC->DialogPage())
            selectedLine = firstCapCC->DialogPage()->CurrentLine();

        // Check height of items and the input parameters aTop and aBottom.
        TInt rest = 0;  // number of the rest items without aTop or aBottom
        TInt index = 0;
        if( topDefined )
        {
            rest = count - aTop;
            index = aTop;
        }
        else
        {
            rest = count - aBottom;
            index = rest - 1;
        }
        TInt height = 0;
        for( TInt ii = 0; ii < rest; ii++ )
        {
            CEikCaptionedControl* line = (*this)[index];
            height += line->MinimumSize().iHeight;  // Use MinimumSize() here as a protection from dynamic layout change
            if( height >= rectHeight )
                break;  // Input params are OK
            topDefined? index++ : index--;
        }
        /**
        * If the window contains too few items inside and there are still items outside,
        * correct the input parameters @a aTop and @a aBottom to fill up the window.
        */
        if( height < rectHeight )
        {
            if( topDefined && aTop > 0 )    // For top-down placement and there are items above the window
            {
                // Calculate height of controls above the window also
                for( TInt ii = 0; ii < aTop; ii++ )
                {
                    CEikCaptionedControl* line = (*this)[ii];
                    height += line->MinimumSize().iHeight;
                    if( height >= rectHeight )  // All items don't fit to the window anyway
                    {
                        topDefined = EFalse;   // Reverse direction to bottom-up
                        aBottom = 0;
                        break;
                    }
                }
                if( height < rectHeight )  // All items fit to the window
                {
                    aTop = 0; // Just place them from the first item
                }
            }
            else if( !topDefined )  // For bottom-up placement
            {
                topDefined = ETrue;   // Reverse direction to top-down
                aTop = 0;
            }
        }

        // Hiding items that are explicitly defined to be outside the window
        TInt start;
        TInt end;
        TPoint invisPoint;    // current invisible point, depends on placement direction
        if( topDefined )
        {
            start = 0;
            end = aTop;
            invisPoint = topInvisPoint;
        }
        else
        {
            start = count - aBottom;
            end = count;
            invisPoint = bottomInvisPoint;
        }
        for( TInt ii = start; ii < end; ii++ )
        {
            CEikCaptionedControl* line = (*this)[ii];
            line->SetPosition( invisPoint );
        }

        // Setting rects for the rest of the items
        if( topDefined )
        {
            rest = count - aTop;
            invisPoint = bottomInvisPoint;
            index = aTop;
        }
        else
        {
            rest = count - aBottom;
            invisPoint = topInvisPoint;
            index = rest - 1;
        }
        TInt reservedHeight = 0; // in pixels
        TBool insideWindow = ETrue; // The current item is still inside the window
        TInt topY = 0;


        for( TInt ii = 0; ii < rest; ii++ )
        {
            CEikCaptionedControl* line = (*this)[index];
            TSize lineSize( line->Size() );
            if( insideWindow )
            {
                ResetHides( line );
                if( topDefined )
                {   // Top-down placement
                    topY = aRect.iTl.iY + reservedHeight;
                }
                else
                {   // Bottom-up placement
                    topY = aRect.iBr.iY - reservedHeight - lineSize.iHeight;
                }
                line->SetExtent( TPoint( formRect.iTl.iX, topY ), lineSize );
                AknsUtils::RegisterControlPosition( line );
                AknsUtils::RegisterControlPosition( line->iCaption );
                AknsUtils::RegisterControlPosition( line->iControl );
                AknsUtils::RegisterControlPosition( line->iTrailer );
                AknsUtils::RegisterControlPosition( line->iBitmap );
                reservedHeight += lineSize.iHeight;
                /**
                * The control at a window edge is considered as partially-visible.
                * Its subcontrols must be checked for visibility individually.
                */
                if( reservedHeight > rectHeight )
                {
                    TInt visibleSubctrls = HideLines( line, aRect );    // Check how many subcontrols stayed visible
                    insideWindow = EFalse;
                    /**
                    * For the bottom-up placement:
                    * if the window contains only an empty "partially-visible" control and a
                    * a selected popup field, make the popup to hang at the top alone.
                    */
                    if( !topDefined && index < count - 1 ) // bottom-up and not last
                    {
                        CEikCaptionedControl* lineBelow = (*this)[index+1];
                        if( visibleSubctrls == 0 && ii == 1 &&
                                IsPopupField( lineBelow ) && lineBelow == selectedLine )
                        {
                            TRect popupRect( lineBelow->Rect() );
                            TInt diff = aRect.iTl.iY - popupRect.iTl.iY; // negative
                            popupRect.Move( 0, diff );
                            lineBelow->SetRect( popupRect );
                        }
                    }
                }
            }
            else
            {
                line->SetPosition( invisPoint );
            }
            topDefined? index++ : index--;
        }
    }
    else    // Dialogs other than forms:
    {
        TRect rect=aRect;
        const TInt fullWidth=rect.iBr.iX-rect.iTl.iX;
        const TInt count=Count();
        const TInt topMargin=iDensePacking ? KAknNoTopMargin : KAknTopMargin;
        const TInt verticalSpacing=iDensePacking ? KVerticalSpacingSquash : KVerticalSpacing;
        rect.iTl.iY+=topMargin;
        TInt deltaHeight=0;
        for (TInt ii=0; ii<count; ++ii)
        {
            CEikCaptionedControl* line=(*this)[ii];
            TSize thisSize=line->MinimumSize();
            TInt thisDeltaHeight=thisSize.iHeight+verticalSpacing;
            if (deltaHeight<thisDeltaHeight)
                deltaHeight=thisDeltaHeight;
            if (!(line->iCaptionWidth))
                thisSize.iWidth=fullWidth;
            else
            {
                CEikCapCArrayExtension *ext = ExtensionOrNull();
                TInt deltaWidth = 0;
                if (ext)
                    deltaWidth = ext->iCaptionWidth-line->iCaptionWidth;
                thisSize.iWidth+=deltaWidth;
                if (ext)
                    line->iCaptionWidth=ext->iCaptionWidth;
                else
                    line->iCaptionWidth = 0;
                line->iMinSize.iWidth+=deltaWidth;
            }
            line->iFullWidth=fullWidth;
            line->SetExtent(rect.iTl,thisSize);
            if (!(line->LatentGroupLineFollows()))
            {
                rect.iTl.iY+=deltaHeight;
                deltaHeight=0;
            }
        }
    }
}
Ejemplo n.º 13
0
gfx::Size Graphics::doUIStringAlgorithm(const std::string& str, gfx::Color fg, gfx::Color bg, const gfx::Rect& rc, int align, bool draw)
{
  gfx::Point pt(0, rc.y);

  if ((align & (JI_MIDDLE | JI_BOTTOM)) != 0) {
    gfx::Size preSize = doUIStringAlgorithm(str, gfx::ColorNone, gfx::ColorNone, rc, 0, false);
    if (align & JI_MIDDLE)
      pt.y = rc.y + rc.h/2 - preSize.h/2;
    else if (align & JI_BOTTOM)
      pt.y = rc.y + rc.h - preSize.h;
  }

  gfx::Size calculatedSize(0, 0);
  size_t beg, end, new_word_beg, old_end;
  std::string line;

  // Draw line-by-line
  for (beg=end=0; end != std::string::npos; ) {
    pt.x = rc.x;

    // Without word-wrap
    if ((align & JI_WORDWRAP) == 0) {
      end = str.find('\n', beg);
    }
    // With word-wrap
    else {
      old_end = std::string::npos;
      for (new_word_beg=beg;;) {
        end = str.find_first_of(" \n", new_word_beg);

        // If we have already a word to print (old_end != npos), and
        // we are out of the available width (rc.w) using the new "end",
        if ((old_end != std::string::npos) &&
            (pt.x+m_font->textLength(str.substr(beg, end-beg).c_str()) > rc.w)) {
          // We go back to the "old_end" and paint from "beg" to "end"
          end = old_end;
          break;
        }
        // If we have more words to print...
        else if (end != std::string::npos) {
          // Force line break, now we have to paint from "beg" to "end"
          if (str[end] == '\n')
            break;

          // White-space, this is a beginning of a new word.
          new_word_beg = end+1;
        }
        // We are in the end of text
        else
          break;

        old_end = end;
      }
    }

    // Get the entire line to be painted
    line = str.substr(beg, end-beg);

    gfx::Size lineSize(
      m_font->textLength(line.c_str()),
      m_font->height());
    calculatedSize.w = MAX(calculatedSize.w, lineSize.w);

    // Render the text
    if (draw) {
      int xout;
      if ((align & JI_CENTER) == JI_CENTER)
        xout = pt.x + rc.w/2 - lineSize.w/2;
      else if ((align & JI_RIGHT) == JI_RIGHT)
        xout = pt.x + rc.w - lineSize.w;
      else
        xout = pt.x;

      drawString(line, fg, bg, gfx::Point(xout, pt.y));

      if (!gfx::is_transparent(bg))
        fillAreaBetweenRects(bg,
          gfx::Rect(rc.x, pt.y, rc.w, lineSize.h),
          gfx::Rect(xout, pt.y, lineSize.w, lineSize.h));
    }

    pt.y += lineSize.h;
    calculatedSize.h += lineSize.h;
    beg = end+1;
  }

  // Fill bottom area
  if (draw && !gfx::is_transparent(bg)) {
    if (pt.y < rc.y+rc.h)
      fillRect(bg, gfx::Rect(rc.x, pt.y, rc.w, rc.y+rc.h-pt.y));
  }

  return calculatedSize;
}
Ejemplo n.º 14
0
 int readLine(char *data, int maxLength)
 {
     return read(data, lineSize(qMin(maxLength, size())));
 }
Ejemplo n.º 15
0
void TwoDOrderParam::SetPositions(input_params& inputPars)
{
	m_x.resize(m_row_number,0);
	m_y.resize(m_row_number,0);

	if(inputPars.runType.compare("Part")==0)
	{
		int counter = 0;
		vector<double> init_x(inputPars.p + inputPars.nx - 1,-1);
		vector<double> init_y(inputPars.p + inputPars.nx - 1,-1);

		vector<int> lineStart(inputPars.p + inputPars.nx - 1,-1);
		vector<int> lineSize(inputPars.p + inputPars.nx - 1,-1);

		// > Set limits
		for(int iii = 0; iii < inputPars.p; ++iii)
		{
			lineStart[iii] = 0;
			init_x[iii] = 0;
			init_y[iii] = (inputPars.p - 1 - iii);
		}
		for(int iii = inputPars.p; iii < inputPars.p + inputPars.nx -1; ++iii)
		{
			lineStart[iii] = (iii - inputPars.p + 1);
			init_x[iii] = (iii - inputPars.p + 1)*sqrt(3)/2;
			init_y[iii] = -(iii - inputPars.p + 1)*0.5;
		}

		for(int iii = 0; iii < inputPars.nx; ++iii)
		{
			lineSize[iii] = (inputPars.ny + iii) - lineStart[iii];
		}
		for(int iii = inputPars.nx; iii < inputPars.p + inputPars.nx - 1; ++iii)
		{
			lineSize[iii] = (inputPars.nx - 1) + inputPars.ny - lineStart[iii];
		}

		for(int iii = 0; iii < inputPars.p + inputPars.nx - 1; ++iii)
		{
			for(int jjj = 0; jjj < lineSize[iii]; ++jjj)
			{
				m_x[counter] = init_x[iii] + jjj*sqrt(3)/2;
				m_y[counter] = init_y[iii] + 0.5*jjj;
				++counter;
			}
		}
	}
//	else if(inputPars.runType.compare("Moessner")==0)
//	{
//		int counter = 0;
//		double init_x = 0;
//		double init_y = 0;
//
//		for(int iii = 0; iii < inputPars.ny; ++iii)
//		{
//			init_x = 0;
//			init_y = inputPars.ny - iii;
//
//			for(int jjj = 0; jjj < inputPars.nx; ++jjj)
//			{
//				m_x[counter] = init_x + jjj*sqrt(3)/2;
//				m_y[counter] = init_y - 0.5*jjj;
//
//				++counter;
//			}
//		}
//	}
	else if(inputPars.runType.compare("Moessner")==0)
	{
		int counter = 0;
		double init_x = 0;
		double init_y = 0;

		for(int jjj = 0; jjj < inputPars.ny; ++jjj)
		{
			init_x = jjj*0.5;
			init_y = jjj*sqrt(3)/2;

			for(int iii = 0; iii < inputPars.nx; ++iii)
			{
				m_x[counter] = init_x + iii;
				m_y[counter] = init_y;
				++counter;
			}
		}
	}
//	else if(inputPars.SimType.compare("Manual")==0)
//	{
//		int counter = 0;
//
//		for(int iii = 0; iii < inputPars.ny/3; ++iii)
//		{
//			// First line
//
//			x = 4*iii*sqrt(3)/2;
//			y = 0;
//
//			for(int jjj = 0; jjj < inputPars.nx/2; ++jjj)
//			{
//				output << x << " " << y;
//				for(int kkk = 0; kkk < m_col_number; ++kkk)
//				{
//					dataPoint = m_mean[counter];
//
//					output << " " << dataPoint;
//					++counter;
//				}
//				output  << endl;
//
//				// Move to next
//				x += sqrt(3)/2;
//				y +=0.5;
//
//				output << x << " " << y;
//				for(int kkk = 0; kkk < m_col_number; ++kkk)
//				{
//					dataPoint = m_mean[counter];
//
//					output << " " << dataPoint;
//					++counter;
//				}
//				output  << endl;
//
//				// Move to the next
//
//				x += 0;
//				y += 1;
//			}
//
//			// Second line
//
//			x = (1 + 4*iii)*sqrt(3)/2;
//			y = -0.5;
//
//			for(int jjj = 0; jjj < inputPars.nx/2; ++jjj)
//			{
//				output << x << " " << y;
//				for(int kkk = 0; kkk < m_col_number; ++kkk)
//				{
//					dataPoint = m_mean[counter];
//
//					output << " " << dataPoint;
//					++counter;
//				}
//				output  << endl;
//
//				// Move to next
//				x += sqrt(3)/2;
//				y +=0.5;
//
//				output << x << " " << y;
//				for(int kkk = 0; kkk < m_col_number; ++kkk)
//				{
//					dataPoint = m_mean[counter];
//
//					output << " " << dataPoint;
//					++counter;
//				}
//				output  << endl;
//
//				// Move to the next
//
//				x += 0;
//				y += 1;
//			}
//
//			// First line
//
//			x = (3 + 4*iii)*sqrt(3)/2;
//			y = -0.5;
//
//			for(int jjj = 0; jjj < inputPars.nx/2; ++jjj)
//			{
//				output << x << " " << y;
//				for(int kkk = 0; kkk < m_col_number; ++kkk)
//				{
//					dataPoint = m_mean[counter];
//
//					output << " " << dataPoint;
//					++counter;
//				}
//				output  << endl;
//
//				// Move to the next
//				x += 0;
//				y += 1;
//
//				output << x << " " << y;
//				for(int kkk = 0; kkk < m_col_number; ++kkk)
//				{
//					dataPoint = m_mean[counter];
//
//					output << " " << dataPoint;
//					++counter;
//				}
//				output  << endl;
//
//				// Move to next
//				x += sqrt(3)/2;
//				y +=0.5;
//			}
//		}
//	}
}
Ejemplo n.º 16
0
		// Accessors
		double                                 getEntry                (std::size_t line, std::size_t index) const
		{
			// Returns the entry at (line, index) if the entry exists, otherwise returns 0
			return (line < size() && index < lineSize(line)) ? contents.at(line).at(index) : 0;
		}
Ejemplo n.º 17
0
 inline bool canReadLine() const
 {
     return lineSize() != -1;
 }