예제 #1
0
static void
calc_node_type(cairo_t *cr, designer_node_type_t *nt)
{
    node_type_data_t *ntd = node_type_data(nt);
    _rect_t br, ir, or, sr;

    ntd->is = g_slist_length(nt->input_slot_specs);
    ntd->os = g_slist_length(nt->output_slot_specs);

    set_slot_font(cr);
    sr = text_rect(cr, "Mg");
    /* add sep space */
    sr.s.h += 3;

    ir = _rect(0, 0, 10, 0);
    for (int i=0; i<ntd->is; i++) {
	designer_slot_spec_t *slot =
	    g_slist_nth_data(nt->input_slot_specs, i);
	slot_spec_data_t *ssd = slot_spec_data(slot);
	
	ssd->offset = _size(3, 5 + sr.s.h * i);
	ir = _union(ir, text_rect(cr, slot->name));
    }
    /* offset left */
    ir = _offset(ir, _size(0, 5));
    /* add slot and sep space */
    ir.s.w += 5+5;
    /* height including sep space */
    ir.s.h = ntd->is * sr.s.h - 3;

    or = _rect(0, 0, 10, 0);
    for (int i=0; i<ntd->os; i++) {
	designer_slot_spec_t *slot =
	    g_slist_nth_data(nt->output_slot_specs, i);
	slot_spec_data_t *ssd = slot_spec_data(slot);
	
	ssd->offset = _size(3, 5 + sr.s.h * i);
	or = _union(or, text_rect(cr, slot->name));
    }
    /* move right, including sep space */
    or = _offset(or, _size(ir.s.w + 5, 5));
    /* add slot and sep space */
    or.s.w += 5+5;
    /* height including sep space */
    or.s.h = ntd->os * sr.s.h - 3;

    br = _union(ir, or);
    /* reserve space around area */
    br = _inset(br, _size(-5, -5));

    ntd->br = br;
    ntd->ir = _splith(&ir, 6);
    _splith(&or, or.s.w - 6);
    ntd->or = or;
    ntd->sr = sr;
}
예제 #2
0
static int _open_plain( const char * device,const open_struct_t * opt )
{
	uint32_t flags ;

	struct crypt_device * cd ;
	struct crypt_params_plain params ;

	memset( &params,'\0',sizeof( struct crypt_params_plain ) ) ;

	params.hash = "ripemd160" ;

	if( zuluCryptPathIsNotValid( device ) ){
		return 3 ;
	}
	if( crypt_init( &cd,device ) != 0 ){
		return 2 ;
	}

	params.offset = _offset( opt->offset ) ;

	if( StringHasComponent( opt->m_opts,"ro" ) ){
		flags = CRYPT_ACTIVATE_READONLY ;
	}else{
		flags = CRYPT_ACTIVATE_ALLOW_DISCARDS ;
	}
	if( crypt_format( cd,CRYPT_PLAIN,"aes","cbc-essiv:sha256",NULL,NULL,32,&params ) != 0 ){
		return zuluExit( 2,cd ) ;
	}
	if( crypt_activate_by_passphrase( cd,opt->mapper_name,CRYPT_ANY_SLOT,
		opt->key,opt->key_len,flags ) < 0 ){
		return zuluExit( 2,cd ) ;
	}else{
		return zuluExit( 0,cd ) ;
	}
}
예제 #3
0
void PostscriptIO::_compute_edge_bezier_coeffs(const Elem* elem)
{
  // I only know how to do this for an Edge3!
  libmesh_assert_equal_to (elem->type(), EDGE3);

  // Get x-coordinates into an array, transform them,
  // and repeat for y.
  float
    phys_coords[3] = {0., 0., 0.},
    bez_coords[3]  = {0., 0., 0.};

  for (unsigned int i=0; i<2; ++i)
    {
      // Initialize vectors.  Physical coordinates are initialized
      // by their postscript-scaled values.
      for (unsigned int j=0; j<3; ++j)
	{
	  phys_coords[j] = (elem->point(j)(i) - _offset(i)) * _scale;
	  bez_coords[j] = 0.; // zero out result vector
	}

      // Multiply matrix times vector
      for (unsigned int j=0; j<3; ++j)
	for (unsigned int k=0; k<3; ++k)
	  bez_coords[j] += _bezier_transform[j][k]*phys_coords[k];

      // Store result in _bezier_coeffs
      for (unsigned int j=0; j<3; ++j)
	_bezier_coeffs[j](i) = phys_coords[j];
    }
}
예제 #4
0
static PyObject * THPStorage_(shareCuda)(THPStorage *self)
{
  HANDLE_TH_ERRORS
  THStorage *storage = self->cdata;
  AutoGPU gpu_guard(storage->device);
  THPObjectPtr tuple(PyTuple_New(5));
  THPObjectPtr device(PyLong_FromLong(storage->device));
  THPObjectPtr _handle(Py_None);
  Py_INCREF(Py_None);
  THPObjectPtr size(PyLong_FromLong(storage->size));
  THPObjectPtr _offset(PyLong_FromLong(0));
  THPObjectPtr view_size(PyLong_FromLong(storage->size));
  if (storage->data) {
    size_t base_size;
    void *base_ptr = THCCachingAllocator_getBaseAllocation(storage->data, &base_size);
    ptrdiff_t offset = (char*)storage->data - (char*)base_ptr;

    cudaIpcMemHandle_t handle;
    THCudaCheck(cudaIpcGetMemHandle(&handle, base_ptr));

    _handle = PyBytes_FromStringAndSize((char *)&handle, CUDA_IPC_HANDLE_SIZE);
    _offset = PyLong_FromSsize_t((Py_ssize_t)offset);
    size = PyLong_FromSize_t(base_size / sizeof(real));
  }
  if (!tuple || !device || !_handle || !size || !_offset || !view_size) {
    return NULL;
  }
  PyTuple_SET_ITEM(tuple.get(), 0, device.release());
  PyTuple_SET_ITEM(tuple.get(), 1, _handle.release());
  PyTuple_SET_ITEM(tuple.get(), 2, size.release());
  PyTuple_SET_ITEM(tuple.get(), 3, _offset.release());
  PyTuple_SET_ITEM(tuple.get(), 4, view_size.release());
  return tuple.release();
  END_HANDLE_TH_ERRORS
}
예제 #5
0
static _rect_t
recalc_area(cairo_t *cr, widget_data_t *data)
{
    _rect_t area;
    int count = 0;

    /* no valid data */
    if (!data || !data->design || !data->design->nodes)
	return _zeror;

    /* check the nodes */
    for (GSList *list = data->design->nodes;
	list != NULL; list = list->next) {
	designer_node_t *node = list->data;

	if (cr) {
	    calc_node_type(cr, node->type);
	    calc_node(cr, node);
	}

	node_data_t *nd = node_data(node);
	_rect_t nr = _offset(nd->nr, _ptos(nd->origin));

	area = (count++) ? _union(area, nr) : nr;
    }
    return _inset(area, _size(-40, -20));
}
예제 #6
0
Polygons
offset(const Polylines &polylines, const float delta,
    double scale, ClipperLib::JoinType joinType, double miterLimit)
{
    // perform offset
    ClipperLib::Paths output = _offset(polylines, delta, scale, joinType, miterLimit);
    
    // convert into Polygons
    return ClipperPaths_to_Slic3rMultiPoints<Polygons>(output);
}
예제 #7
0
ExPolygons
offset_ex(const Polygons &polygons, const float delta,
    double scale, ClipperLib::JoinType joinType, double miterLimit)
{
    // perform offset
    ClipperLib::Paths output = _offset(polygons, delta, scale, joinType, miterLimit);
    
    // convert into ExPolygons
    return ClipperPaths_to_Slic3rExPolygons(output);
}
예제 #8
0
파일: string.c 프로젝트: MattDevo/coreboot
long int strtol(const char *ptr, char **endptr, int base)
{
	int ret = 0;
	int negative = 1;

	if (endptr != NULL)
		*endptr = (char *) ptr;

	/* Purge whitespace */

	for( ; *ptr && isspace(*ptr); ptr++);

	if (ptr[0] == '-') {
		negative = -1;
		ptr++;
	}

	if (!*ptr)
		return 0;

	/* Determine the base */

	if (base == 0) {
		if (ptr[0] == '0' && (ptr[1] == 'x' || ptr[1] == 'X'))
			base = 16;
		else if (ptr[0] == '0') {
			base = 8;
			ptr++;
		}
		else
			base = 10;
	}

	/* Base 16 allows the 0x on front - so skip over it */

	if (base == 16) {
		if (ptr[0] == '0' && (ptr[1] == 'x' || ptr[1] == 'X'))
			ptr += 2;
	}

	/* If the first character isn't valid, then don't
	 * bother */

	if (!*ptr || !_valid(*ptr, base))
		return 0;

	for( ; *ptr && _valid(*ptr, base); ptr++)
		ret = (ret * base) + _offset(*ptr, base);

	if (endptr != NULL)
		*endptr = (char *) ptr;

	return ret * negative;
}
예제 #9
0
파일: 4obj.c 프로젝트: 0intro/plan9-mips
static Addr
addr(Biobuf *bp)
{
    Addr a;
    vlong off;
    long l;

    a.type = Bgetc(bp);	/* a.type */
    skip(bp,1);		/* reg */
    a.sym = Bgetc(bp);	/* sym index */
    a.name = Bgetc(bp);	/* sym type */
    switch(a.type) {
    default:
    case D_NONE:
    case D_REG:
    case D_FREG:
    case D_MREG:
    case D_FCREG:
    case D_LO:
    case D_HI:
        break;
    case D_OREG:
    case D_CONST:
    case D_BRANCH:
    case D_VCONST:
        l = Bgetc(bp);
        l |= Bgetc(bp) << 8;
        l |= Bgetc(bp) << 16;
        l |= Bgetc(bp) << 24;
        off = l;
        if(a.type == D_VCONST) {
            l = Bgetc(bp);
            l |= Bgetc(bp) << 8;
            l |= Bgetc(bp) << 16;
            l |= Bgetc(bp) << 24;
            off = ((vlong)l << 32) | (off & 0xFFFFFFFF);
            a.type = D_CONST;		/* perhaps */
        }
        if(off < 0)
            off = -off;
        if(a.sym && (a.name==D_PARAM || a.name==D_AUTO))
            _offset(a.sym, off);
        break;
    case D_SCONST:
        skip(bp, NSNAME);
        break;
    case D_FCONST:
        skip(bp, 8);
        break;
    }
    return a;
}
예제 #10
0
static int _open_plain( const char * device,const resolve_path_t * opts )
{
	uint32_t flags ;

	struct crypt_device * cd ;
	struct crypt_params_plain params ;

	size_t size ;
	/*
	 * open_struct_t is defined in includes.h
	 */
	const open_struct_t * opt = opts->args ;

	const args * e = opt->variables ;

	memset( &params,'\0',sizeof( struct crypt_params_plain ) ) ;

	params.hash = e->hash ;

	if( zuluCryptPathIsNotValid( device ) ){

		return 3 ;
	}
	if( crypt_init( &cd,device ) != 0 ){

		return 2 ;
	}

	params.offset = _offset( e->offset ) ;

	if( opts->open_mode == O_RDONLY ){

		flags = CRYPT_ACTIVATE_READONLY ;
	}else{
		flags = CRYPT_ACTIVATE_ALLOW_DISCARDS ;
	}

	size = ( size_t ) StringConvertToInt( e->keySize ) / 8 ;

	if( crypt_format( cd,CRYPT_PLAIN,e->algo,e->cipher,NULL,NULL,size,&params ) != 0 ){

		return zuluExit( 2,cd ) ;
	}
	if( crypt_activate_by_passphrase( cd,opt->mapper_name,CRYPT_ANY_SLOT,
		opt->key,opt->key_len,flags ) < 0 ){

		return zuluExit( 2,cd ) ;
	}else{
		return zuluExit( 0,cd ) ;
	}
}
void scenario::latticeboltzmann::blocklatticeboltzmann::AbstractBoundaryData4Channel::
getBoundaryData(
  const tarch::la::Vector<DIMENSIONS,double> &latticeNode,
  const tarch::la::Vector<DIMENSIONS,double> &latticeWidth,
  const int& pdfDirection,
  const peano::applications::latticeboltzmann::MultiLevelSimData& multiLevelSimData,
  peano::applications::latticeboltzmann::BoundaryData &boundaryData
) {
  double coords;

  // if this is a wall, fill no-slip information and return
  for (int d = 1; d < DIMENSIONS; d++){
    coords = peano::applications::latticeboltzmann::LATTICEVELOCITIES._entries[LB_CURRENT_DIR-1-pdfDirection](d)*latticeWidth(d)
           + latticeNode(d);
    if ( tarch::la::smaller(coords,_offset(d)) || tarch::la::greater(coords,_domainSize(d)+_offset(d)) ){
      fillBoundaryData4NoSlipWalls(boundaryData);
      return;
    }
  }

  coords = peano::applications::latticeboltzmann::LATTICEVELOCITIES._entries[LB_CURRENT_DIR-1-pdfDirection](0)*latticeWidth(0)
         + latticeNode(0);

  // if velocity inlet...
  if ( tarch::la::smaller(coords,_offset(0)) ){
    fillBoundaryData4VelocityInlet(latticeNode,boundaryData);
    return;
  }

  // if pressure outlet...
  if ( tarch::la::greater(coords,_offset(0)+_domainSize(0)) ){
    fillBoundaryData4PressureOutlet(boundaryData);
    return;
  }

  // otherwise: treat boundary also as no slip (-> obstacles in the flow etc.)
  fillBoundaryData4InnerBoundaries(latticeNode,latticeWidth,pdfDirection,multiLevelSimData,boundaryData);
}
예제 #12
0
static Addr
addr(Biobuf *bp)
{
	Addr a;
	long off;

	a.type = Bgetc(bp);	/* a.type */
	skip(bp,1);		/* reg */
	a.sym = Bgetc(bp);	/* sym index */
	a.name = Bgetc(bp);	/* sym type */
	a.gotype = Bgetc(bp);	/* go type */
	switch(a.type){
	default:
	case D_NONE:
	case D_REG:
	case D_FREG:
	case D_PSR:
	case D_FPCR:
		break;
	case D_REGREG:
	case D_REGREG2:
		Bgetc(bp);
		break;
	case D_CONST2:
		Bgetc(bp);
		Bgetc(bp);
		Bgetc(bp);
		Bgetc(bp);	// fall through
	case D_OREG:
	case D_CONST:
	case D_BRANCH:
	case D_SHIFT:
		off = Bgetc(bp);
		off |= Bgetc(bp) << 8;
		off |= Bgetc(bp) << 16;
		off |= Bgetc(bp) << 24;
		if(off < 0)
			off = -off;
		if(a.sym && (a.name==D_PARAM || a.name==D_AUTO))
			_offset(a.sym, off);
		break;
	case D_SCONST:
		skip(bp, NSNAME);
		break;
	case D_FCONST:
		skip(bp, 8);
		break;
	}
	return a;
}
예제 #13
0
int32_t _expand( struct buffer * self, uint32_t length )
{
    int32_t offset = _offset( self );
    uint32_t needlength = offset + self->length + length;

    if ( needlength <= self->capacity )
    {
        return 0;
    }

    if ( self->capacity - self->length >= length )
    {
        _align( self );
    }
    else
    {
        void * newbuffer = NULL;
        uint32_t newcapacity = self->capacity;

        if ( newcapacity < MIN_BUFFER_LENGTH )
        {
            newcapacity = MIN_BUFFER_LENGTH;
        }
        for ( ; newcapacity < needlength; )
        {
            newcapacity <<= 1;
        }

        if ( self->orignbuffer != self->buffer )
        {
            _align( self );
        }

        newbuffer = (char *)realloc( self->orignbuffer, newcapacity );
        if ( newbuffer == NULL )
        {
            return -1;
        }

        self->capacity = newcapacity;
        self->orignbuffer = self->buffer = newbuffer;
    }

    return 0;
}
예제 #14
0
int32_t buffer_append( struct buffer * self, char * buf, uint32_t length )
{
    uint32_t offset = _offset(self);
    uint32_t needlength = offset + self->length + length;

    if ( needlength > self->capacity )
    {
        if ( _expand(self, length) == -1 )
        {
            return -1;
        }
    }

    memcpy( self->buffer+self->length, buf, length );
    self->length += length;

    return 0;
}
예제 #15
0
void scenario::latticeboltzmann::blocklatticeboltzmann::
BoundaryData4EmptyBox::getBoundaryData(
  const tarch::la::Vector<DIMENSIONS,double> &latticeNode,
  const tarch::la::Vector<DIMENSIONS,double> &latticeWidth,
  const int& pdfDirection,
  const peano::applications::latticeboltzmann::MultiLevelSimData& multiLevelSimData,
  peano::applications::latticeboltzmann::BoundaryData &boundaryData
){
  // determine meshsize and timestep for simulation
  int level = multiLevelSimData.getSimData(0).getLevel();
  double dt = multiLevelSimData.getSimData(level).getDt();
  double dx = multiLevelSimData.getSimData(level).getDx();
  // determine boundary node (in this case, this is the midpoint between the first node outside the comp. domain
  // (= inside the structure) and the last node inside the comp. domain)
  const tarch::la::Vector<DIMENSIONS,double> boundaryNode(latticeNode + 0.5*latticeWidth(0)*peano::applications::latticeboltzmann::LATTICEVELOCITIES._entries[LB_CURRENT_DIR-1-pdfDirection]);
  tarch::la::Vector<DIMENSIONS,double> velocityL(0.0);
  double coords = 0.0;

  // if this is a wall at the box boundary, set the HW_BB flag for no-slip (=half-way bounce back boundary)
  // and return
  for (int d = 0; d < DIMENSIONS; d++){
    coords = peano::applications::latticeboltzmann::LATTICEVELOCITIES._entries[LB_CURRENT_DIR-1-pdfDirection](d)*latticeWidth(d)
           + latticeNode(d);
    if ( tarch::la::smaller(coords,_offset(d)) || tarch::la::greater(coords,_domainSize(d)+_offset(d)) ){
      boundaryData.setBoundaryType(
        peano::applications::latticeboltzmann::BoundaryData::HW_BB
      );
      return;
    }
  }


  // if this has not been the outer wall, we consider the boundary to be the boundary of
  // a moving structure or obstacle:
  // set boundary type
  boundaryData.setBoundaryType(peano::applications::latticeboltzmann::BoundaryData::MOVING_OBSTACLE_HW_BB);

  // get velocity from structure
  velocityL = peano::integration::partitioncoupling::services::ReceiveDataService::getInstance().getReceiveData().getVelocity(boundaryNode);
  // rescale velocity
  velocityL = velocityL* (dt/dx);
  // set velocity
  boundaryData.setVelocityL(velocityL);
}
예제 #16
0
파일: parser.c 프로젝트: radare/defora-cc
/* address */
static int _address(State * state)
	/* "[" [ space ] [ sign [ space ] ] value [ space ] [ offset [ space ] ] "]" */
{
	int ret;

#ifdef DEBUG
	fprintf(stderr, "DEBUG: %s()\n", __func__);
#endif
	state->address = 1;
	/* "[" */
	ret = _parser_scan(state);
	/* [ space ] */
	if(_parser_in_set(state, TS_SPACE))
		ret |= _space(state);
	/* [ sign [ space ] ] */
	if(_parser_in_set(state, TS_SIGN))
	{
		ret |= _sign(state);
		if(_parser_in_set(state, TS_SPACE))
			ret |= _space(state);
	}
	else
		state->negative = 0;
	/* value */
	if(_parser_in_set(state, TS_VALUE))
		ret |= _value(state);
	else
		ret |= _parser_error(state, "%s", "Expected value");
	/* [ space ] */
	if(_parser_in_set(state, TS_SPACE))
		ret |= _space(state);
	/* [ offset [ space ] ] */
	if(_parser_in_set(state, TS_OFFSET))
	{
		state->address = 2;
		ret |= _offset(state);
		if(_parser_in_set(state, TS_SPACE))
			ret |= _space(state);
	}
	state->address = 0;
	/* "]" */
	return ret | _parser_check(state, AS_CODE_OPERATOR_RBRACKET);
}
예제 #17
0
파일: 7obj.c 프로젝트: AustenConrad/plan-9
static Addr
addr(Biobuf *bp)
{
	Addr a;
	vlong off;

	a.type = Bgetc(bp);	/* a.type */
	skip(bp,1);		/* reg */
	a.sym = Bgetc(bp);	/* sym index */
	a.name = Bgetc(bp);	/* sym type */
	switch(a.type){
	default:
	case D_NONE: case D_REG: case D_FREG: case D_PREG:
	case D_FCREG: case D_PCC:
		break;
	case D_OREG:
	case D_CONST:
	case D_BRANCH:
		off = (uvlong)Bgetc(bp);
		off |= (uvlong)Bgetc(bp) << 8;
		off |= (uvlong)Bgetc(bp) << 16;
		off |= (uvlong)Bgetc(bp) << 24;
		off |= (uvlong)Bgetc(bp) << 32;
		off |= (uvlong)Bgetc(bp) << 40;
		off |= (uvlong)Bgetc(bp) << 48;
		off |= (uvlong)Bgetc(bp) << 56;
		if(off < 0)
			off = -off;
		if(a.sym && (a.name==D_PARAM || a.name==D_AUTO))
			_offset(a.sym, off);
		break;
	case D_SCONST:
		skip(bp, NSNAME);
		break;
	case D_FCONST:
		skip(bp, 8);
		break;
	}
	return a;
}
예제 #18
0
peanoclaw::Area peanoclaw::Area::mapCellToPatch(
  const tarch::la::Vector<DIMENSIONS, double>& finePosition,
  const tarch::la::Vector<DIMENSIONS, double>& fineSubcellSize,
  const tarch::la::Vector<DIMENSIONS, double>& coarseSubcellSize,
  const tarch::la::Vector<DIMENSIONS, int>& coarseSubcellIndex,
  const tarch::la::Vector<DIMENSIONS, double>& coarseSubcellPosition,
  const double& epsilon
) const {
  Area cellArea;

  //cellArea._offset = ((coarseSubcellPosition - finePosition + epsilon) / fineSubcellSize).convertScalar<int>();
  tarch::la::Vector<DIMENSIONS, double> offsetTemp = (coarseSubcellPosition - finePosition + epsilon);
  for (int d=0; d < DIMENSIONS; d++) {
    offsetTemp[d] /= fineSubcellSize[d];
  }
  cellArea._offset = offsetTemp.convertScalar<int>();

 
  //cellArea._size = ((coarseSubcellPosition + coarseSubcellSize - finePosition - epsilon) / fineSubcellSize - cellArea._offset.convertScalar<double>() + 1.0).convertScalar<int>();
  tarch::la::Vector<DIMENSIONS, double> sizeTemp = coarseSubcellPosition + coarseSubcellSize - finePosition - epsilon;
  for (int d=0; d < DIMENSIONS; d++) {
    sizeTemp[d] /= fineSubcellSize[d];
  }
  sizeTemp -= offsetTemp;
  sizeTemp += 1.0;
  cellArea._size = sizeTemp.convertScalar<int>();

  tarch::la::Vector<DIMENSIONS, int> cellAreaUpperBound = cellArea._offset + cellArea._size;
  tarch::la::Vector<DIMENSIONS, int> areaUpperBound = _offset + _size;
  for(int d = 0; d < DIMENSIONS; d++) {
    cellArea._offset(d) = std::max(cellArea._offset(d), _offset(d));
    cellArea._size(d) = std::min(cellAreaUpperBound(d), areaUpperBound(d));
  }
  cellArea._size -= cellArea._offset;

  return cellArea;
}
예제 #19
0
static void 
draw_node(cairo_t *cr, designer_node_t *n, int flags)
{
    designer_node_type_t *nt = n->type;
    node_type_data_t *ntd = node_type_data(nt);
    node_data_t *nd = node_data(n);

    _point_t pos = nd->origin;

    cairo_save(cr);
    cairo_translate(cr, pos.x, pos.y);

    /* drop shadow */
    cairo_set_source_rgba(cr, RGBA_DROP_SHADOW);
    round_path(cr, _offset(nd->nr, _size(3, 3)), round_s);
    cairo_fill(cr);

    /* title area color */
    cairo_set_source_rgba(cr, RGBA_TITLE_AREA);
    round_path(cr, nd->tr, upper_s);
    cairo_fill(cr);

    /* title text */
    set_title_font(cr);
    cairo_set_source_rgba(cr, RGBA_TITLE_TEXT);
    cairo_move_to(cr, nd->lr.o.x - 1, 
	nd->lr.o.y + nd->lr.s.h - 1);
    cairo_show_text(cr, n->name);

    /* close button */
    cairo_set_line_width(cr, 1.0);
    rect_path(cr, nd->xr);
    cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.8);
    cairo_fill_preserve(cr);
    cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.5);
    cairo_stroke(cr);
    cross_path(cr, nd->xr, 2);
    cairo_stroke(cr);

    /* body area color */
    cairo_set_source_rgba(cr, RGBA_BODY_AREA);
    round_path(cr, nd->br, lower_s);
    cairo_fill(cr);

