void DL_Jww::CreateMoji(DL_CreationInterface* creationInterface, CDataMoji& DMoji) { string lName = HEX[DMoji.m_nGLayer > ArraySize(HEX)-1 ? ArraySize(HEX)-1: DMoji.m_nGLayer] + "-" + HEX[DMoji.m_nLayer > ArraySize(HEX)-1 ? ArraySize(HEX)-1: DMoji.m_nLayer]; // add layer creationInterface->addLayer(DL_LayerData(lName,0)); int width; if(DMoji.m_nPenWidth > 26) width = 0; else width = DMoji.m_nPenWidth; int color = colTable[DMoji.m_nPenColor > ArraySize(colTable)-1 ? ArraySize(colTable)-1 : DMoji.m_nPenColor]; attrib = DL_Attributes(values[8], // layer color, // color width, // width lTable[DMoji.m_nPenStyle > ArraySize(lTable)-1 ? ArraySize(lTable)-1 : DMoji.m_nPenStyle]); // linetype creationInterface->setAttributes(attrib); creationInterface->setExtrusion(0.0, 0.0, 1.0, 0.0 ); DL_TextData d( // insertion point DMoji.m_start.x, DMoji.m_start.y, 0.0, // alignment point 0.0, 0.0, 0.0, // height DMoji.m_dSizeY, // x scale 1.0, // generation flags 0, // h just 0, // v just 0, // text DMoji.m_string, // style string("japanese"), // angle DMoji.m_degKakudo / 180.0 * M_PI); creationInterface->addText(d); #ifdef FINISHED QTextCodec* codec = QTextCodec::codecForName("SJIS"); RS_TextData data3(RS_Vector(0.0, 0.0), 10,//double height, 10,//double width, RS2::VAlignMiddle, RS2::HAlignCenter, RS2::LeftToRight, RS2::AtLeast, 1.0,//double lineSpacingFactor, RS_String(""),//const RS_String& text, RS_String(""), 0.0,//double angle, RS2::Update); RS_Text* text; data3.insertionPoint = RS_Vector(DMoji.m_start.x, DMoji.m_start.y); data3.height = DMoji.m_dSizeY; data3.width = DMoji.m_dSizeX; data3.valign = RS2::VAlignBottom;//VAlignMiddle; data3.halign = RS2::HAlignLeft;//HAlignCenter; data3.drawingDirection = RS2::LeftToRight; data3.lineSpacingStyle = RS2::Exact; data3.lineSpacingFactor = DMoji.m_dKankaku;//1.0; //コード変換 size_t left = DMoji.m_string.length(); char* sjis = (char *)DMoji.m_string.c_str(); char buf[200]; //memset(buf, NULL, 1000); char* p = buf; size_t bufleft = 200; #ifdef _WINDOWS // エンコーディングの変換:iconvを使う場合 iconv_t cd = iconv_open(UTF8_CES, SHIFTJIS_CES); #ifdef DEBUG printf("sjis = %x, p = %x\n", sjis, p); #endif size_t r = iconv(cd, (const char **)(&sjis), &left, &p, &bufleft);//const_cast<char**> #ifdef DEBUG printf("sjis = %x, p = %x\n", sjis, p); printf("sjis = %x %x %x %x, p = %x %x %x %x\n", sjis[0],sjis[1],sjis[2],sjis[3], buf[0],buf[1],buf[2],buf[3]); printf("r = %d, left = %d, bufleft = %d\n", r, left, bufleft); #endif *p = '\0'; iconv_close(cd); #else // int ires = SJIS2UTF8N(sjis,buf,bufleft); int nBytesOut; strcpy(buf,(const char *)CUnicodeF::sjis_to_euc((const unsigned char *)sjis/*, &nBytesOut*/)); // QTextCodec* codec = QTextCodec::codecForName("eucJP"); // data3.text = codec->toUnicode(buf); #endif // data3.text = codec->toUnicode(sjis); data3.text = RS_String::fromUtf8(buf); data3.style = RS_String("japanese-euc"); data3.angle = DMoji.m_degKakudo / 180.0 * M_PI; #ifdef DEBUG RS_DEBUG->setLevel(RS_Debug::D_DEBUGGING); #endif data3.updateMode = RS2::Update; //jwDWORD m_nMojiShu;//文字種(斜体文字は20000、ボールド体は10000を加えた数値) text = new RS_Text(graphic, data3); RS2::LineType ltype = lTable[DMoji.m_nPenStyle]; RS_Color col = colTable[DMoji.m_nPenColor]; RS2::LineWidth lw = lWidth[DMoji.m_nPenWidth > 26 ? 0 : DMoji.m_nPenWidth];//RS2::Width12 text->setPen(RS_Pen(col, RS2::Width08, ltype)); //画層設定 RS_String lName = HEX[DMoji.m_nGLayer > 0x0f ? 0: DMoji.m_nGLayer] + "-" + HEX[DMoji.m_nLayer > 0x0f ? 0 : DMoji.m_nLayer]; if( graphic->findLayer(lName) == (RS_Layer*)NULL ){ #ifdef DEBUG std::cout << lName.ascii() << std::endl; #endif RS_Layer* layer = new RS_Layer(lName); graphic->addLayer(layer); } text->setLayer(lName); // add the line to the graphic graphic->addEntity(text); #ifdef DEBUG std::cout << data3.height << " " << data3.width << std::endl; std::cout << *text; #endif #endif }
/** * Updates the sub entities of this dimension. Called when the * dimension or the position, alignment, .. changes. * * @param autoText Automatically reposition the text label */ void RS_DimAngular::update(bool /*autoText*/) { RS_DEBUG->print("RS_DimAngular::update"); clear(); if (isUndone()) { return; } // distance from entities (DIMEXO) double dimexo = getExtensionLineOffset(); // extension line extension (DIMEXE) double dimexe = getExtensionLineExtension(); // text height (DIMTXT) double dimtxt = getTextHeight(); // text distance to line (DIMGAP) double dimgap = getDimensionLineGap(); // find out center: RS_Vector center = getCenter(); if (!center.valid) { return; } double ang1 = 0.0; double ang2 = 0.0; bool reversed = false; RS_Vector p1; RS_Vector p2; getAngles(ang1, ang2, reversed, p1, p2); double rad = edata.definitionPoint4.distanceTo(center); RS_Line* line; RS_Vector dir; double len; double dist; // 1st extension line: dist = center.distanceTo(p1); len = rad - dist + dimexe; dir.setPolar(1.0, ang1); line = new RS_Line(this, RS_LineData(center + dir*dist + dir*dimexo, center + dir*dist + dir*len)); line->setPen(RS_Pen(RS2::FlagInvalid)); line->setLayer(NULL); addEntity(line); // 2nd extension line: dist = center.distanceTo(p2); len = rad - dist + dimexe; dir.setPolar(1.0, ang2); line = new RS_Line(this, RS_LineData(center + dir*dist + dir*dimexo, center + dir*dist + dir*len)); line->setPen(RS_Pen(RS2::FlagInvalid)); line->setLayer(NULL); addEntity(line); // Create dimension line (arc): RS_Arc* arc = new RS_Arc(this, RS_ArcData(center, rad, ang1, ang2, reversed)); arc->setPen(RS_Pen(RS2::FlagInvalid)); arc->setLayer(NULL); addEntity(arc); // length of dimension arc: double distance = arc->getLength(); // do we have to put the arrows outside of the arc? bool outsideArrows = (distance<getArrowSize()*2); // arrow angles: double arrowAngle1, arrowAngle2; double arrowAng; if (rad>1.0e-6) { arrowAng = getArrowSize() / rad; } else { arrowAng = 0.0; } RS_Vector v1, v2; if (!arc->isReversed()) { v1.setPolar(rad, arc->getAngle1()+arrowAng); } else { v1.setPolar(rad, arc->getAngle1()-arrowAng); } v1+=arc->getCenter(); arrowAngle1 = arc->getStartpoint().angleTo(v1); if (!arc->isReversed()) { v2.setPolar(rad, arc->getAngle2()-arrowAng); } else { v2.setPolar(rad, arc->getAngle2()+arrowAng); } v2+=arc->getCenter(); arrowAngle2 = arc->getEndpoint().angleTo(v2); if (!outsideArrows) { arrowAngle1 = arrowAngle1+M_PI; arrowAngle2 = arrowAngle2+M_PI; } // Arrows: RS_SolidData sd; RS_Solid* arrow; // arrow 1 arrow = new RS_Solid(this, sd); arrow->shapeArrow(arc->getStartpoint(), arrowAngle1, getArrowSize()); arrow->setPen(RS_Pen(RS2::FlagInvalid)); arrow->setLayer(NULL); addEntity(arrow); // arrow 2: arrow = new RS_Solid(this, sd); arrow->shapeArrow(arc->getEndpoint(), arrowAngle2, getArrowSize()); arrow->setPen(RS_Pen(RS2::FlagInvalid)); arrow->setLayer(NULL); addEntity(arrow); // text label: RS_TextData textData; RS_Vector textPos = arc->getMiddlePoint(); RS_Vector distV; double textAngle; double dimAngle1 = textPos.angleTo(arc->getCenter())-M_PI/2.0; // rotate text so it's readable from the bottom or right (ISO) // quadrant 1 & 4 if (dimAngle1>M_PI/2.0*3.0+0.001 || dimAngle1<M_PI/2.0+0.001) { distV.setPolar(dimgap, dimAngle1+M_PI/2.0); textAngle = dimAngle1; } // quadrant 2 & 3 else { distV.setPolar(dimgap, dimAngle1-M_PI/2.0); textAngle = dimAngle1+M_PI; } // move text away from dimension line: textPos+=distV; textData = RS_TextData(textPos, dimtxt, 30.0, RS2::VAlignBottom, RS2::HAlignCenter, RS2::LeftToRight, RS2::Exact, 1.0, getLabel(), "standard", textAngle); RS_Text* text = new RS_Text(this, textData); // move text to the side: text->setPen(RS_Pen(RS2::FlagInvalid)); text->setLayer(NULL); addEntity(text); calculateBorders(); }