Exemplo n.º 1
0
ScaleBarObject
ScaleBarGrabber::scalebar()
{
  ScaleBarObject so;
  so.set(position(), voxels(), type(), textpos());
  return so;
}
Exemplo n.º 2
0
Arquivo: slm.c Projeto: mingpen/OpenNT
void ExitPgm(void)
{
    ResetScrAttrCur(vcolorExitFore, vcolorExitBack, NORMAL);
    clearrows(YMAXSCREEN - 1, YMAXSCREEN);

      /* restore INT24 */
    CloseDisks();

      /* restore CTRL+C handler */
    signal(SIGINT, SIG_DFL);

      /* die nicely at bottom of screen */
    Cursor(TRUE);
    textpos(22, 1);

    exit(1);
}
Exemplo n.º 3
0
void Fl_Tool_Button::preferred_size(int &w, int &h) const
{
    TbTextPos tp = textpos();
    if(tp==POS_DEFAULT) tp = default_textpos();

    TbShowMode sm = showmode();
    if(sm==SHOW_DEFAULT) sm = default_showmode();

    if(sm==SHOW_AUTO) {
        if(image()) sm = SHOW_IMAGE;
        else        sm = SHOW_TEXT;
    }

    int H=0, W=0;
    if(sm&SHOW_TEXT) {
        measure_label(W, H);
    }

    if(sm&SHOW_IMAGE) {
        int bw, bh;
        m_bar->get_icon_size(m_bar->tb_size(), bw, bh);

        if(tp == POS_RIGHT) W += bw;
        else                H += bh;

        if(W < bw) W = bw;
        if(H < bh) H = bh;
    }

    W += box()->dw() + 4;
    H += box()->dh() + 4;

    if(W < H) W = H;

    w = W;
    h = H;
}
Exemplo n.º 4
0
static void drawDebugMaterials() {
	
	if(!ACTIVEBKG || !ACTIVEBKG->exist) {
		return;
	}
	
	PolyType skip = POLY_NODRAW | POLY_HIDE;
	if(GInput->isKeyPressed(Keyboard::Key_LeftShift)) {
		skip |= POLY_TRANS | POLY_WATER;
	}
	
	Vec2f point(DANAEMouse);
	
	Entity * owner = GetFirstInterAtPos(Vec2s(point));
	TextureContainer * material = NULL;
	size_t count = 0;
	Vec2f pp[4];
	Vec2f puv[4];
	PolyType flags;
	
	float minz = std::numeric_limits<float>::max();
	
	for(size_t k = 1; k < entities.size(); k++) {
		
		EntityHandle h = EntityHandle(k);
		if(!entities[h] || !entities[h]->obj) {
			continue;
		}
		Entity * entity = entities[h];
		
		if((entity->ioflags & IO_CAMERA) || (entity->ioflags & IO_MARKER))
			continue;
		
		if(!(entity->gameFlags & GFLAG_ISINTREATZONE))
			continue;
		if((entity->gameFlags & GFLAG_INVISIBILITY))
			continue;
		if((entity->gameFlags & GFLAG_MEGAHIDE))
			continue;
		
		switch(entity->show) {
			case SHOW_FLAG_DESTROYED:    continue;
			case SHOW_FLAG_IN_INVENTORY: continue;
			case SHOW_FLAG_ON_PLAYER:    continue;
			case SHOW_FLAG_LINKED:       break;
			case SHOW_FLAG_NOT_DRAWN:    continue;
			case SHOW_FLAG_HIDDEN:       continue;
			case SHOW_FLAG_MEGAHIDE:     continue;
			case SHOW_FLAG_KILLED:       continue;
			case SHOW_FLAG_IN_SCENE:     break;
			case SHOW_FLAG_TELEPORTING:  break;
		}
		
		if(!entity->bbox2D.valid()) {
			continue;
		}
		
		for(size_t j = 0; j < entity->obj->facelist.size(); j++) {
			const EERIE_FACE & face = entity->obj->facelist[j];
			
			if(face.facetype & skip) {
				continue;
			}
			
			bool valid = true;
			bool bvalid = false;
			Vec3f p[3];
			Vec2f uv[3];
			for(size_t i = 0; i < 3; i++) {
				unsigned short v = face.vid[i];
				valid = valid && v < entity->obj->vertexlist3.size();
				if(valid) {
					if(entity->animlayer[0].cur_anim) {
						p[i] = entity->obj->vertexlist3[v].vert.p;
						uv[i] = entity->obj->vertexlist3[v].vert.uv;
					} else {
						p[i] = entity->obj->vertexlist[v].vert.p;
						uv[i] = entity->obj->vertexlist[v].vert.uv;
					}
					valid = valid && (p[i].z > 0.000001f);
					bvalid = bvalid || (p[i].x >= g_size.left && p[i].x < g_size.right
					                 && p[i].y >= g_size.top && p[i].y < g_size.bottom);
				}
			}
			
			if(!valid || !bvalid) {
				continue;
			}
			
			float z = pointInTriangle(point, p[0], p[1], p[2]);
			
			if(z > 0 && z <= minz) {
				count = 3;
				for(size_t i = 0; i < count; i++) {
					pp[i] = Vec2f(p[i].x, p[i].y);
					puv[i] = uv[i];
				}
				if(face.texid >= 0 && size_t(face.texid) < entity->obj->texturecontainer.size()) {
					material = entity->obj->texturecontainer[face.texid];
				} else {
					material = NULL;
				}
				owner = entity;
				minz = z;
				flags = face.facetype & ~(POLY_WATER | POLY_LAVA);
			}
			
		}
	}
	
	for(short z = 0; z < ACTIVEBKG->Zsize; z++)
	for(short x = 0; x < ACTIVEBKG->Xsize; x++) {
		const EERIE_BKG_INFO & feg = ACTIVEBKG->fastdata[x][z];
		
		if(!feg.treat) {
			continue;
		}
		
		for(long l = 0; l < feg.nbpolyin; l++) {
			EERIEPOLY * ep = feg.polyin[l];
			
			if(!ep) {
				continue;
			}
			
			if(ep->type & skip) {
				continue;
			}
			
			bool valid = true;
			bool bvalid = false;
			Vec3f p[4];
			for(size_t i = 0; i < ((ep->type & POLY_QUAD) ? 4u : 3u); i++) {
				TexturedVertex tv;
				tv.p = EE_RT(ep->v[i].p);
				valid = valid && (tv.p.z > 0.000001f);
				EE_P(tv.p, tv);
				bvalid = bvalid || (tv.p.x >= g_size.left && tv.p.x < g_size.right
				                 && tv.p.y >= g_size.top && tv.p.y < g_size.bottom);
				p[i] = tv.p;
			}
			
			if(!valid || !bvalid) {
				continue;
			}
			
			float z = pointInTriangle(point, p[0], p[1], p[2]);
			if(z <= 0 && (ep->type & POLY_QUAD)) {
				z = pointInTriangle(point, p[1], p[3], p[2]);
			}
			
			if(z > 0 && z <= minz) {
				count = ((ep->type & POLY_QUAD) ? 4 : 3);
				for(size_t i = 0; i < count; i++) {
					pp[i] = Vec2f(p[i].x, p[i].y);
					puv[i] = ep->v[i].uv;
				}
				material = ep->tex;
				owner = NULL;
				minz = z;
				flags = ep->type;
			}
			
		}
	}
	
	if(count) {
		
		GRenderer->SetRenderState(Renderer::DepthTest, false);
		
		drawLine2D(pp[0], pp[1], 0.1f, Color::magenta);
		drawLine2D(pp[2], pp[0], 0.1f, Color::magenta);
		if(count == 4) {
			drawLine2D(pp[2], pp[3], 0.1f, Color::magenta);
			drawLine2D(pp[3], pp[1], 0.1f, Color::magenta);
		} else {
			drawLine2D(pp[1], pp[2], 0.1f, Color::magenta);
		}
		
		Vec2f c = Vec2f(0.f);
		float miny = std::numeric_limits<float>::max();
		float maxy = std::numeric_limits<float>::min();
		for(size_t i = 0; i < count; i++) {
			c += pp[i];
			miny = std::min(miny, pp[i].y);
			maxy = std::max(maxy, pp[i].y);
		}
		c *= 1.f / count;
		
		Vec2f textpos(c.x, miny - 2 * hFontDebug->getLineHeight());
		
		std::ostringstream oss;
		
		if(owner) {
			textpos.y -= hFontDebug->getLineHeight();
		}
		if(material && material->m_pTexture) {
			textpos.y -= hFontDebug->getLineHeight();
		}
		if((flags & (POLY_WATER | POLY_LAVA)) && enviro && enviro->m_pTexture) {
			textpos.y -= hFontDebug->getLineHeight();
		}
		if(textpos.y < g_size.top + 5) {
			textpos.y = maxy + 2 * hFontDebug->getLineHeight();
		}
		
		
		if(owner) {
			drawTextCentered(hFontDebug, textpos, owner->idString(), Color::cyan);
			textpos.y += hFontDebug->getLineHeight();
		}
		if(material && material->m_pTexture) {
			drawDebugMaterialTexture(textpos, "Diffuse: ", *material->m_pTexture, Color::green);
		}
		if((flags & (POLY_WATER | POLY_LAVA)) && enviro && enviro->m_pTexture) {
			oss.str(std::string());
			oss << "Animation: ";
			oss << ((flags & (POLY_LAVA)) ? "lava" : "water");
			if(flags & POLY_FALL) {
				oss << " (flowing)";
			}
			drawDebugMaterialTexture(textpos, oss.str(), *enviro->m_pTexture, Color::yellow);
		}
		
		(void)textpos;
		
		for(size_t i = 0; i < count; i++) {
			
			oss.str(std::string());
			oss.setf(std::ios_base::fixed, std::ios_base::floatfield);
			oss.precision(2);
			oss << '(' << puv[i].x << ',' << puv[i].y << ')';
			std::string text = oss.str();
			
			Vec2f textpos = pp[i];
			if(pp[i].y < c.y) {
				textpos.y -= hFontDebug->getLineHeight();
			}
			
			if(pp[i].x < c.x) {
				Vec2i size = hFontDebug->getTextSize(text);
				textpos.x -= size.x;
			}
			
			hFontDebug->draw(textpos.x, textpos.y, text, Color::gray(0.7f));
		}
		
		GRenderer->SetRenderState(Renderer::DepthTest, true);
		
	}
	
}
void DXF2BRD_CONVERTER::addMText( const DRW_MText& aData )
{
    wxString    text = toNativeString( wxString::FromUTF8( aData.text.c_str() ) );
    wxString    attrib, tmp;

    /* Some texts start by '\' and have formating chars (font name, font option...)
     *  ending with ';'
     *  Here are some mtext formatting codes:
     *  Format code        Purpose
     * \0...\o            Turns overline on and off
     *  \L...\l            Turns underline on and off
     * \~                 Inserts a nonbreaking space
     \\                 Inserts a backslash
     \\\{...\}            Inserts an opening and closing brace
     \\ \File name;        Changes to the specified font file
     \\ \Hvalue;           Changes to the text height specified in drawing units
     \\ \Hvaluex;          Changes the text height to a multiple of the current text height
     \\ \S...^...;         Stacks the subsequent text at the \, #, or ^ symbol
     \\ \Tvalue;           Adjusts the space between characters, from.75 to 4 times
     \\ \Qangle;           Changes obliquing angle
     \\ \Wvalue;           Changes width factor to produce wide text
     \\ \A                 Sets the alignment value; valid values: 0, 1, 2 (bottom, center, top)    while( text.StartsWith( wxT("\\") ) )
     */
    while( text.StartsWith( wxT( "\\" ) ) )
    {
        attrib << text.BeforeFirst( ';' );
        tmp     = text.AfterFirst( ';' );
        text    = tmp;
    }

    BOARD_ITEM* brdItem;
    EDA_TEXT* textItem;

    if( m_useModuleItems )
    {
        TEXTE_MODULE* modText = new TEXTE_MODULE( NULL );
        brdItem = static_cast< BOARD_ITEM* >( modText );
        textItem = static_cast< EDA_TEXT* >( modText );
    }
    else
    {
        TEXTE_PCB* pcbText = new TEXTE_PCB( NULL );
        brdItem = static_cast< BOARD_ITEM* >( pcbText );
        textItem = static_cast< EDA_TEXT* >( pcbText );
    }

    brdItem->SetLayer( ToLAYER_ID( m_brdLayer ) );
    wxPoint     textpos( mapX( aData.basePoint.x ), mapY( aData.basePoint.y ) );

    textItem->SetTextPos( textpos );
    textItem->SetTextAngle( aData.angle * 10 );

    // The 0.8 factor gives a better height/width ratio with our font
    textItem->SetTextWidth( mapDim( aData.height * 0.8 ) );
    textItem->SetTextHeight( mapDim( aData.height ) );
    textItem->SetThickness( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) );
    textItem->SetText( text );

    // Initialize text justifications:
    if( aData.textgen <= 3 )
    {
        textItem->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
    }
    else if( aData.textgen <= 6 )
    {
        textItem->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
    }
    else
    {
        textItem->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
    }

    if( aData.textgen % 3 == 1 )
    {
        textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
    }
    else if( aData.textgen % 3 == 2 )
    {
        textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
    }
    else
    {
        textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
    }

#if 0   // These setting have no mening in Pcbnew
    if( data.alignH == 1 )
    {
        // Text is left to right;
    }
    else if( data.alignH == 3 )
    {
        // Text is top to bottom;
    }
    else
    {
        // use ByStyle;
    }

    if( aData.alignV == 1 )
    {
        // use AtLeast;
    }
    else
    {
        // useExact;
    }
#endif

    m_newItemsList.push_back( static_cast< BOARD_ITEM* >( brdItem ) );
}