#if 0
    /* slot border */
    cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.3);
    cairo_set_line_width(cr, 1.0);
    rect_path(cr, nd->ir);
    cairo_stroke(cr);
    rect_path(cr, nd->or);
    cairo_stroke(cr);
#endif

    /* prepare for slots */
    cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.6);
    cairo_set_line_width(cr, 1.0);
    set_slot_font(cr);

    /* input slots */
    for (int i=0; i<ntd->is; i++) {
	designer_slot_spec_t *slot =
	    g_slist_nth_data(nt->input_slot_specs, i);
	slot_spec_data_t *ssd = slot_spec_data(slot);
	_point_t sl = _move(nd->ir.o, ssd->offset);
	
	cairo_move_to(cr, sl.x + 6, sl.y + 3);
	cairo_show_text(cr, slot->name);
	cairo_stroke(cr);
	circle_path(cr, sl, 3.0);
	cairo_stroke(cr);
    }

    for (int i=0; i<ntd->os; i++) {
	designer_slot_spec_t *slot =
	    g_slist_nth_data(nt->output_slot_specs, i);
	slot_spec_data_t *ssd = slot_spec_data(slot);
	_rect_t sr = text_rect(cr, slot->name);
	_point_t sl = _move(nd->or.o, ssd->offset);

	cairo_move_to(cr, sl.x - sr.s.w - 8, sl.y + 3);
	cairo_show_text(cr, slot->name);
	cairo_stroke(cr);
	circle_path(cr, sl, 3.0);
	cairo_stroke(cr);
    }
    /* filter border */
    cairo_set_line_width(cr, 1.0);
    cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.8);
    round_path(cr, nd->nr, round_s);
    cairo_stroke(cr);

    cairo_move_to(cr, nd->br.o.x, nd->br.o.y);
    cairo_line_to(cr, nd->br.o.x + nd->br.s.w, nd->br.o.y);
    cairo_stroke(cr);

    /* root node? */
    if (flags & 0x1) {
	cairo_set_line_width(cr, 2.0);
	cairo_set_source_rgba(cr, RGBA_ROOT_NODE);
	// cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
	// cairo_set_dash(cr, round_d, 2, 0);
	round_path(cr, _inset(nd->nr, _size(-3,-3)), rnd13_s);
	cairo_stroke(cr);
    }


