![]() |
|
| |
![]() |
#1 |
高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
![]() |
![]() query regarding oddbtext alignment and position
query regarding oddbtext alignment and position hi all, i have a query regarding setting the alignment option for oddbtext entity. i have done this by the following piece of code.. and i have not used any fonts. pblock = m_pdb->getmodelspaceid().safeopenobject(oddb::kforwrite) ; ptext = oddbtext::createobject(); ptext->setposition(odgepoint3d(ptx, pty, 0)); ptext->recordgraphicsmodified(false); ptext->setheight(10); ptext->setwidthfactor(3); ptext->settextstyle(oddbsymutil::gettextstyleid("standar d", theapp.m_pdb)); ptext->settextstring("hello world"); ptext->setrotation(0); ptext->sethorizontalmode(oddb::ktextright); ptext->setverticalmode(oddb::ktextvertmid); pblock->appendoddbentity(ptext); i hope i'm not using any fonts. but the position of the text seems to be invalid. am i doing the right way. i'm not using any fonts, so do i need to use the .shx file..? if so, i don't have autocad installed. so how can i create a .shx file..? is it a must that if i'm using a oddbtext entity, then i must use a .shx file. for proper alignment..? tia ------------------ regards, rajesh parameswaran rajuinnet # 27th october 2004, 01:52 am registered user join date: mar 2003 location: france posts: 135 if the horizontalmode is not ktextleft you have to set the alignment point. try this: code] ptext->setalignmentpoint(odgepoint3d(ptx, pty, 0)); [/code] broux@trace.fr # 27th october 2004, 01:57 am registered user join date: jul 2004 location: india posts: 82 quote: originally posted by froggy if the horizontalmode is not ktextleft you have to set the alignment point. try this: code] ptext->setalignmentpoint(odgepoint3d(ptx, pty, 0)); [/code] hi froggy, thank you for your response. can i know more detail about this. i need to implement all the possible combnations. top left, top center, top right, bottom left, bottom center, bottom right, middle left, middle center, and middle right. tia ------------------ regards, rajesh parameswaran rajuinnet # 27th october 2004, 08:34 am moderator join date: mar 2002 posts: 2,994 if text alignment is left-baseline use setposition(). in other cases use setalignmentpoint(). dd will calculate other point (position or alignment). to perform the calculation dd needs access to .shx file. if required .shx file is not available you can set both position and alignment point yourself and call recordgraphicsmodified(false) to prevent recalculation. but recordgraphicmodified() will take effect only if it's called after all properties/coordinates are set because any oddbtext modification turns the graphicsmodified flag on. sergey slezkin sslezkin # 28th october 2004, 01:15 am registered user join date: jul 2004 location: india posts: 82 still hunting with alignment and position quote: originally posted by sergey slezkin if text alignment is left-baseline use setposition(). in other cases use setalignmentpoint(). dd will calculate other point (position or alignment). to perform the calculation dd needs access to .shx file. if required .shx file is not available you can set both position and alignment point yourself and call recordgraphicsmodified(false) to prevent recalculation. but recordgraphicmodified() will take effect only if it's called after all properties/coordinates are set because any oddbtext modification turns the graphicsmodified flag on. hi sergey, as you told i have modified my code. but for all the positions, its placing the text ane bottom corner of the drawing... please help... code below.. pblock = m_pdb->getmodelspaceid().safeopenobject(oddb::kforwrite) ; ptext = oddbtext::createobject(); ptext->setheight(height); ptext->setwidthfactor(3); ptext->settextstyle(oddbsymutil::gettextstyleid(strstyle , m_pdb)); ptext->settextstring(strtext); ptext->setrotation(0); ptext->getboundingpoints(temparray); nstyle = getjustificationindex(just); switch (nstyle) { case 1: // top left ptext->setalignmentpoint(temparray[0].x, temparray[0].y); ptext->sethorizontalmode(oddb::ktextleft); ptext->setverticalmode(oddb::ktexttop); break; case 2: // top center ptext->setalignmentpoint((temparray[0].x + temparray[1].x)/2 , temparray[0].y); ptext->sethorizontalmode(oddb::ktextcenter); ptext->setverticalmode(oddb::ktexttop); break; case 3: // top right ptext->setalignmentpoint(temparray[1].x, temparray[0].y); ptext->sethorizontalmode(oddb::ktextright); ptext->setverticalmode(oddb::ktexttop); break; case 4: // middle left ptext->setalignmentpoint(temparray[0].x, (temparray[1].y + temparray[2].y)/2); ptext->sethorizontalmode(oddb::ktextleft); ptext->setverticalmode(oddb::ktextvertmid); break; case 5: // middle center ptext->setalignmentpoint((temparray[0].x + temparray[1].x)/2 , (temparray[1].y + temparray[1].y)/2); ptext->sethorizontalmode(oddb::ktextcenter); ptext->setverticalmode(oddb::ktextvertmid); break; case 6: // middle right ptext->setalignmentpoint(temparray[1].x, (temparray[1].y + temparray[1].y)/2); ptext->sethorizontalmode(oddb::ktextright); ptext->setverticalmode(oddb::ktextvertmid); break; case 7: //bottom left ptext->setposition(temparray[2].x, temparray[2].y); ptext->sethorizontalmode(oddb::ktextleft); ptext->setverticalmode(oddb::ktextbottom); break; case 8: //bottom center ptext->setalignmentpoint((temparray[0].x + temparray[1].x)/2 , temparray[2].y); ptext->sethorizontalmode(oddb::ktextcenter); ptext->setverticalmode(oddb::ktextbottom); break; case 9: //bottom right ptext->setalignmentpoint(temparray[3].x, temparray[3].y); ptext->sethorizontalmode(oddb::ktextright); ptext->setverticalmode(oddb::ktextbottom); break; } pblock->appendoddbentity(ptext); ptext->recordgraphicsmodified(false); tia --------------------- regards, rajesh parameswaran rajuinnet # 28th october 2004, 06:21 am moderator join date: mar 2002 posts: 2,994 if you use recordgraphicsmodified(false) to prevent dd recalculation of second point you need to set both position and alignment points. sergey slezkin sslezkin # 28th october 2004, 06:27 am registered user join date: jul 2004 location: india posts: 82 quote: originally posted by sergey slezkin if you use recordgraphicsmodified(false) to prevent dd recalculation of second point you need to set both position and alignment points. hi sergey, even if i don't use the recordgraphicsmodified(false) option, the same result is performed. am i creating the right way ..? -------------------- regards, rajesh parameswaran rajuinnet # 28th october 2004, 06:48 am moderator join date: mar 2002 posts: 2,994 you call getboundingpoints() to fill temparray. at this moment text position was not set so it has (0,0,0) value. temparray is filled with values around (0,0,0) when you use them to set position or alignment. surely all texts are near (0,0,0) btw getboundingpoints() needs .shx files to calculate string dimensions properly. if fonts are not available default font will be used and results will be incorrect. sergey slezkin sslezkin # 28th october 2004, 06:56 am registered user join date: jul 2004 location: india posts: 82 quote: originally posted by sergey slezkin you call getboundingpoints() to fill temparray. at this moment text position was not set so it has (0,0,0) value. temparray is filled with values around (0,0,0) when you use them to set position or alignment. surely all texts are near (0,0,0) btw getboundingpoints() needs .shx files to calculate string dimensions properly. if fonts are not available default font will be used and results will be incorrect. hi sergey, if i am using the font standard, then is it necessary that it needs the .shx file for the getboundingpoints() function..? ptext->settextstyle(oddbsymutil::gettextstyleid("standar d", m_pdb)); --------------------- regards, rajesh parameswaran rajuinnet # 28th october 2004, 07:09 am moderator join date: mar 2002 posts: 2,994 standard is not font it's text style. any text style can have any font (shx or ttf) dd has a built-in font similar to simplex.shx which is used if no other fonts are available. sergey slezkin sslezkin # 28th october 2004, 07:14 am registered user join date: jul 2004 location: india posts: 82 quote: originally posted by sergey slezkin standard is not font it's text style. any text style can have any font (shx or ttf) dd has a built-in font similar to simplex.shx which is used if no other fonts are available. hi sergey, so is there any default font(s) available, or is there any limited fonts available, which can be used, such that there may be no need of any external files (*.shx)..? tia ---------------- regards, rajesh parameswaran rajuinnet # 28th october 2004, 09:03 am moderator join date: mar 2002 posts: 2,994 dd has single built-in font similar to simplex.shx. on windows platforms ttf fonts installed in your system are also available. sergey slezkin sslezkin none ? | ? thread tools display modes linear mode search this thread rate this thread excellent good average bad terrible posting rules you may post new threads you may post replies you may post attachments you may edit your posts is on are on code is off html code is off forum jump user control panel private messages subscriptions who's online search forums forums home general topics news questions and remarks business issues industry commentary general software issues documentation issues future directions dwg libraries dwgdirect.net dwgdirect, c++ version dwgdirectx, activex version adtdirect/c3ddirect opendwg toolkit/viewkit dgn libraries dgndirect, c++ version (2.x+) dgndirect libraries (legacy 0.99xx) all times are gmt -7. the time now is 12:46 amfff">. - - - copyright ?2000 - 2009, jelsoft enterprises ltd. copyright 1998-2008 open design alliance inc. if the horizontalmode is not ktextleft you have to set the alignment point. try this: code] ptext->setalignmentpoint(odgepoint3d(ptx, pty, 0)); [/code] quote: originally posted by froggy if the horizontalmode is not ktextleft you have to set the alignment point. try this: code] ptext->setalignmentpoint(odgepoint3d(ptx, pty, 0)); [/code] hi froggy, thank you for your response. can i know more detail about this. i need to implement all the possible combnations. top left, top center, top right, bottom left, bottom center, bottom right, middle left, middle center, and middle right. tia ------------------ regards, rajesh parameswaran if text alignment is left-baseline use setposition(). in other cases use setalignmentpoint(). dd will calculate other point (position or alignment). to perform the calculation dd needs access to .shx file. if required .shx file is not available you can set both position and alignment point yourself and call recordgraphicsmodified(false) to prevent recalculation. but recordgraphicmodified() will take effect only if it's called after all properties/coordinates are set because any oddbtext modification turns the graphicsmodified flag on. sergey slezkin still hunting with alignment and position quote: originally posted by sergey slezkin if text alignment is left-baseline use setposition(). in other cases use setalignmentpoint(). dd will calculate other point (position or alignment). to perform the calculation dd needs access to .shx file. if required .shx file is not available you can set both position and alignment point yourself and call recordgraphicsmodified(false) to prevent recalculation. but recordgraphicmodified() will take effect only if it's called after all properties/coordinates are set because any oddbtext modification turns the graphicsmodified flag on. hi sergey, as you told i have modified my code. but for all the positions, its placing the text ane bottom corner of the drawing... please help... code below.. pblock = m_pdb->getmodelspaceid().safeopenobject(oddb::kforwrite) ; ptext = oddbtext::createobject(); ptext->setheight(height); ptext->setwidthfactor(3); ptext->settextstyle(oddbsymutil::gettextstyleid(strstyle , m_pdb)); ptext->settextstring(strtext); ptext->setrotation(0); ptext->getboundingpoints(temparray); nstyle = getjustificationindex(just); switch (nstyle) { case 1: // top left ptext->setalignmentpoint(temparray[0].x, temparray[0].y); ptext->sethorizontalmode(oddb::ktextleft); ptext->setverticalmode(oddb::ktexttop); break; case 2: // top center ptext->setalignmentpoint((temparray[0].x + temparray[1].x)/2 , temparray[0].y); ptext->sethorizontalmode(oddb::ktextcenter); ptext->setverticalmode(oddb::ktexttop); break; case 3: // top right ptext->setalignmentpoint(temparray[1].x, temparray[0].y); ptext->sethorizontalmode(oddb::ktextright); ptext->setverticalmode(oddb::ktexttop); break; case 4: // middle left ptext->setalignmentpoint(temparray[0].x, (temparray[1].y + temparray[2].y)/2); ptext->sethorizontalmode(oddb::ktextleft); ptext->setverticalmode(oddb::ktextvertmid); break; case 5: // middle center ptext->setalignmentpoint((temparray[0].x + temparray[1].x)/2 , (temparray[1].y + temparray[1].y)/2); ptext->sethorizontalmode(oddb::ktextcenter); ptext->setverticalmode(oddb::ktextvertmid); break; case 6: // middle right ptext->setalignmentpoint(temparray[1].x, (temparray[1].y + temparray[1].y)/2); ptext->sethorizontalmode(oddb::ktextright); ptext->setverticalmode(oddb::ktextvertmid); break; case 7: //bottom left ptext->setposition(temparray[2].x, temparray[2].y); ptext->sethorizontalmode(oddb::ktextleft); ptext->setverticalmode(oddb::ktextbottom); break; case 8: //bottom center ptext->setalignmentpoint((temparray[0].x + temparray[1].x)/2 , temparray[2].y); ptext->sethorizontalmode(oddb::ktextcenter); ptext->setverticalmode(oddb::ktextbottom); break; case 9: //bottom right ptext->setalignmentpoint(temparray[3].x, temparray[3].y); ptext->sethorizontalmode(oddb::ktextright); ptext->setverticalmode(oddb::ktextbottom); break; } pblock->appendoddbentity(ptext); ptext->recordgraphicsmodified(false); tia --------------------- regards, rajesh parameswaran if you use recordgraphicsmodified(false) to prevent dd recalculation of second point you need to set both position and alignment points. sergey slezkin quote: originally posted by sergey slezkin if you use recordgraphicsmodified(false) to prevent dd recalculation of second point you need to set both position and alignment points. hi sergey, even if i don't use the recordgraphicsmodified(false) option, the same result is performed. am i creating the right way ..? -------------------- regards, rajesh parameswaran you call getboundingpoints() to fill temparray. at this moment text position was not set so it has (0,0,0) value. temparray is filled with values around (0,0,0) when you use them to set position or alignment. surely all texts are near (0,0,0) btw getboundingpoints() needs .shx files to calculate string dimensions properly. if fonts are not available default font will be used and results will be incorrect. sergey slezkin quote: originally posted by sergey slezkin you call getboundingpoints() to fill temparray. at this moment text position was not set so it has (0,0,0) value. temparray is filled with values around (0,0,0) when you use them to set position or alignment. surely all texts are near (0,0,0) btw getboundingpoints() needs .shx files to calculate string dimensions properly. if fonts are not available default font will be used and results will be incorrect. hi sergey, if i am using the font standard, then is it necessary that it needs the .shx file for the getboundingpoints() function..? ptext->settextstyle(oddbsymutil::gettextstyleid("standar d", m_pdb)); --------------------- regards, rajesh parameswaran standard is not font it's text style. any text style can have any font (shx or ttf) dd has a built-in font similar to simplex.shx which is used if no other fonts are available. sergey slezkin quote: originally posted by sergey slezkin standard is not font it's text style. any text style can have any font (shx or ttf) dd has a built-in font similar to simplex.shx which is used if no other fonts are available. hi sergey, so is there any default font(s) available, or is there any limited fonts available, which can be used, such that there may be no need of any external files (*.shx)..? tia ---------------- regards, rajesh parameswaran dd has single built-in font similar to simplex.shx. on windows platforms ttf fonts installed in your system are also available. sergey slezkin |
![]() |
![]() |
GDT自动化论坛(仅游客可见) |