Example #1
0
int RS_Settings::readNumEntry(const RS_String& key, int def, bool* ok)
{
#if QT_VERSION>=0x030000

  // lookup:
  RS_String sret = readEntryCache(key);
  if (sret==RS_String::null)
  {
    int ret;
    QSettings s(QSettings::Ini);
    s.insertSearchPath(QSettings::Windows, companyKey);

    ret = s.readNumEntry(QString("%1%2%3").arg(appKey).arg(group).arg(key),
                         def, ok);
    addToCache(key, RS_String("%1").arg(ret));
    return ret;
  }
  else
  {
    return sret.toInt();
  }
#else

  return def;
#endif

}
/**
 * @return Automatically created label for the default 
 * measurement of this dimension.
 */
RS_String RS_DimDiametric::getMeasuredLabel() {

    // Definitive dimension line:
    double dist = data.definitionPoint.distanceTo(edata.definitionPoint);

	RS_Graphic* graphic = getGraphic();

    RS_String ret;
	if (graphic!=NULL) {
		ret = RS_Units::formatLinear(dist, graphic->getUnit(), 
			graphic->getLinearFormat(), graphic->getLinearPrecision());
	}
	else {
    	ret = RS_String("%1").arg(dist);
	}

    return ret;
}
Example #3
0
/**
 *  Gets the one and only RS_Debug instance
 *  (creates a new one on first call only)
 *
 *  @return Pointer to the single instance of this
 * singleton class
 */
RS_Debug* RS_Debug::instance() {
    if(uniqueInstance==NULL) {
        RS_DateTime now = RS_DateTime::currentDateTime();
        RS_String nowStr;
#if QT_VERSION>=0x030000
		nowStr = now.toString("yyyyMMdd_hhmmss");
#else
		nowStr = now.toString();
#endif
		//RS_String fName = RS_String("%1/debug_%2.log")
		//	.arg(RS_SYSTEM->getHomeDir())
		//	.arg(nowStr);
		RS_String fName = RS_String("debug_%1.log")
			.arg(nowStr);

        uniqueInstance = new RS_Debug;
        //uniqueInstance->stream = fopen(fName.latin1(), "wt");
        uniqueInstance->stream = stderr;
    }
    return uniqueInstance;
}
Example #4
0
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
}
Example #5
0
bool RS_Settings::writeEntry(const RS_String& key, double value) {
    RS_String s = RS_String("%1").arg(value);
    return writeEntry(key, s);
}
Example #6
0
/**
 * @return a string representing the given unit (e.g. "Millimeter").
 *      translated if @a t is true (the default).
 */
RS_String RS_Units::unitToString(RS2::Unit u, bool t) {
    RS_String ret = "";

    switch (u) {
    case RS2::None:
        ret = t ? QObject::tr("None") : RS_String("None");
        break;
    case RS2::Inch:
        ret = t ? QObject::tr("Inch") : RS_String("Inch");
        break;
    case RS2::Foot:
        ret = t ? QObject::tr("Foot") : RS_String("Foot");
        break;
    case RS2::Mile:
        ret = t ? QObject::tr("Mile") : RS_String("Mile");
        break;
    case RS2::Millimeter:
        ret = t ? QObject::tr("Millimeter") : RS_String("Millimeter");
        break;
    case RS2::Centimeter:
        ret = t ? QObject::tr("Centimeter") : RS_String("Centimeter");
        break;
    case RS2::Meter:
        ret = t ? QObject::tr("Meter") : RS_String("Meter");
        break;
    case RS2::Kilometer:
        ret = t ? QObject::tr("Kilometer") : RS_String("Kilometer");
        break;
    case RS2::Microinch:
        ret = t ? QObject::tr("Microinch") : RS_String("Microinch");
        break;
    case RS2::Mil:
        ret = t ? QObject::tr("Mil") : RS_String("Mil");
        break;
    case RS2::Yard:
        ret = t ? QObject::tr("Yard") : RS_String("Yard");
        break;
    case RS2::Angstrom:
        ret = t ? QObject::tr("Angstrom") : RS_String("Angstrom");
        break;
    case RS2::Nanometer:
        ret = t ? QObject::tr("Nanometer") : RS_String("Nanometer");
        break;
    case RS2::Micron:
        ret = t ? QObject::tr("Micron") : RS_String("Micron");
        break;
    case RS2::Decimeter:
        ret = t ? QObject::tr("Decimeter") : RS_String("Decimeter");
        break;
    case RS2::Decameter:
        ret = t ? QObject::tr("Decameter") : RS_String("Decameter");
        break;
    case RS2::Hectometer:
        ret = t ? QObject::tr("Hectometer") : RS_String("Hectometer");
        break;
    case RS2::Gigameter:
        ret = t ? QObject::tr("Gigameter") : RS_String("Gigameter");
        break;
    case RS2::Astro:
        ret = t ? QObject::tr("Astro") : RS_String("Astro");
        break;
    case RS2::Lightyear:
        ret = t ? QObject::tr("Lightyear") : RS_String("Lightyear");
        break;
    case RS2::Parsec:
        ret = t ? QObject::tr("Parsec") : RS_String("Parsec");
        break;

    default:
        ret = "";
        break;
    }

    return ret;
}