/*
    rect_path(cr, nd->ir);
    cairo_stroke(cr);
    rect_path(cr, nd->or);
    cairo_stroke(cr); */

    cairo_restore(cr);
}
예제 #20
0
void PostscriptIO::write (const std::string& fname)
{
  // We may need to gather a ParallelMesh to output it, making that
  // const qualifier in our constructor a dirty lie
  MeshSerializer serialize(const_cast<MeshBase&>(this->mesh()), !_is_parallel_format);

  if (this->mesh().processor_id() == 0)
    {
      // Get a constant reference to the mesh.
      const MeshBase& the_mesh = MeshOutput<MeshBase>::mesh();

      // Only works in 2D
      libmesh_assert_equal_to (the_mesh.mesh_dimension(), 2);

      // Create output file stream.
      // _out is now a private member of the class.
      _out.open(fname.c_str());

      // Make sure it opened correctly
      if (!_out.good())
        libmesh_file_error(fname.c_str());

      // The mesh bounding box gives us info about what the
      // Postscript bounding box should be.
      MeshTools::BoundingBox bbox = MeshTools::bounding_box(the_mesh);

      // Add a little extra padding to the "true" bounding box so
      // that we can still see the boundary
      const Real percent_padding = 0.01;
      const Real dx=bbox.second(0)-bbox.first(0); libmesh_assert_greater (dx, 0.0);
      const Real dy=bbox.second(1)-bbox.first(1); libmesh_assert_greater (dy, 0.0);

      const Real x_min = bbox.first(0)  - percent_padding*dx;
      const Real y_min = bbox.first(1)  - percent_padding*dy;
      const Real x_max = bbox.second(0) + percent_padding*dx;
      const Real y_max = bbox.second(1) + percent_padding*dy;

      // Width of the output as given in postscript units.
      // This usually is given by the strange unit 1/72 inch.
      // A width of 300 represents a size of roughly 10 cm.
      const Real width = 300;
      _scale = width / (x_max-x_min);
      _offset(0) = x_min;
      _offset(1) = y_min;

      // Header writing stuff stolen from Deal.II
      std::time_t  time1= std::time (0);
      std::tm     *time = std::localtime(&time1);
      _out << "%!PS-Adobe-2.0 EPSF-1.2" << '\n'
	//<< "%!PS-Adobe-1.0" << '\n' // Lars' PS version
	  << "%%Filename: " << fname << '\n'
	  << "%%Title: LibMesh Output" << '\n'
	  << "%%Creator: LibMesh: A C++ finite element library" << '\n'
	  << "%%Creation Date: "
	  << time->tm_year+1900 << "/"
	  << time->tm_mon+1 << "/"
	  << time->tm_mday << " - "
	  << time->tm_hour << ":"
	  << std::setw(2) << time->tm_min << ":"
	  << std::setw(2) << time->tm_sec << '\n'
	  << "%%BoundingBox: "
	// lower left corner
	  << "0 0 "
	// upper right corner
	  << static_cast<unsigned int>( rint((x_max-x_min) * _scale ))
	  << ' '
	  << static_cast<unsigned int>( rint((y_max-y_min) * _scale ))
	  << '\n';

      // define some abbreviations to keep
      // the output small:
      // m=move turtle to
      // l=define a line
      // s=set rgb color
      // sg=set gray value
      // lx=close the line and plot the line
      // lf=close the line and fill the interior
      _out << "/m {moveto} bind def"      << '\n'
	  << "/l {lineto} bind def"      << '\n'
	  << "/s {setrgbcolor} bind def" << '\n'
	  << "/sg {setgray} bind def"    << '\n'
	  << "/cs {curveto stroke} bind def" << '\n'
	  << "/lx {lineto closepath stroke} bind def" << '\n'
	  << "/lf {lineto closepath fill} bind def"   << '\n';

      _out << "%%EndProlog" << '\n';
      //	  << '\n';

      // Set line width in the postscript file.
      _out << line_width << " setlinewidth" << '\n';

      // Set line cap and join options
      _out << "1 setlinecap" << '\n';
      _out << "1 setlinejoin" << '\n';

      // allow only five digits for output (instead of the default
      // six); this should suffice even for fine grids, but reduces
      // the file size significantly
      _out << std::setprecision (5);

      // Loop over the active elements, draw lines for the edges.  We
      // draw even quadratic elements with straight sides, i.e. a straight
      // line sits between each pair of vertices.  Also we draw every edge
      // for an element regardless of the fact that it may overlap with
      // another.  This would probably be a useful optimization...
      MeshBase::const_element_iterator       el     = the_mesh.active_elements_begin();
      const MeshBase::const_element_iterator end_el = the_mesh.active_elements_end();
      for ( ; el != end_el; ++el)
	{
	  //const Elem* elem = *el;

	  this->plot_linear_elem(*el);
	  //this->plot_quadratic_elem(*el); // Experimental
	}

      // Issue the showpage command, and we're done.
      _out << "showpage" << std::endl;

    } // end if (this->mesh().processor_id() == 0)
}
예제 #21
0
파일: plsub.c 프로젝트: EQ4/SPTK
int offset(double x, double y)
{
   _offset(_plnorm(x), _plnorm(y));
   return (0);
}
void peano::applications::latticeboltzmann::blocklatticeboltzmann::configurations::PlaneBoundaryConfiguration::
parseInterval(std::string interval){
  for (int d = 0; d < DIMENSIONS; d++){
    std::string number1("");
    std::string number2("");
    tarch::irr::io::IrrXMLReader* getNumbers = tarch::irr::io::createIrrXMLReaderFromString("");
    size_t closedPos1   = interval.find("[");
    size_t openPos1     = interval.find("(");
    size_t closedPos2   = interval.find("]");
    size_t openPos2     = interval.find(")");
    size_t semicolonPos = interval.find(";");
    size_t first = 0;
    size_t last = 0;

    // determine left bracket position
    if ( (closedPos1 == std::string::npos) && (openPos1 == std::string::npos) ){
      logDebug("parseInterval()", "No left brackets found!");
      assertion(false);
    }
    if (closedPos1 == std::string::npos){
      first = openPos1;
    }
    if (openPos1 == std::string::npos){
      first = closedPos1;
    }
    if ( (closedPos1 != std::string::npos) && (openPos1 != std::string::npos) ){
      first = std::min(closedPos1,openPos1);
    }

    // determine right bracket position
    if ( (closedPos2 == std::string::npos) && (openPos2 == std::string::npos) ){
      logDebug("parseInterval()", "No right brackets found!");
      assertion(false);
    }
    if (closedPos2 == std::string::npos){
      last = openPos2;
    }
    if (openPos2 == std::string::npos){
      last = closedPos2;
    }
    if ( (closedPos2 != std::string::npos) && (openPos2 != std::string::npos) ){
      last = std::min(closedPos2,openPos2);
    }

    // check validity
    if (first >= last){
      logDebug("parseInterval()", "Right brackets before left brackets!");
      assertion(false);
    }
    if ( (semicolonPos <=first) || (semicolonPos >= last) || (semicolonPos == std::string::npos) ){
      logDebug("parseInterval()", "No valid semicolon separation could not be detected!");
      assertion(false);
    }

    // find out type of brackets
    if (first == closedPos1){
      _isOpen(2*d) = false;
    } else {
      _isOpen(2*d) = true;
    }
    if (last == closedPos2){
      _isOpen(2*d+1) = false;
    } else {
      _isOpen(2*d+1) = true;
    }

    // get start and end interval and set offset and width of box range
    number1 = interval.substr(first+1,semicolonPos-1-first);
    number2 = interval.substr(semicolonPos+1,last-1-semicolonPos);
    _offset(d) = getNumbers->convertValueStringToDouble( number1 );
    _width(d) = getNumbers->convertValueStringToDouble(number2) - _offset(d);
    logDebug("parseInterval()", "Number1: " << number1 << " offset " << d << ": " << _offset(d));
    logDebug("parseInterval()", "Number2: " << number2 << " width " << d << ": " << _width(d));

    // remove this part from string
    interval = interval.substr(last+1);

    // find sign 'x' and next left bracket
    if (d < DIMENSIONS-1){
      size_t closedNext = interval.find("[");
      size_t openNext = interval.find("(");
      first = interval.find("x");

      if ( (closedNext == std::string::npos) && (openNext == std::string::npos) ){
        logDebug("parseInterval()", "No new left brackets found!");
        assertion(false);
      }
      if (closedNext == std::string::npos){
        last = openNext;
      }
      if (openNext == std::string::npos){
        last = closedNext;
      }
      if ( (closedNext != std::string::npos) && (openNext != std::string::npos) ){
        last = std::min(closedNext,openNext);
      }

      if (last <= first){
        logDebug("parseInterval()", "No 'x' between intervals could be found!");
        assertion(false);
      }

      // remove all just until the first letter behind 'x'
      interval = interval.substr(first+1);
    }
    logDebug("parseInterval()", "Rest to parse: " << interval);

  }

  // check width
  for (int d = 0; d < DIMENSIONS; d++){
    if (tarch::la::smaller(_width(d),0.0)){
      logDebug("parseInterval()", "Width of box is smaller than zero!");
      assertion(false);
    }
  }
}
예제 #23
0
bool MgBaseShape::offset(const Vector2d& vec, int segment) {
    return _offset(vec, segment);
}
예제 #24
0
uint32_t _left( struct buffer * self )
{
    return (uint32_t)( self->capacity - _offset(self) - self->length );
}
예제 #25
0
ClipperLib::Paths _offset(ClipperLib::Path &&input, ClipperLib::EndType endType, const float delta, ClipperLib::JoinType joinType, double miterLimit)
{
    ClipperLib::Paths paths;
    paths.emplace_back(std::move(input));
	return _offset(std::move(paths), endType, delta, joinType, miterLimit);
}
예제 #26
0
MusicPanel::MusicPanel(wxWindow* parent)
{
    wxIntegerValidator<int> _bars(&__bars, wxNUM_VAL_THOUSANDS_SEPARATOR);
    _bars.SetMin(1);
    _bars.SetMax(100);
    wxIntegerValidator<int> _startNote(&__startNote, wxNUM_VAL_THOUSANDS_SEPARATOR);
    _startNote.SetMin(0);
    _startNote.SetMax(127);
    wxIntegerValidator<int> _endNote(&__endNote, wxNUM_VAL_THOUSANDS_SEPARATOR);
    _endNote.SetMin(0);
    _endNote.SetMax(127);
    wxIntegerValidator<int> _sensitivity(&__sensitivity, wxNUM_VAL_THOUSANDS_SEPARATOR);
    _sensitivity.SetMin(0);
    _sensitivity.SetMax(100);
    wxIntegerValidator<int> _offset(&__offset, wxNUM_VAL_THOUSANDS_SEPARATOR);
    _offset.SetMin(0);
    _offset.SetMax(100);

	//(*Initialize(MusicPanel)
	wxFlexGridSizer* FlexGridSizer42;
	wxFlexGridSizer* FlexGridSizer31;

	Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("wxID_ANY"));
	FlexGridSizer42 = new wxFlexGridSizer(0, 1, 0, 0);
	FlexGridSizer42->AddGrowableCol(0);
	FlexGridSizer31 = new wxFlexGridSizer(0, 4, 0, 0);
	FlexGridSizer31->AddGrowableCol(1);
	StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Bars"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
	FlexGridSizer31->Add(StaticText1, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2);
	Slider_Music_Bars = new wxSlider(this, IDD_SLIDER_Music_Bars, 20, 1, 100, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("IDD_SLIDER_Music_Bars"));
	FlexGridSizer31->Add(Slider_Music_Bars, 1, wxALL|wxEXPAND, 2);
	TextCtrl_Music_Bars = new wxTextCtrl(this, ID_TEXTCTRL_Music_Bars, _("20"), wxDefaultPosition, wxDLG_UNIT(this,wxSize(20,-1)), 0, _bars, _T("ID_TEXTCTRL_Music_Bars"));
	FlexGridSizer31->Add(TextCtrl_Music_Bars, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2);
	BitmapButton_Music_Bars = new wxBitmapButton(this, ID_BITMAPBUTTON_CHOICE_Music_Bars, wxNullBitmap, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_CHOICE_Music_Bars"));
	BitmapButton_Music_Bars->SetDefault();
	BitmapButton_Music_Bars->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION));
	FlexGridSizer31->Add(BitmapButton_Music_Bars, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2);
	StaticText2 = new wxStaticText(this, ID_STATICTEXT2, _("Type"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2"));
	FlexGridSizer31->Add(StaticText2, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2);
	Choice_Music_Type = new wxChoice(this, ID_CHOICE_Music_Type, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_CHOICE_Music_Type"));
	Choice_Music_Type->SetSelection( Choice_Music_Type->Append(_("Morph")) );
	Choice_Music_Type->Append(_("Bounce"));
	Choice_Music_Type->Append(_("Collide"));
	Choice_Music_Type->Append(_("Seperate"));
	Choice_Music_Type->Append(_("On"));
	FlexGridSizer31->Add(Choice_Music_Type, 1, wxALL|wxEXPAND, 2);
	FlexGridSizer31->Add(-1,-1,1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	BitmapButton_Music_Type = new wxBitmapButton(this, ID_BITMAPBUTTON_CHOICE_Music_Type, wxNullBitmap, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_CHOICE_Music_Type"));
	BitmapButton_Music_Type->SetDefault();
	BitmapButton_Music_Type->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION));
	FlexGridSizer31->Add(BitmapButton_Music_Type, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2);
	StaticText12 = new wxStaticText(this, ID_STATICTEXT12, _("Start Note"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT12"));
	FlexGridSizer31->Add(StaticText12, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2);
	Slider_Music_StartNote = new wxSlider(this, IDD_SLIDER_Music_StartNote, 60, 0, 127, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("IDD_SLIDER_Music_StartNote"));
	FlexGridSizer31->Add(Slider_Music_StartNote, 1, wxALL|wxEXPAND, 2);
	TextCtrl_Music_StartNote = new wxTextCtrl(this, ID_TEXTCTRL_Music_StartNote, _("60"), wxDefaultPosition, wxDLG_UNIT(this,wxSize(20,-1)), 0, _startNote, _T("ID_TEXTCTRL_Music_StartNote"));
	FlexGridSizer31->Add(TextCtrl_Music_StartNote, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2);
	BitmapButton_Music_StartNote = new wxBitmapButton(this, ID_BITMAPBUTTON_Music_StartNote, wxNullBitmap, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_Music_StartNote"));
	BitmapButton_Music_StartNote->SetDefault();
	BitmapButton_Music_StartNote->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION));
	FlexGridSizer31->Add(BitmapButton_Music_StartNote, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	StaticText11 = new wxStaticText(this, ID_STATICTEXT11, _("End Note"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT11"));
	FlexGridSizer31->Add(StaticText11, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2);
	Slider_Music_EndNote = new wxSlider(this, IDD_SLIDER_Music_EndNote, 80, 0, 127, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("IDD_SLIDER_Music_EndNote"));
	FlexGridSizer31->Add(Slider_Music_EndNote, 1, wxALL|wxEXPAND, 2);
	TextCtrl_Music_EndNote = new wxTextCtrl(this, ID_TEXTCTRL_Music_EndNote, _("80"), wxDefaultPosition, wxDLG_UNIT(this,wxSize(20,-1)), 0, _endNote, _T("ID_TEXTCTRL_Music_EndNote"));
	FlexGridSizer31->Add(TextCtrl_Music_EndNote, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2);
	BitmapButton_Music_EndNote = new wxBitmapButton(this, ID_BITMAPBUTTON_Music_EndNote, wxNullBitmap, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_Music_EndNote"));
	BitmapButton_Music_EndNote->SetDefault();
	BitmapButton_Music_EndNote->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION));
	FlexGridSizer31->Add(BitmapButton_Music_EndNote, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	StaticText4 = new wxStaticText(this, ID_STATICTEXT4, _("Sensitivity"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT4"));
	FlexGridSizer31->Add(StaticText4, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2);
	Slider_Music_Sensitivity = new wxSlider(this, IDD_SLIDER_Music_Sensitivity, 50, 0, 100, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("IDD_SLIDER_Music_Sensitivity"));
	FlexGridSizer31->Add(Slider_Music_Sensitivity, 1, wxALL|wxEXPAND, 2);
	TextCtrl_Music_Sensitivity = new wxTextCtrl(this, ID_TEXTCTRL_Music_Sensitivity, _("50"), wxDefaultPosition, wxDLG_UNIT(this,wxSize(20,-1)), 0, _sensitivity, _T("ID_TEXTCTRL_Music_Sensitivity"));
	FlexGridSizer31->Add(TextCtrl_Music_Sensitivity, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2);
	BitmapButton_Music_Sensitivity = new wxBitmapButton(this, ID_BITMAPBUTTON_Music_Sensitivty, wxNullBitmap, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_Music_Sensitivty"));
	BitmapButton_Music_Sensitivity->SetDefault();
	BitmapButton_Music_Sensitivity->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION));
	FlexGridSizer31->Add(BitmapButton_Music_Sensitivity, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2);
	StaticText3 = new wxStaticText(this, ID_STATICTEXT3, _("Offset"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT3"));
	FlexGridSizer31->Add(StaticText3, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2);
	Slider_Music_Offset = new wxSlider(this, IDD_SLIDER_Music_Offset, 0, 0, 100, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("IDD_SLIDER_Music_Offset"));
	FlexGridSizer31->Add(Slider_Music_Offset, 1, wxALL|wxEXPAND, 2);
	TextCtrl_Music_Offset = new wxTextCtrl(this, ID_TEXTCTRL_Music_Offset, _("0"), wxDefaultPosition, wxDLG_UNIT(this,wxSize(20,-1)), 0, _offset, _T("ID_TEXTCTRL_Music_Offset"));
	FlexGridSizer31->Add(TextCtrl_Music_Offset, 1, wxALL|wxEXPAND, 2);
	BitmapButton_Music_Offset = new wxBitmapButton(this, ID_BITMAPBUTTON_Music_Offset, wxNullBitmap, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_Music_Offset"));
	BitmapButton_Music_Offset->SetDefault();
	BitmapButton_Music_Offset->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION));
	FlexGridSizer31->Add(BitmapButton_Music_Offset, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2);
	FlexGridSizer31->Add(-1,-1,1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	CheckBox_Music_Scale = new wxCheckBox(this, ID_CHECKBOX_Music_Scale, _("Scale Bars"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX_Music_Scale"));
	CheckBox_Music_Scale->SetValue(false);
	FlexGridSizer31->Add(CheckBox_Music_Scale, 1, wxALL|wxEXPAND, 2);
	FlexGridSizer31->Add(-1,-1,1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	BitmapButton_Music_Scale = new wxBitmapButton(this, ID_BITMAPBUTTON_Music_Scale, wxNullBitmap, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_Music_Scale"));
	BitmapButton_Music_Scale->SetDefault();
	BitmapButton_Music_Scale->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION));
	FlexGridSizer31->Add(BitmapButton_Music_Scale, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2);
	StaticText5 = new wxStaticText(this, ID_STATICTEXT5, _("Notes Scaling"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT5"));
	FlexGridSizer31->Add(StaticText5, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2);
	Choice_Music_Scaling = new wxChoice(this, ID_CHOICE_Music_Scaling, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_CHOICE_Music_Scaling"));
	Choice_Music_Scaling->Append(_("None"));
	Choice_Music_Scaling->Append(_("Individual Notes"));
	Choice_Music_Scaling->SetSelection( Choice_Music_Scaling->Append(_("All Notes")) );
	FlexGridSizer31->Add(Choice_Music_Scaling, 1, wxALL|wxEXPAND, 2);
	FlexGridSizer31->Add(-1,-1,1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	BitmapButton_Music_Scaling = new wxBitmapButton(this, ID_BITMAPBUTTON_Music_Scaling, wxNullBitmap, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_Music_Scaling"));
	BitmapButton_Music_Scaling->SetDefault();
	BitmapButton_Music_Scaling->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION));
	FlexGridSizer31->Add(BitmapButton_Music_Scaling, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2);
	StaticText6 = new wxStaticText(this, ID_STATICTEXT6, _("Color"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT6"));
	FlexGridSizer31->Add(StaticText6, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2);
	Choice_Music_Colour = new wxChoice(this, ID_CHOICE_Music_Colour, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_CHOICE_Music_Colour"));
	Choice_Music_Colour->SetSelection( Choice_Music_Colour->Append(_("Distinct")) );
	Choice_Music_Colour->Append(_("Blend"));
	Choice_Music_Colour->Append(_("Cycle"));
	FlexGridSizer31->Add(Choice_Music_Colour, 1, wxALL|wxEXPAND, 2);
	FlexGridSizer31->Add(-1,-1,1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	BitmapButton_Music_Colour = new wxBitmapButton(this, ID_BITMAPBUTTON_Music_Colour, wxNullBitmap, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_Music_Colour"));
	BitmapButton_Music_Colour->SetDefault();
	BitmapButton_Music_Colour->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION));
	FlexGridSizer31->Add(BitmapButton_Music_Colour, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	FlexGridSizer31->Add(-1,-1,1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	CheckBox_Music_Fade = new wxCheckBox(this, ID_CHECKBOX_Music_Fade, _("Fade"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX_Music_Fade"));
	CheckBox_Music_Fade->SetValue(false);
	FlexGridSizer31->Add(CheckBox_Music_Fade, 1, wxALL|wxEXPAND, 2);
	FlexGridSizer31->Add(-1,-1,1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	BitmapButton_Music_Fade = new wxBitmapButton(this, ID_BITMAPBUTTON_Music_Fade, wxNullBitmap, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_Music_Fade"));
	BitmapButton_Music_Fade->SetDefault();
	BitmapButton_Music_Fade->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION));
	FlexGridSizer31->Add(BitmapButton_Music_Fade, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	FlexGridSizer42->Add(FlexGridSizer31, 1, wxEXPAND, 2);
	SetSizer(FlexGridSizer42);
	FlexGridSizer42->Fit(this);
	FlexGridSizer42->SetSizeHints(this);

	Connect(IDD_SLIDER_Music_Bars,wxEVT_COMMAND_SLIDER_UPDATED,(wxObjectEventFunction)&MusicPanel::UpdateLinkedTextCtrl);
	Connect(ID_TEXTCTRL_Music_Bars,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&MusicPanel::UpdateLinkedSlider);
	Connect(ID_BITMAPBUTTON_CHOICE_Music_Bars,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&MusicPanel::OnLockButtonClick);
	Connect(ID_CHOICE_Music_Type,wxEVT_COMMAND_CHOICE_SELECTED,(wxObjectEventFunction)&MusicPanel::OnChoice_Music_TypeSelect);
	Connect(ID_BITMAPBUTTON_CHOICE_Music_Type,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&MusicPanel::OnLockButtonClick);
	Connect(IDD_SLIDER_Music_StartNote,wxEVT_COMMAND_SLIDER_UPDATED,(wxObjectEventFunction)&MusicPanel::OnSlider_Music_StartNoteCmdSliderUpdated);
	Connect(ID_TEXTCTRL_Music_StartNote,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&MusicPanel::OnTextCtrl_Music_StartNoteText);
	Connect(ID_BITMAPBUTTON_Music_StartNote,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&MusicPanel::OnLockButtonClick);
	Connect(IDD_SLIDER_Music_EndNote,wxEVT_COMMAND_SLIDER_UPDATED,(wxObjectEventFunction)&MusicPanel::OnSlider_Music_StartNoteCmdSliderUpdated);
	Connect(ID_TEXTCTRL_Music_EndNote,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&MusicPanel::OnTextCtrl_Music_StartNoteText);
	Connect(ID_BITMAPBUTTON_Music_EndNote,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&MusicPanel::OnLockButtonClick);
	Connect(IDD_SLIDER_Music_Sensitivity,wxEVT_COMMAND_SLIDER_UPDATED,(wxObjectEventFunction)&MusicPanel::UpdateLinkedTextCtrl);
	Connect(ID_TEXTCTRL_Music_Sensitivity,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&MusicPanel::UpdateLinkedSlider);
	Connect(ID_BITMAPBUTTON_Music_Sensitivty,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&MusicPanel::OnLockButtonClick);
	Connect(IDD_SLIDER_Music_Offset,wxEVT_COMMAND_SLIDER_UPDATED,(wxObjectEventFunction)&MusicPanel::UpdateLinkedTextCtrl);
	Connect(ID_TEXTCTRL_Music_Offset,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&MusicPanel::UpdateLinkedSlider);
	Connect(ID_BITMAPBUTTON_Music_Offset,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&MusicPanel::OnLockButtonClick);
	Connect(ID_BITMAPBUTTON_Music_Scale,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&MusicPanel::OnLockButtonClick);
	Connect(ID_BITMAPBUTTON_Music_Scaling,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&MusicPanel::OnLockButtonClick);
	Connect(ID_BITMAPBUTTON_Music_Colour,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&MusicPanel::OnLockButtonClick);
	Connect(ID_BITMAPBUTTON_Music_Fade,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&MusicPanel::OnLockButtonClick);
	//*)
    SetName("ID_PANEL_Music");

	ValidateWindow();
}
예제 #27
0
bool MgComposite::_setHandlePoint(int index, const Point2d& pt, float)
{
    return _offset(pt - _getHandlePoint(index), -1);
}
예제 #28
0
파일: dbmem.c 프로젝트: cfrantz/pongo
pgctx_t *dbfile_open(const char *filename, uint32_t initsize)
{
	int ret, i;
	dbroot_t *r;
	pgctx_t *ctx;
	mempool_t *pool;
	memheap_t *heap;
	if (initsize == 0) initsize = 16;

	initsize *= 1024*1024;
	// Create a new context
	ctx = malloc(sizeof(*ctx));
	memset(ctx, 0, sizeof(*ctx));
	for(i=0; i<NR_DB_CONTEXT; i++) {
		if (dbctx[i] == NULL) {
			dbctx[i] = ctx;
			break;
		}
	}
	ret = mm_open(&ctx->mm, filename, initsize);
	if (ret < 0)
		return NULL;
	ctx->root = ctx->mm.map[0].ptr;
	pmem_more_memory = dbfile_more_mem;
#ifdef WANT_UUID_TYPE
	ctx->newkey = _newkey;
#endif

	if (strcmp((char*)ctx->root->signature, DBROOT_SIG)) {
		r = ctx->root;
		strcpy((char*)r->signature, DBROOT_SIG);

		pool = pmem_pool_init((char*)ctx->mm.map[0].ptr+4096, ctx->mm.map[0].size-4096);
		heap = pmem_pool_alloc(pool, 4096);
		heap->nr_procheap = (4096-sizeof(*heap)) / sizeof(procheap_t);
		heap->mempool = _offset(ctx, pool);
		pmem_relist_pools(&ctx->mm, heap);
		r->heap = _offset(ctx, heap);

		// Create the root data dictionary
		ctx->data = dbcollection_new(ctx, 0);
		r->data = ctx->data;

		// Not sure about the atom cache...
		//ctx->cache = DBNULL;
		//ctx->cache = dbcache_new(ctx, 0, 0);
		//r->cache = ctx->cache;

		r->pidcache = dbcollection_new(ctx, 0);
		
		r->meta.chunksize = initsize;
		r->meta.id = dbstring_new(ctx, "_id", 3);
	} else {
		ctx->data = ctx->root->data;
		ctx->cache = ctx->root->cache;
		log_verbose("data=%" PRIx64 " cache=%" PRIx64, ctx->data.all, ctx->cache.all);
		// Probably don't want to run the GC here...
		//db_gc(ctx, NULL);
	}

	// Pidcache in "ctx" points to this process' pidcache.
	// The pidcache in root points to the global pidcache (container
	// of pidcaches)
	ctx->pidcache = DBNULL;
	ctx->sync = 1;
	return ctx;
}