Exemple #1
0
/**
	this method performs a deep copy of the matrix that is passed in as a paramerer.
*/
void Matrix::deepCopy(const Matrix& other){
	//make sure that the current matrix is large enough and has the right dimensions
	resizeTo((int)other.matrix->size1, (int)other.matrix->size2);

	//and now copy the data
	gsl_matrix_memcpy(this->matrix, other.matrix);
}
Exemple #2
0
void MediaJack::layoutChanged(
	int32 layout)
{
	D_METHOD(("MediaJack::layoutChanged\n"));
	resizeTo(M_DEFAULT_WIDTH, M_DEFAULT_HEIGHT);
	_updateBitmap();
}
Exemple #3
0
void VideoFrame::mouseMoveEvent(QMouseEvent *AEvent)
{
	static const QSize cornerSize = QSize(10,10);

	if (FPressedPos.isNull() || FCollapsed)
	{
		FCursorCorner = -1;
		for (int i=0; FCursorCorner<0 && i<4; i++)
			if ((Corners[i].align & FAlignment)==0 && QStyle::alignedRect(Qt::LeftToRight,Corners[i].align,cornerSize,rect()).contains(AEvent->pos()))
				FCursorCorner = i;

		if (FCollapsed)
			setCursor(Qt::ArrowCursor);
		else if (FResizeEnabled && FCursorCorner>=0)
			setCursor(Corners[FCursorCorner].cursor);
		else if (FMoveEnabled)
			setCursor(Qt::OpenHandCursor);
	}
	else if (FResizeEnabled && FCursorCorner>=0)
	{
		FMoved = true;
		emit resizeTo((Qt::Corner)FCursorCorner,mapToParent(AEvent->pos()));
	}
	else if (FMoveEnabled && FMoved)
	{
		emit moveTo(mapToParent(AEvent->pos())-FPressedPos);
	}
	else if ((FGlobalPressed-AEvent->globalPos()).manhattanLength()>=qApp->startDragDistance())
	{
		FMoved = true;
	}

	QFrame::mouseMoveEvent(AEvent);
}
/**
	This method sets the current vector to be equal to one of the products: A * b or A'*b.
	The value of transA indicates if A is transposed or not
*/
void Vector::setToProductOf(const Matrix& A, const Matrix& B, bool transA, bool transB){
	Matrix::setToProductOf(A, B, transA, transB);
	if (this->matrix->size2 != 1){
		resizeTo((int)this->matrix->size1, 1);
		throwError("Matrix product did not result in a vector!");
	}
}
Exemple #5
0
int main(int argc, char ** argv) {

    if (argc != 2) {
      printf("usage: %s imageFile.jpg\n", argv[0]);
      exit(0);
    }

    struct timeval tv;
    gettimeofday(&tv, NULL);
    long startSec = tv.tv_sec;
    long startUsec = tv.tv_usec;
 
    IplImage * frame = cvLoadImage(argv[1], 1);
    IplImage * resized = resizeTo(frame, 320, 240);
    CvMat * grayImage = toGrayImage(resized);
    CvMat * edgeImage = toEdgeImage(grayImage);


    detectError(resized, grayImage, edgeImage, 100, 800, 0);

    gettimeofday(&tv, NULL);

    printf("use %ld seconds and %ld microseconds\n", tv.tv_sec - startSec, tv.tv_usec - startUsec);
 
    while (1) {
        cvShowImage("Image", resized);
        cvWaitKey(30);
    }
}
Exemple #6
0
void VCFrame::mouseMoveEvent(QMouseEvent* e)
{
  if (_app->mode() == App::Design)
    {
      if (m_resizeMode == true)
	{	  
	  QPoint p(QCursor::pos());
	  resizeTo(mapFromGlobal(p));
	  _app->doc()->setModified(true);
	}
      else if (e->state() & LeftButton || e->state() & MidButton)
	{
	  QPoint p(parentWidget()->mapFromGlobal(QCursor::pos()));
	  p.setX(p.x() - m_mousePressPoint.x());
	  p.setY(p.y() - m_mousePressPoint.y());
		
	  moveTo(p);
	  _app->doc()->setModified(true);
	}
    }
  else
    {
      QFrame::mouseMoveEvent(e);
    }
}
void
CQIllustratorShape::
setBBox(const CBBox2D &bbox)
{
  checkoutShape(CQIllustratorData::ChangeType::GEOMETRY);

  moveTo(bbox.getLL());

  resizeTo(bbox.getWidth(), bbox.getHeight());

  checkinShape(CQIllustratorData::ChangeType::GEOMETRY);
}
PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
{
    m_window = initEcoreEvas();

    m_view = EWKViewCreate(contextRef, pageGroupRef, ecore_evas_get(m_window), /* smart */ 0);

    WKRetainPtr<WKStringRef> wkTheme = adoptWK(WKStringCreateWithUTF8CString(TEST_THEME_DIR "/default.edj"));
    WKViewSetThemePath(EWKViewGetWKView(m_view), wkTheme.get());

    evas_object_smart_callback_add(m_view, "webprocess,crashed", onWebProcessCrashed, 0);
    resizeTo(600, 800);
}
void TiledMapLayer::loadFrom(PACKFILE *file, TileRepository *tileRepository)
{
	ASSERT(file);

	// Load the map header
	int w = pack_igetw(file);
	int h = pack_igetw(file);
	resizeTo(w, h);

	// Load the tile data
	for (int y = 0; y < mapHeight; y++)
		for (int x = 0; x < mapWidth; x++)
			getTile(Point(x,y))->loadFrom(file, tileRepository);
}
Exemple #10
0
/**
	this method sets the current matrix to a 3x3 matrix that is equal to the outer product of the vectors a and b
*/
void Matrix::setToOuterproduct(const Vector3d& a, const Vector3d& b){
	resizeTo(3,3);
	MATRIX_AT(this->matrix, 0, 0) = a.x * b.x;
	MATRIX_AT(this->matrix, 0, 1) = a.x * b.y;
	MATRIX_AT(this->matrix, 0, 2) = a.x * b.z;

	MATRIX_AT(this->matrix, 1, 0) = a.y * b.x;
	MATRIX_AT(this->matrix, 1, 1) = a.y * b.y;
	MATRIX_AT(this->matrix, 1, 2) = a.y * b.z;

	MATRIX_AT(this->matrix, 2, 0) = a.z * b.x;
	MATRIX_AT(this->matrix, 2, 1) = a.z * b.y;
	MATRIX_AT(this->matrix, 2, 2) = a.z * b.z;
}
Exemple #11
0
void Column::Private::replaceTexts(int first, const QStringList& new_values)
{
    if (d_data_type != SciDAVis::TypeQString) return;

    emit d_owner->dataAboutToChange(d_owner);
    int num_rows = new_values.size();
    if (first+1-rowCount() > 1)
        d_validity.setValue(Interval<int>(rowCount(), first-1), true);
    if (first + num_rows > rowCount())
        resizeTo(first + num_rows);

    for(int i=0; i<num_rows; i++)
        static_cast< QStringList* >(d_data)->replace(first+i, new_values.at(i));
    d_validity.setValue(Interval<int>(first, first+num_rows-1), false);
    emit d_owner->dataChanged(d_owner);
}
Exemple #12
0
void Column::Private::setDateTimeAt(int row, const QDateTime& new_value)
{
    if (d_data_type != SciDAVis::TypeQDateTime) return;

    emit d_owner->dataAboutToChange(d_owner);
    if (row >= rowCount())
    {
        if (row+1-rowCount() > 1) // we are adding more than one row in resizeTo()
            d_validity.setValue(Interval<int>(rowCount(), row-1), true);
        resizeTo(row+1);
    }

    static_cast< QList<QDateTime>* >(d_data)->replace(row, new_value);
    d_validity.setValue(Interval<int>(row, row), !new_value.isValid());
    emit d_owner->dataChanged(d_owner);
}
Exemple #13
0
bool ofPixels_<PixelType>::resize(int dstWidth, int dstHeight, ofInterpolationMethod interpMethod){

	if ((dstWidth<=0) || (dstHeight<=0) || !(isAllocated())) return false;

	ofPixels_<PixelType> dstPixels;
	dstPixels.allocate(dstWidth, dstHeight,getImageType());

	if(!resizeTo(dstPixels,interpMethod)) return false;

	delete [] pixels;
	pixels = dstPixels.getPixels();
	width  = dstWidth;
	height = dstHeight;
	dstPixels.pixelsOwner = false;
	return true;
}
Exemple #14
0
void Column::Private::setValueAt(int row, double new_value)
{
    if (d_data_type != SciDAVis::TypeDouble) return;

    emit d_owner->dataAboutToChange(d_owner);
    if (row >= rowCount())
    {
        if (row+1-rowCount() > 1) // we are adding more than one row in resizeTo()
            d_validity.setValue(Interval<int>(rowCount(), row-1), true);
        resizeTo(row+1);
    }

    static_cast< QVector<double>* >(d_data)->replace(row, new_value);
    d_validity.setValue(Interval<int>(row, row), false);
    emit d_owner->dataChanged(d_owner);
}
bool ofPixels_<PixelType>::resize(size_t dstWidth, size_t dstHeight, ofInterpolationMethod interpMethod){

	if ((dstWidth == 0) || (dstHeight == 0) || !(isAllocated())) return false;

	ofPixels_<PixelType> dstPixels;
	dstPixels.allocate(dstWidth, dstHeight, getPixelFormat());

	if(!resizeTo(dstPixels,interpMethod)) return false;

	delete [] pixels;
	pixels = dstPixels.getData();
	width  = dstWidth;
	height = dstHeight;
	pixelsSize = dstPixels.size();
	dstPixels.pixelsOwner = false;
	return true;
}
Exemple #16
0
void Column::Private::replaceValues(int first, const QVector<qreal>& new_values)
{
    if (d_data_type != SciDAVis::TypeDouble) return;

    emit d_owner->dataAboutToChange(d_owner);
    int num_rows = new_values.size();
    if (first+1-rowCount() > 1)
        d_validity.setValue(Interval<int>(rowCount(), first-1), true);
    if (first + num_rows > rowCount())
        resizeTo(first + num_rows);

    double * ptr = static_cast< QVector<double>* >(d_data)->data();
    for(int i=0; i<num_rows; i++)
        ptr[first+i] = new_values.at(i);
    d_validity.setValue(Interval<int>(first, first+num_rows-1), false);
    emit d_owner->dataChanged(d_owner);
}
Exemple #17
0
void Column::Private::replaceDateTimes(int first, const QList<QDateTime>& new_values)
{
    if (d_data_type != SciDAVis::TypeQDateTime) return;

    emit d_owner->dataAboutToChange(d_owner);
    int num_rows = new_values.size();
    if (first+1-rowCount() > 1)
        d_validity.setValue(Interval<int>(rowCount(), first-1), true);
    if (first + num_rows > rowCount())
        resizeTo(first + num_rows);

    for(int i=0; i<num_rows; i++) {
        static_cast< QList<QDateTime>* >(d_data)->replace(first+i, new_values.at(i));
        d_validity.setValue(i, !new_values.at(i).isValid());
    }
    emit d_owner->dataChanged(d_owner);
}
Exemple #18
0
bool algot::HashTable::add(std::string str){
  unsigned int hashNum = useHash(str, tableSize);
  algot::DLL<std::string>* list = table + hashNum;
  if(list->isEmpty()){
    usedCells++;
  }
  else if(list->get(str)){
    return false;
  }
  list->add(str);
  if(loadFactor() > 0.75){
    resizeTo((tableSize-1)*2 + 1); 
    //The plus one is to avoid the tableSize being a direct power of two all the time.
  }

  return true;
}
Exemple #19
0
PlatformWebView::PlatformWebView(WKContextRef context, WKPageGroupRef pageGroup, WKPageRef /* relatedPage */, WKDictionaryRef options)
    : m_options(options)
{
    WKRetainPtr<WKStringRef> useFixedLayoutKey(AdoptWK, WKStringCreateWithUTF8CString("UseFixedLayout"));
    m_usingFixedLayout = options ? WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(options, useFixedLayoutKey.get()))) : false;

    m_window = initEcoreEvas();

    m_view = EWKViewCreate(context, pageGroup, ecore_evas_get(m_window), /* smart */ 0);

    WKPageSetUseFixedLayout(WKViewGetPage(EWKViewGetWKView(m_view)), m_usingFixedLayout);

    if (m_usingFixedLayout)
        resizeTo(800, 600);

    ewk_view_theme_set(m_view, TEST_THEME_DIR "/default.edj");
    m_windowIsKey = false;
    evas_object_show(m_view);
}
Exemple #20
0
PlatformWebView::PlatformWebView(WKPageConfigurationRef configuration, const TestOptions& options)
    : m_options(options)
{
    WKRetainPtr<WKStringRef> useFixedLayoutKey(AdoptWK, WKStringCreateWithUTF8CString("UseFixedLayout"));
    m_usingFixedLayout = options.useFixedLayout;

    m_window = initEcoreEvas();

    WKContextRef context = WKPageConfigurationGetContext(configuration);
    m_view = EWKViewCreate(context, configuration, ecore_evas_get(m_window), /* smart */ 0);

    WKPageSetUseFixedLayout(WKViewGetPage(EWKViewGetWKView(m_view)), m_usingFixedLayout);

    if (m_usingFixedLayout)
        resizeTo(800, 600);

    ewk_view_theme_set(m_view, DEFAULT_THEME_DIR "/default.edj");
    m_windowIsKey = false;
    evas_object_show(m_view);
}
Exemple #21
0
void VCDockSlider::mouseMoveEvent(QMouseEvent* e)
{
  if (_app->mode() == App::Design && m_static == false)
    {
      if (m_resizeMode == true)
	{	  
	  QPoint p(QCursor::pos());
	  resizeTo(mapFromGlobal(p));
	  _app->doc()->setModified(true);
	}
      else if (e->state() & LeftButton || e->state() & MidButton)
	{
	  QPoint p(QCursor::pos());
	  moveTo(parentWidget()->mapFromGlobal(p));
	  _app->doc()->setModified(true);
	}
    }
  else
    {
      QFrame::mouseMoveEvent(e);
    }
}
Exemple #22
0
bool Column::Private::copy(const Private * other)
{
    if (other->dataType() != dataType()) return false;
    int num_rows = other->rowCount();

    emit d_owner->dataAboutToChange(d_owner);
    resizeTo(num_rows);

    // copy the data
    switch(d_data_type)
    {
    case SciDAVis::TypeDouble:
    {
        double * ptr = static_cast< QVector<double>* >(d_data)->data();
        for(int i=0; i<num_rows; i++)
            ptr[i] = other->valueAt(i);
        break;
    }
    case SciDAVis::TypeQString:
    {
        for(int i=0; i<num_rows; i++)
            static_cast< QStringList* >(d_data)->replace(i, other->textAt(i));
        break;
    }
    case SciDAVis::TypeQDateTime:
    {
        for(int i=0; i<num_rows; i++)
            static_cast< QList<QDateTime>* >(d_data)->replace(i, other->dateTimeAt(i));
        break;
    }
    }
    // copy the validity information
    d_validity = other->invalidIntervals();

    emit d_owner->dataChanged(d_owner);

    return true;
}
Exemple #23
0
bool Column::Private::copy(const Private * source, int source_start, int dest_start, int num_rows)
{
    if (source->dataType() != dataType()) return false;
    if (num_rows == 0) return true;

    emit d_owner->dataAboutToChange(d_owner);
    if (dest_start+1-rowCount() > 1)
        d_validity.setValue(Interval<int>(rowCount(), dest_start-1), true);
    if (dest_start + num_rows > rowCount())
        resizeTo(dest_start + num_rows);

    // copy the data
    switch(d_data_type)
    {
    case SciDAVis::TypeDouble:
    {
        double * ptr = static_cast< QVector<double>* >(d_data)->data();
        for(int i=0; i<num_rows; i++)
            ptr[dest_start+i] = source->valueAt(source_start + i);
        break;
    }
    case SciDAVis::TypeQString:
        for(int i=0; i<num_rows; i++)
            static_cast< QStringList* >(d_data)->replace(dest_start+i, source->textAt(source_start + i));
        break;
    case SciDAVis::TypeQDateTime:
        for(int i=0; i<num_rows; i++)
            static_cast< QList<QDateTime>* >(d_data)->replace(dest_start+i, source->dateTimeAt(source_start + i));
        break;
    }
    // copy the validity information
    for(int i=0; i<num_rows; i++)
        d_validity.setValue(dest_start+i, source->isInvalid(source_start+i));

    emit d_owner->dataChanged(d_owner);

    return true;
}
Exemple #24
0
/**
	This method	sets the current matrix	to be equal	to one of the products:	a *	b, a'*b, a*b' or a'*b'.
	The	values of transA and transB	indicate which of the matrices are tranposed and which ones	are	not.

	NOTE: the matrices a and b should have no elements in common to the current matrix, otherwise the
	result is unpredictable.

*/
void Matrix::setToProductOf(const Matrix& a, const Matrix& b, bool transA, bool	transB){
	//we'll use the blas subroutine for this
	CBLAS_TRANSPOSE_t TransA = (transA) ? (CblasTrans):(CblasNoTrans);
	CBLAS_TRANSPOSE_t TransB = (transB) ? (CblasTrans):(CblasNoTrans);

	const size_t M = this->matrix->size1;
	const size_t N = this->matrix->size2;
	const size_t MA = (!transA) ? a.matrix->size1 : a.matrix->size2;
	const size_t NA = (!transA) ? a.matrix->size2 : a.matrix->size1;
	const size_t MB = (!transB) ? b.matrix->size1 : b.matrix->size2;
	const size_t NB = (!transB) ? b.matrix->size2 : b.matrix->size1;

	//we might be able to perform the multiplication inplace if: 
	//	- the current matrix has the correct dimensions
	//	- the current matrix is different than both a and b
	//	- NOTE: if either a or b is a shallow copy of a then the results are unpredictable
	if (this->matrix != a.matrix && this->matrix != b.matrix){
		//if the current matrix already has the correct dimension, proceed right away
		if (M == MA && N == NB && NA == MB){   /* [MxN] = [MAxNA][MBxNB] */
			gsl_blas_dgemm(TransA, TransB, 1.0, a.matrix, b.matrix, 0.0, this->matrix);
			return;
		}
		//we'll resize the current matrix and then proceede
		resizeTo((int)MA, (int)NB);
		gsl_blas_dgemm(TransA, TransB, 1.0, a.matrix, b.matrix, 0.0, this->matrix);
		return;
	}
	
	Matrix *c = new Matrix((int)MA, (int)NB);
	//otherwise it means that either a or b is the current matrix, so we'll allocate a new one...
	gsl_blas_dgemm(TransA, TransB, 1.0, a.matrix, b.matrix, 0.0, c->matrix);

	//now copy over the current matrix the result of the multiplication - deep copy
	deepCopy(*c);
	//and now deallocate the matrix c
	delete c;
}
Exemple #25
0
void PlatformWebView::setWindowFrame(WKRect frame)
{
    gtk_window_move(GTK_WINDOW(m_window), frame.origin.x, frame.origin.y);
    resizeTo(frame.size.width, frame.size.height);
}