Ejemplo n.º 1
0
Morpho::Morpho()
{
  // everything is not in use
  // creates predefined masks
  masks = new bool*[NUM_MASK];

  maskSize[0] = 5;
  masks[0] = createMask(5);
  maskSize[1] = 19;
  masks[1] = createMask(19);
  maskSize[2] = 9;
  masks[2] = createMask(9);
}
Ejemplo n.º 2
0
int processBoardGet(char *type)
{
  if( strcmp(type, "vmax") == 0 ) {
    printf("Board VMAX = %f V.\n", caenv6533GetVMAX(board_addr)*1.0);
  } else if ( strcmp(type, "imax") == 0 ) {
    printf("Board IMAX = %d uA.\n", caenv6533GetIMAX(board_addr));
  } else if ( strcmp(type, "status") == 0 ) {
    short int status = caenv6533GetSTATUS(board_addr);

    printf("Board STATUS bits set:\n|| " );
    // Check if on or off
    int i;
    for( i = 0; i < 12; i++ ) {
      //if( ( status & (1 << i)) >> i ) {
      if( status & createMask(i,i) ) {
        printf("%s || ",statusText[i]);
      }
    }
    printf("\n");
  } else if ( strcmp(type, "fwrel") == 0 ) {
    short int fwrel = caenv6533GetFWREL(board_addr);
    short int minor = fwrel & 0xFF;
    short int major = fwrel >> 8;
    printf("Board Firwmare %d.%d\n",major, minor);
  } else if ( strcmp(type, "chnum") == 0 ) {
Ejemplo n.º 3
0
void UBMagnifier::setSize(qreal percentFromScene)
{
    if(gView == NULL || mView == NULL) return;

    // calculate object size
    params.sizePercentFromScene = percentFromScene;
    QSize sceneSize = mView->size();
    qreal size = params.sizePercentFromScene * sceneSize.width() / 100;

    QRect currGeom = geometry();
    if (circular == mDrawingMode)
    {
        if(currGeom.width() == currGeom.height())
        {
            QPoint newPos = mView->mapFromGlobal(updPointMove);
            setGeometry(newPos.x() - size / 2, newPos.y() - size / 2, size, size);
        }
        else
            setGeometry(0, 0, size, size);
    }
    else if (rectangular == mDrawingMode)
    {
        QPoint newPos = mView->mapFromGlobal(updPointMove);
        setGeometry(newPos.x() - size / 2, newPos.y() - size / 2 / 3, size, size/3);
    }

    calculateButtonsPositions();
    createMask();

}
Ejemplo n.º 4
0
// PRE: tokens points to the first string argument of operand2
uint32_t handleOperand2(char **tokens, bool *imm) {
    if (tokens[0][0] == '#') {
        *imm = true;
        uint32_t value = getValue(tokens[0]);
        if (value > MAX_MOV_CONSTANT) {
            int lastOnePos = getLastOnePos(value);
            //round lastOnePos down to the nearest multiple of 2.
            lastOnePos &= createMask(1, (sizeof(int) * 8 - 1));
            uint32_t shiftedValue = binaryShift(value, ROR, lastOnePos)
                    .result;
            if (shiftedValue > MAX_MOV_CONSTANT) {
                fprintf(stderr, "cannot fit value into operand2");
                exit(EXIT_FAILURE);
            }

            return ((INTWIDTH - lastOnePos) / 2) << 8 | shiftedValue;

        } else {
            return value;
        }

    } else if (tokens[0][0] == 'r') {
        uint32_t Rm = getValue(tokens[0]);
        uint32_t shift = generateShift(&tokens[1]);
        return shift << REG_FIELD_LENGTH | Rm;

    } else {
        fputs("Error in tokenHandlers: handleOperand2: invalid operand 2",
                stderr);
        exit(EXIT_FAILURE);
    }
}
Ejemplo n.º 5
0
void UBMagnifier::setDrawingMode(int mode)
{
    mDrawingMode = static_cast<DrawingMode>(mode);

    QString sMode;

    if (circular == mDrawingMode)
    {
        sMode = "roundeRrectangle";
        resize(width(), width());
    }

    if (rectangular == mDrawingMode)
    {
        sMode = "circle";
        resize(width(), height()/3);

        if (mView)
        {
            qreal newPercentSize = size().width()/3 * 100 / mView->width();
            emit magnifierResized_Signal(newPercentSize);
        }
    }

    sChangeModePixmap->load(":/images/"+sMode+".svg");

    calculateButtonsPositions();
    if (mView && gView)
        UBApplication::boardController->controlView()->scene()->moveMagnifier();

    createMask();

    UBSettings::settings()->magnifierDrawingMode->set(mode);
}
Ejemplo n.º 6
0
void HSBackport::initialize() {
	
	createMask();

	// create effect animation mat
	int matW = 0;
	int matH = 0;

	allKeys = LEDController::getInstance()->getKeyPositions();
	vector<CorsairLedPosition>::iterator it = allKeys.begin();
	for (; it != allKeys.end(); ) {
		matW = max(matW, (int)ceil(it->left + it->width));
		matH = max(matH, (int)ceil(it->top + it->height));
		++it;
	}
	
	CorsairLedPosition kPos = LEDController::getInstance()->getKeyPositionById(getKey());
	bCenterPoint = cv::Point((int)floor(kPos.left + kPos.width / 2), (int)floor(kPos.top + kPos.height / 2));
	
	effectMat = Mat4b(matH, matW, CV_8UC4);

	effectColorsMat = ImageFilterMat::loadResourceAsMat(IDB_BACKPORTCOLORS);
	// effectColorsMat = Mat4b(90, 840, Vec4b(255, 125, 0, 255));
		
}
Ejemplo n.º 7
0
QImage YoonEncryptor::encrypt(const QImage &src)
{
    auto result = src;
    if(result.height() > result.width())
        result = result.transformed(QTransform().rotate(90));

    QVector<int> seed = dividers(result.height());
    int **lookUpTable = createLUT(seed);
    QImage tempImage;
    int red,green,blue;
    QColor oldColor;
    for(int r = 0; r < K; r++){
        tempImage = result;
        int **mask = createMask(result.height());
        for(int i = 0; i < result.height(); i++){
            for(int j = 0; j < result.width(); j++){
                oldColor = tempImage.pixelColor(j, i);
                red   = oldColor.red()^mask[lookUpTable[i][j]][j];
                green = oldColor.green()^mask[lookUpTable[i][j]][j];
                blue  = oldColor.blue()^mask[lookUpTable[i][j]][j];
                result.setPixelColor(j, lookUpTable[i][j], QColor(red, green, blue));
            }
        }
        freeMemory(mask, result.height());
    }
    freeMemory(lookUpTable, result.height());

    if(result.height() > result.width())
        result = result.transformed(QTransform().rotate(-90));
    return result;
}
Ejemplo n.º 8
0
RotoRegion::RotoRegion(const PathV& v)
{
    for (PathV::const_iterator c = v.begin(); c != v.end(); ++c)
        _rotoPaths.push_back(*c);
    assert(_rotoPaths.size() > 1);

    _sides.push_back(RR_RIGHT); // we start first curve 0->1
    const RotoPath* last = _rotoPaths.front();
    _rotoPaths.front()->setRegion(this, RR_RIGHT);

    int i = 1;
    PathV::const_iterator c = _rotoPaths.begin();
    ++c; // move one up
    float d0, d1;
    for (; c != _rotoPaths.end(); ++c, ++i)
    {
        const Vec2f endPt = (*c)->getEnd(getLast(i - 1));
        d0 = (*c)->_bez->distanceToEnd2(endPt, 0);
        d1 = (*c)->_bez->distanceToEnd2(endPt, 1);
        if (d0 < d1)
            _sides.push_back(RR_RIGHT);
        else
            _sides.push_back(RR_LEFT);
        (*c)->setRegion(this, _sides[i]);

        last = *c;
    }
    assert(_sides.size() == _rotoPaths.size());

    createMask();
}
Ejemplo n.º 9
0
bool AlertBox::init(Settings* settings)
{
	if ( !Layer::init() )  {
		return false;
	}

	_settings = settings;
	_dead = false;
	_size = Size(1040,648);

	_moved = false;
	_yPosition = 0;

	//create fon
	fon = Sprite::create(PATH_INTERFACE "AlertBox.png");
	this->addChild(fon);

	closeButton = Sprite::create(PATH_INTERFACE "CloseAlertBox.png");
	closeButton->setPosition( Point(520, 324) );
	this->addChild(closeButton);

	_scroll = Layer::create();
	_scroll->setPosition( Point(0, _size.height/2) );
	

	createMask();
	_layerMask->addChild(_scroll);
	this->addChild(_layerMask);

	initTouch();
	return true;
}
Ejemplo n.º 10
0
void OutlierDetector::findOutliers(const cv::Mat &optical_flow_vectors, cv::Mat &outlier_probabilities, bool include_zeros, int pixel_step, bool print)
{
    cv::Mat angle_matrix = cv::Mat::zeros(optical_flow_vectors.rows, optical_flow_vectors.cols, CV_64F);
    cv::Mat magnitude_matrix = cv::Mat::zeros(optical_flow_vectors.rows, optical_flow_vectors.cols, CV_64F);
    outlier_probabilities = cv::Mat::zeros(optical_flow_vectors.rows, optical_flow_vectors.cols, CV_64F);
    
    createAngleMatrix(optical_flow_vectors, angle_matrix, pixel_step);    
    //if (print) std::cout << " Angle matrix " << std::endl << angle_matrix << std::endl;
    createMagnitudeMatrix(optical_flow_vectors, magnitude_matrix, pixel_step);
    //if (print) std::cout << " Magnitude matrix " << std::endl << magnitude_matrix << std::endl;
    if (print ) std::cout << "angles " << std::endl;
    createMask(optical_flow_vectors, angle_matrix, outlier_probabilities, include_zeros, pixel_step, print);
    //if (print) std::cout << " Mask angle " << std::endl << outlier_probabilities << std::endl;
    if (print ) std::cout << "lenghts " << std::endl;
    createMask(optical_flow_vectors, magnitude_matrix, outlier_probabilities, include_zeros, pixel_step, print);
    //if (print) std::cout << " Mask magn " << std::endl << outlier_probabilities << std::endl;
}
Ejemplo n.º 11
0
int 
main(int argc, char * argv[])
{  
    int     pid, initresult;

    if (argc != 2)
    {
        fprintf (stderr, "Usage: %s <proces-number 0..4>\n", argv [0]);
        return (-1);
    }

    pid = atoi(argv[1]);
    #ifdef VERBOSE
    printf ("Starting up process %d\n", pid);
    #endif

    if(pid == 0)
    {
        initSemSHM(pid);
    }else{
        openSemSHM(pid);
    }
    createMask(pid);
    statement_1(pid);

    // enter Critical Section
    sem_wait(sem_flags);
    // Read flags from shm
    flags = shm_addr[0];
    #ifdef VERBOSE
    printf ("Flags in store are 0x%02x\n", flags);
    #endif
    // mask flags
    flags = flags | mask;
    #ifdef VERBOSE
    printf ("Flags after masking 0x%02x\n", flags);
    #endif
    // update flag in shm
    shm_addr[0] = flags;
    #ifdef VERBOSE
    printf ("Flags are 0x%02x in process %d\n", flags, pid);
    #endif
    // leave Critical Section
    sem_post(sem_flags);

    // Check the flags, do sem_post(sem_sync) or sem_wait(sem_sync)
    if(flags == 0x0F){
        sem_post(sem_sync);
    }else{
        sem_wait(sem_sync);
    }
    sem_post(sem_sync);
    statement_2(pid);

    // Clean up   
    cleanupSemSHM(pid);
}
Ejemplo n.º 12
0
void HazePerfection::morphfill()
{
	readHotImage();
	createMask();
	invertImage(hotDataset, maskDataset, inverta);
	createMark(markB);
	morphologicalReconstruction(markDataset, maskDataset);
	invertImage(markDataset, maskDataset, inverta);
}
Ejemplo n.º 13
0
Mat HSBackport::getOriginalMatForUI() {
	createMask();
	Mat ret;
	ret = ScreenHotSpot::getOriginalMatForUI();
	if (!ret.empty()) {
		ImageFilterMat::addAlphaMask(&ret, &mask);
	}
	return ret;
}
Ejemplo n.º 14
0
GBitmap::GBitmap(const char *fileName, bool isTrans, COLORREF transCr):
			mBmp(NULL),
			mMask(NULL),
			mWidth(0),
			mHeight(0),
			mIsTrans(isTrans),
			mTransColor(transCr)
{
	load(fileName);
	if(mIsTrans) createMask();
}
Ejemplo n.º 15
0
bool GBitmap::loadTransparent(const char *fileName, COLORREF transCr)
{
	if(!load(fileName)) return false;

	mIsTrans = true;
	mTransColor = transCr;

	createMask();

	return true;
}
Ejemplo n.º 16
0
int processChannelGet(char *chan, char *type)
{
  short int channel = atoi(chan);
  if (channel > 5 || channel < 0 ) {
    printf("Error, invalid channel (%d) specified.\n",channel);
    return -2;
  }

  if( strcmp(type,"vmon") == 0 ) { // Current voltage
    printf("Channel %d VMON = %f V\n",channel,caenv6533GetVMON(board_addr,channel));
  } else if ( strcmp(type, "chstatus") == 0 ) { // Get status

    unsigned short int status = caenv6533GetCHSTATUS(board_addr,channel);

    printf("Channel %d CHSTATUS bits set:\n|| ",channel );
    // Check if on or off
    int i;
    for( i = 0; i < 14; i++ ) {
      //if( ( status & (1 << i)) >> i ) {
      if( status & createMask(i,i) ) {
        printf("%s || ",chstatusText[i]);
      }
    }
    printf("\n");
  } else if ( strcmp(type, "vset" ) == 0 ) {
    printf("Channel %d VSET = %f V\n",channel,caenv6533GetVSET(board_addr,channel));
  } else if ( strcmp(type, "pw" ) == 0 ) {
    printf("Channel %d PW = %s\n",channel,  caenv6533GetPW(board_addr,channel) == 0 ? "OFF" : "ON" );
  } else if ( strcmp(type, "svmax" ) == 0 ) {
    printf("Channel %d SVMAX = %f V\n",channel,  caenv6533GetSVMAX(board_addr,channel) );
  } else if ( strcmp(type, "trip_time" ) == 0 ) {
    printf("Channel %d TRIP_TIME = %f s\n",channel,  caenv6533GetTRIP_TIME(board_addr,channel) );
  } else if ( strcmp(type, "imonh" ) == 0 ) {
    printf("Channel %d ImonH = %f uA\n",channel,  caenv6533GetImonH(board_addr,channel) );
  } else if ( strcmp(type, "imonl" ) == 0 ) {
    printf("Channel %d ImonL = %f uA\n",channel,  caenv6533GetImonL(board_addr,channel) );
  } else if ( strcmp(type, "iset" ) == 0 ) {
    printf("Channel %d ISET = %f uA\n",channel,  caenv6533GetISET(board_addr,channel) );
  } else if ( strcmp(type, "polarity" ) == 0 ) {
    printf("Channel %d POLARITY = %s\n",channel,  caenv6533GetPOLARITY(board_addr,channel) == 0 ? "NEGATIVE" : "POSITIVE" );
  } else if ( strcmp(type, "imon_range" ) == 0 ) {
    printf("Channel %d IMON_RANGE = %s\n",channel,  caenv6533GetIMON_RANGE(board_addr,channel) == 0 ? "HIGH" : "LOW" );
  } else {
    return -3;
  }

  return 0;
}
Ejemplo n.º 17
0
CDMask::CDMask( Vec2i const& size , CFScene* scene )
	:size( size )
	,needShow( true )
{

	spr = scene->createObject( nullptr );
	
	spr->setOpacity( 0.5f );
	//spr->createPlane( NULL , 100 , 100 , Vec3D(1,0,0) );
	spr->setLocalPosition( Vec3D(0,0,10) );
	spr->enableVisibleTest( false );
	spr->setRenderOption( CFly::CFRO_CULL_FACE , CFly::CF_CULL_NONE );

	int geom = createMask( spr , nullptr );

	CFly::MeshBase* shape = spr->getElement( geom )->getMesh();
	mGoemBuf = shape->getVertexElement( CFly::CFV_XYZ , mGoemOffset );
}
Ejemplo n.º 18
0
KisDlgFilter::KisDlgFilter(KisViewManager *view, KisNodeSP node, KisFilterManager *filterManager, QWidget *parent) :
        QDialog(parent),
        d(new Private)
{
    setModal(false);

    d->uiFilterDialog.setupUi(this);
    d->node = node;
    d->view = view;
    d->filterManager = filterManager;

    d->uiFilterDialog.filterSelection->setView(view);
    d->uiFilterDialog.filterSelection->showFilterGallery(KisConfig().showFilterGallery());

    d->uiFilterDialog.pushButtonCreateMaskEffect->show();
    connect(d->uiFilterDialog.pushButtonCreateMaskEffect, SIGNAL(pressed()), SLOT(createMask()));

    d->uiFilterDialog.filterGalleryToggle->setChecked(d->uiFilterDialog.filterSelection->isFilterGalleryVisible());
    d->uiFilterDialog.filterGalleryToggle->setIcon(QPixmap(KoResourcePaths::findResource("data", "krita/pics/sidebaricon.png")));
    d->uiFilterDialog.filterGalleryToggle->setMaximumWidth(d->uiFilterDialog.filterGalleryToggle->height());
    connect(d->uiFilterDialog.filterSelection, SIGNAL(sigFilterGalleryToggled(bool)), d->uiFilterDialog.filterGalleryToggle, SLOT(setChecked(bool)));
    connect(d->uiFilterDialog.filterGalleryToggle, SIGNAL(toggled(bool)), d->uiFilterDialog.filterSelection, SLOT(showFilterGallery(bool)));
    connect(d->uiFilterDialog.filterSelection, SIGNAL(sigSizeChanged()), this, SLOT(slotFilterWidgetSizeChanged()));

    if (node->inherits("KisMask")) {
        d->uiFilterDialog.pushButtonCreateMaskEffect->setVisible(false);
    }

    d->uiFilterDialog.filterSelection->setPaintDevice(true, d->node->original());

    connect(d->uiFilterDialog.buttonBox, SIGNAL(accepted()), SLOT(accept()));
    connect(d->uiFilterDialog.buttonBox, SIGNAL(rejected()), SLOT(reject()));
    connect(d->uiFilterDialog.checkBoxPreview, SIGNAL(toggled(bool)), SLOT(enablePreviewToggled(bool)));

    connect(d->uiFilterDialog.filterSelection, SIGNAL(configurationChanged()), SLOT(filterSelectionChanged()));

    connect(this, SIGNAL(accepted()), SLOT(slotOnAccept()));
    connect(this, SIGNAL(rejected()), SLOT(slotOnReject()));

    KConfigGroup group( KSharedConfig::openConfig(), "filterdialog");
    d->uiFilterDialog.checkBoxPreview->setChecked(group.readEntry("showPreview", true));

}
Ejemplo n.º 19
0
FunctionMode ImageAnalysis::depth_mask_detection(){
	//printf("depth mask detection\n");
	
	if( m_depthMaskCounter > 0){
		// Depth mask already detected. Reset m_depthMaskCounter and begin again.
		m_depthMaskCounter = -NMASKFRAMES;
	}
	if( m_depthMaskCounter == -NMASKFRAMES ){
		/* First step/frame. */
		
		//Disable clipping in libfreenect driver to get depth mask of
		//full range.
		m_pdevice->setRoi(false,Rect(0,0,0,0) );
	
		m_depthMaskWithoutThresh = Scalar(0);
		m_depthMask = Scalar(255);//temporary full mask
	}
	if( m_depthMaskCounter < 0){
		// Use (fullsize) early frames to generate mask
		m_pdevice->getDepth8UC1(m_depthf, Rect(0,0,KRES_X,KRES_Y),
				m_pSettingKinect->m_kinectProp.minDepth,m_pSettingKinect->m_kinectProp.maxDepth);
		if( m_depthMaskCounter > 2-NMASKFRAMES)//deprecated filtering of first frames
			createMask(m_depthf,m_depthMaskWithoutThresh,/*m_pSettingKinect->m_kinectProp.marginBack,*/m_depthMaskWithoutThresh);
		m_depthMaskCounter++;

		if( m_depthMaskCounter == 0 ){
			/* Last step/frame. */
			finishDepthMaskCreation();

			/* Re-enable clipping */
			if( m_pSettingKinect->m_kinectProp.clipping)
				m_pdevice->setRoi(true,m_pSettingKinect->m_kinectProp.roi);

			printf("Depth mask detection finished.\n");
			return HAND_DETECTION;
		}
		return DEPTH_MASK_DETECTION;
	}else{
		return HAND_DETECTION;
	}
		return DEPTH_MASK_DETECTION;
}
Ejemplo n.º 20
0
void MoveRegionTool::OnLButtonUp(UINT nFlags, const CPoint &point) {
  if(m_copy == NULL) {
    invertPolygon();   // remove polygon
    m_rect = m_polygon.getBoundsRect();                                                             // define rect
    if(m_polygon.size() > 2 && m_rect.Width() > 0 && m_rect.Height() > 0) {                         // if valid rectangle
      m_copy = theApp.fetchPixRect(m_rect.Size());                                                          //   define copy
      m_mask = theApp.fetchPixRect(m_rect.Size());                                                          //   define mask
      m_old  = theApp.fetchPixRect(m_rect.Size());                                                          //   define old
      m_copy->rop(ORIGIN,m_rect.Size(),SRCCOPY, getImage(),m_rect.TopLeft());                       //   take a copy
      m_old->rop( ORIGIN,m_rect.Size(),SRCCOPY, getImage(),m_rect.TopLeft());                       //   take a copy
      createMask();

      invertPolygon(); // draw polygon
    } else {
      m_polygon.clear();
    }
  } else {
    invertPolygon(); // draw polygon
  }
}
Ejemplo n.º 21
0
#include "ClangIndexer.h"

Hash<Path, uint32_t> Location::sPathsToIds;
Hash<uint32_t, Path> Location::sIdsToPaths;
uint32_t Location::sLastId = 0;
std::mutex Location::sMutex;
static inline uint64_t createMask(int startBit, int bitCount)
{
    uint64_t mask = 0;
    for (int i=startBit; i<startBit + bitCount; ++i) {
        mask |= (static_cast<uint64_t>(1) << i);
    }
    return mask;
}

const uint64_t Location::FILEID_MASK = createMask(0, FileBits);
const uint64_t Location::LINE_MASK = createMask(FileBits, LineBits);
const uint64_t Location::COLUMN_MASK = createMask(FileBits + LineBits, ColumnBits);

String Location::toString(Flags<ToStringFlag> flags, Hash<Path, String> *contextCache) const
{
    if (isNull())
        return String();
    const unsigned int l = line();
    const unsigned int c = column();
    int extra = RTags::digits(l) + RTags::digits(c) + 3;
    String ctx;
    if (flags & Location::ShowContext) {
        ctx += '\t';
        ctx += context(flags, contextCache);
        extra += ctx.size();
Ejemplo n.º 22
0
//--------------------------------------------------------------
void ofxMtlMapping2D::update()
{
    ofxMtlMapping2DControls::mapping2DControls()->update();
    
    // ---- save mapping to xml
    if(ofxMtlMapping2DControls::mapping2DControls()->saveMapping()) {
        ofxMtlMapping2DControls::mapping2DControls()->resetSaveMapping();
        saveShapesList();
    }
    
    
    // ---- load mapping from xml
    if(ofxMtlMapping2DControls::mapping2DControls()->loadMapping()) {
        ofxMtlMapping2DControls::mapping2DControls()->resetLoadMapping();
        loadShapesList();
    }
    
    
    
    // ----
    // Editing or not !?
    if(!ofxMtlMapping2DControls::mapping2DControls()->editShapes())
        return;
    
    
    // ----
    // Create a new shape
    if(ofxMtlMapping2DControls::mapping2DControls()->createNewQuad()) {
        ofxMtlMapping2DControls::mapping2DControls()->resetCreateNewShape();
        createQuad(1020/2, 720/2);
        return;
    }
    
    if(ofxMtlMapping2DControls::mapping2DControls()->createNewGrid()) {
        ofxMtlMapping2DControls::mapping2DControls()->resetCreateNewShape();
        createGrid(1020/2, 720/2);
        return;
    }
    
    if(ofxMtlMapping2DControls::mapping2DControls()->createNewTriangle()) {
        ofxMtlMapping2DControls::mapping2DControls()->resetCreateNewShape();
        createTriangle(1020/2, 720/2);
        return;
    }
    
    if(ofxMtlMapping2DControls::mapping2DControls()->createNewMask()) {
        ofxMtlMapping2DControls::mapping2DControls()->resetCreateNewShape();
        createMask(1020/2, 720/2);
        return;
    }
    
    // ----
    // Selected shape with UI
    if(ofxMtlMapping2DControls::mapping2DControls()->selectedShapeChanged()) {
        ofxMtlMapping2DControls::mapping2DControls()->resetSelectedShapeChangedFlag();

        list<ofxMtlMapping2DShape*>::iterator it = iteratorForShapeWithId(ofxMtlMapping2DControls::mapping2DControls()->selectedShapeId());
        if(it != ofxMtlMapping2DShapes::pmShapes.end()) {
            ofxMtlMapping2DShape* shape = *it;
            shape->setAsActiveShape(true);
            
            // Put active shape at the top of the list
            ofxMtlMapping2DShapes::pmShapes.push_front(shape);
            ofxMtlMapping2DShapes::pmShapes.erase(it);
        }
    }

    
    // ----
    // We changed of mode - Output / Input
    if(ofxMtlMapping2DControls::mapping2DControls()->mappingModeChanged()) {
        ofxMtlMapping2DControls::mapping2DControls()->resetMappingChangedFlag();        
        
        // ---- OUTPUT MODE
        if(ofxMtlMapping2DControls::mapping2DControls()->mappingMode() == MAPPING_MODE_OUTPUT) {
            list<ofxMtlMapping2DShape*>::iterator it;
            for (it=ofxMtlMapping2DShapes::pmShapes.begin(); it!=ofxMtlMapping2DShapes::pmShapes.end(); it++) {
                ofxMtlMapping2DShape* shape = *it;
                shape->enable();
                
                if(shape->inputPolygon) {
                    // If this Shape is textured and has an 'inputPolygon'
                    shape->inputPolygon->setAsIdle();
                }
            }
        // ---- INPUT MODE
        } else if (ofxMtlMapping2DControls::mapping2DControls()->mappingMode() == MAPPING_MODE_INPUT) {
            list<ofxMtlMapping2DShape*>::iterator it;
            for (it=ofxMtlMapping2DShapes::pmShapes.begin(); it!=ofxMtlMapping2DShapes::pmShapes.end(); it++) {
                ofxMtlMapping2DShape* shape = *it;
                shape->setAsIdle();
                shape->inputPolygon->enable();
            }
        }
    
    }
    
    // ----
    // Update the Shapes
    list<ofxMtlMapping2DShape*>::iterator it;
    for (it=ofxMtlMapping2DShapes::pmShapes.begin(); it!=ofxMtlMapping2DShapes::pmShapes.end(); it++) {
        ofxMtlMapping2DShape* shape = *it;
        shape->update();
    }
}
Ejemplo n.º 23
0
KisFilterDialog::KisFilterDialog(KisView2 *view, KisNodeSP node, KisImageWSP image, KisSelectionSP selection) :
        QDialog(view),
        d(new Private)
{
    setModal(false);

    d->uiFilterDialog.setupUi(this);
    d->node = node;
    d->image = image;
    d->view = view;
    d->mask = new KisFilterMask();
    d->mask->initSelection(selection, dynamic_cast<KisLayer*>(node.data()));
    d->uiFilterDialog.filterSelection->setView(view);
    d->uiFilterDialog.filterSelection->showFilterGallery(KisConfig().showFilterGallery());

    if (d->node->inherits("KisLayer")) {
        qobject_cast<KisLayer*>(d->node.data())->setPreviewMask(d->mask);
        d->uiFilterDialog.pushButtonCreateMaskEffect->show();
        d->uiFilterDialog.pushButtonCreateMaskEffect->setEnabled(true);
        connect(d->uiFilterDialog.pushButtonCreateMaskEffect, SIGNAL(pressed()), SLOT(createMask()));
    } else {
        d->uiFilterDialog.pushButtonCreateMaskEffect->hide();
    }
    d->uiFilterDialog.pushButtonCreateMaskEffect->hide(); // TODO fixme, understand why the mask isn't created, and then remove that line
    d->uiFilterDialog.filterSelection->setPaintDevice(d->node->original());
    d->uiFilterDialog.pushButtonOk->setGuiItem(KStandardGuiItem::ok());
    d->uiFilterDialog.pushButtonCancel->setGuiItem(KStandardGuiItem::cancel());

    connect(d->uiFilterDialog.pushButtonOk, SIGNAL(pressed()), SLOT(apply()));
    connect(d->uiFilterDialog.pushButtonOk, SIGNAL(pressed()), SLOT(accept()));
    connect(d->uiFilterDialog.pushButtonCancel, SIGNAL(pressed()), SLOT(reject()));
    connect(d->uiFilterDialog.checkBoxPreview, SIGNAL(stateChanged(int)), SLOT(previewCheckBoxChange(int)));

    connect(d->uiFilterDialog.filterSelection, SIGNAL(configurationChanged()), SLOT(updatePreview()));
    connect(this, SIGNAL(finished(int)), SLOT(close()));

    KConfigGroup group(KGlobal::config(), "filterdialog");
    d->uiFilterDialog.checkBoxPreview->setChecked(group.readEntry("showPreview", true));
}
Ejemplo n.º 24
0
//! ----------------------------------------------------------------------------
//! CONSTRUCTOR
//! ----------------------------------------------------------------------------
BrainBot::BrainBot(fV3 position_, NavGrid const* grid_) :
GameObject(position_, createView(position_), createMask(grid_))
{

}
Ejemplo n.º 25
0
Status_t
vs_event_create (Event_t * ec, unsigned char name[], Eventset_t state)
{
  static const char function[] = "vs_event_create";
  uint32_t          namesize;
  Implpriv_Event_t *implpriv;

  IB_ENTER (function, (unint) ec, (unint) name, (uint32_t) state,
	    (uint32_t) 0U);
  
  if (ec == 0)
    {
      IB_LOG_ERROR0 ("Event_t parameter is null");
      IB_EXIT (function, VSTATUS_ILLPARM);
      return VSTATUS_ILLPARM;
    }

  if (name == 0)
    {
      IB_LOG_ERROR0 ("name parameter is null");
      IB_EXIT (function, VSTATUS_ILLPARM);
      return VSTATUS_ILLPARM;
    }

  for (namesize = 0U; namesize < VS_NAME_MAX; namesize++)
    {
      if (name[namesize] == (unsigned char) 0x00)
	{
	  (void) memmove (ec->name, name, namesize + 1U);
	  break;
	}
    }

  if (namesize >= VS_NAME_MAX)
    {
      IB_LOG_ERROR0 ("name doesn't contain a terminator");
      IB_EXIT (function, VSTATUS_ILLPARM);
      return VSTATUS_ILLPARM;
    }

  /*
     ** this is a run-time check to ensure that the opaque section of Event_t
     ** is large enough to contain the Implementation private data structure.
     ** If this test fails, adjust the OPAQUE_EVENT_SIZE_WORDS define in
     ** cs_g.h and rebuild.
   */
  if (sizeof (Implpriv_Event_t) > sizeof (ec->opaque))
    {
      IB_LOG_ERROR ("Implpriv_Event_t too big:", sizeof (Implpriv_Event_t));
      IB_EXIT (function, VSTATUS_ILLPARM);
      return VSTATUS_ILLPARM;
    }

  /*
  ** this is a run-time check to make sure that the event array is supported by
  ** the ATI implementation.
  */
  if (sizeof (Eventset_t) > sizeof (uint32_t))
  {
    IB_LOG_ERROR0 ("Implpriv_Event_t does not support size of event array.");
    IB_EXIT (function, VSTATUS_NODEV);
    return VSTATUS_NODEV;
  }

  implpriv = (Implpriv_Event_t *) (void *) & ec->opaque;
  memset(implpriv, 0, sizeof(*implpriv));

  implpriv->magic = IMPLPRIV_EVENT_MAGIC;
  ec->event_handle = ec;
  IB_LOG_INFO("handle: ", ec->event_handle);
  
  if((implpriv->id = createMask()) == 0){
      IB_LOG_ERROR0 ("Mask Creation Failed");
      IB_EXIT (function, VSTATUS_NODEV);
      return VSTATUS_NODEV;
  }
  


  IB_EXIT (function, VSTATUS_OK);
  return VSTATUS_OK;
}
Ejemplo n.º 26
0
uint16_t getValueFromBits(uint16_t extractFrom, int high, int length) 
{
   int low= high-length +1;
   uint16_t mask = createMask(low ,high);
   return shiftDown(extractFrom & mask, low); 
}
Ejemplo n.º 27
0
void RangeMask::getMasks(const optional<uint16_t>& startOpt,
                         const optional<uint16_t>& endOpt,
                         MaskList& out) {
    out.clear();
    if (!startOpt && !endOpt) {
        return;
    }
    if (startOpt && !endOpt) {
        out.push_back(createMask(startOpt.get(), -1));
        return;
    }
    if (!startOpt && endOpt) {
        out.push_back(createMask(endOpt.get(), -1));
        return;
    }

    uint16_t start = startOpt.get();
    uint16_t end = endOpt.get();
    if (start > end) {
        swap(start, end);
    }

    if (start == end) {
        out.push_back(createMask(start, -1));
    } else {
        /* Find first bit from MSB that is different between 'start' & 'end' */
        int l2 = 15;
        while (l2 > 0 && isBitSet(start, l2) == isBitSet(end, l2)) {
            --l2;
        }
        /* Find first from LSB that is set in 'start' */
        int l1 = 0;
        while (l1 < l2 && !isBitSet(start, l1)) {
            ++l1;
        }
        /* Find beginning of trailing 1s in 'end' */
        int lto = -1;
        while (lto < l2 && isBitSet(end, lto+1)) {
            ++lto;
        }

        if (l1 == l2 && l2 == lto) {
            /* Special case:
             *    start = xxxx0..0
             *    end   = xxxx1..1
             */
            out.push_back(createMask(start, l2));
        } else {
            out.push_back(createMask(start, l1-1));
            int p = l1 + 1;
            while (p < l2) {
                if (!isBitSet(start, p)) {
                    out.push_back(createMask(setBit(start, p, true), p-1));
                }
                ++p;
            }
            p = l2 - 1;
            while (p > lto) {
                if (isBitSet(end, p)) {
                    out.push_back(createMask(setBit(end, p, false), p-1));
                }
                --p;
            }
            out.push_back(createMask(end, lto == l2 ? lto-1 : lto));
        }
    }
}
Ejemplo n.º 28
0
int main(int argc, char* argv[]){
	
	FILE* parameters;
	
	/* parameters of the gaussian */
	int width;
	int length;
	double amplitude;
	double x_0;
	double y_0;
	double sigma_x0;
	double sigma_y0;
	double a_0;
	double b_0;
	double c_0;
	int max,min;
	
	/* parameters for the cookie cutter */
	double x0,y0;
	double FWHM_x,FWHM_y;
	int span_x,span_y;
	int dimx,dimy;
	int x,y;
	
	/* gaussian struct */
	fit_t results,test_g;
	
	/* indexes */
	int i,j;
	int temp;
	
	if(argc != 2){
		printf("NUMERO PARAMETRI INVALIDO\n");
		exit(EXIT_FAILURE);
	}
	
	parameters = fopen(argv[1],"r");
	
	/* LETTURA DEI PARAMETRI */
	fscanf(parameters,"%d\t%d\t",&width,&length);
	fscanf(parameters,"%lf\t%lf\t%lf\t",&amplitude,&x_0,&y_0);
	fscanf(parameters,"%lf\t%lf\t",&sigma_x0,&sigma_y0);
	fscanf(parameters,"%lf\t%lf\t%lf",&a_0,&b_0,&c_0);
	
	/* GAUSSIAN_MATRIX */
	unsigned char matrix[length][width];
	
#if DEBUG
	/* STAMPA DI DEBUG DEI PARAMETRI DELLA GAUSSIANA DA INTERPOLARE */
	printf("Dimensioni della matrice: %d %d\n",width,length);
	printf("Ampiezza: %f\nPosizione asse X: %f\nPosizione asse Y: %f\n",amplitude,x_0,y_0);
	printf("Varianza asse X: %f\nVarianza asse Y: %f\n",sigma_x0,sigma_y0);
	printf("A(x): %f\nB(y): %f\nC: %f\n",a_0,b_0,c_0);
#endif	
	
	/* ASSEGNAZIONE ALLA STRUCT */
	results.A = amplitude;
	results.x_0 = x_0;
	results.y_0 = y_0;
	results.sigma_x = sigma_x0;
	results.sigma_y = sigma_y0;
	results.a = a_0;
	results.b = b_0;
	results.c = c_0;	
	
	/* COSTRUZIONE DELL'IMMAGINE */
	for (i=0;i<length;i++){
		for(j=0;j<width;j++){
			temp = (int) evaluateGaussian(&results,j,i);
			//printf("%d\n",temp);
			matrix[i][j] = temp;
		}
	}
	
	/* WRITING THE IMAGE TO BE FITTED ON A TIFF FILE */
	writeImage((unsigned char *)matrix,(char *) OUTPUT_MATRIX, width, length);
	
	maxmin( (unsigned char*) matrix, width, length, &max, &min);
	
	printf("MAX: %d MIN: %d\n", max, min);
	
	/* a pixel mask is created in order to reduce the dimensione of the region to analyze with the centroid */
	unsigned char *mask = createMask( (unsigned char*) matrix, width, length, max, min, CROP_PARAMETER);
	
#if DEBUG
	writeImage(mask, (char *) "mask.tiff", width, length);
#endif
	
	centroid(mask, width, length, &x0, &y0, &FWHM_x, &FWHM_y);
	
#if DEBUG
	printf("centro in %f - %f\nCon ampiezza %f e %f\n", x0, y0, FWHM_x, FWHM_y);
#endif
	
	delete mask;
	
	/* inizialization for the diameter of the gaussian*/
	span_x = (int) (2 * FWHM_x);
	span_y = (int) (2 * FWHM_y);
	
	/* determination of the dimension of the crop */
	dimx = 2 * span_x + 1;
	dimy = 2 * span_y + 1;
	
	/* inizialization of the position coordinates */
	x = (int) x0;
	y = (int) y0;
	
	/**
	 inizialization of the test_g struct.
	 NOTE: the coordinates of the position (x,y) are relative to the cropped portion of the image.
	 the value of span_x, which is approximately the diameter of the gaussian, is generally not as bad
	 as you may think to start the fit. 
	 */
	test_g.A = max;
	test_g.x_0 = span_x;
	test_g.y_0 = span_y;
	test_g.sigma_x = FWHM_x;
	test_g.sigma_y = FWHM_y;
	test_g.a = 0;
	test_g.b = 0;
	test_g.c = min;
	
	fprintf(risultati, "%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n", (&test_g)->A, (&test_g)->x_0 + x - span_x, (&test_g)->y_0 + y - span_y, (&test_g)->sigma_x, (&test_g)->sigma_y, (&test_g)->a, (&test_g)->b, (&test_g)->c);
	
	
	/* THIS PART CAN BE ITERATIVE */
	
	unsigned char *cropped = cropImage((unsigned char*) matrix, width, length, x - span_x, x + span_x, y - span_y, y + span_y);
	
#if DEBUG
	writeImage(cropped, (char *) "./CROP.tiff", dimx, dimy);
#endif
	
	for(i=0;i<ITERATION;i++){
		
		/* FIT FUNCTION */
		iteration(cropped, dimx, dimy, &test_g);
		
		fprintf(risultati, "%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n", (&test_g)->A, (&test_g)->x_0 + x - span_x, (&test_g)->y_0 + y - span_y, (&test_g)->sigma_x, (&test_g)->sigma_y, (&test_g)->a, (&test_g)->b, (&test_g)->c);
	}
	return 0;
}