Exemplo n.º 1
0
//打字回调
void TopwoType::typing(float f)
{
	//已经全部显示,取消计划
	if (__is_type_all || __type_char_num >= __type_char_sum - 1)
	{
		this->closeTypeLoop();
		typeAll();
		return;
	}

	CCString *sub = NULL;

	//排除格式符
	char ch = 0;
	for (__type_char_num++; sub = Topwo::getInstance()->getTopwoTools()->subUtfString(const_cast<char*>(__type_str->getCString()), 0, __type_char_num); __type_char_num++)
	{
		ch = sub->m_sString.at(sub->m_sString.length() - 1);
		if (/*ch != '\n' &&*/
			ch != '\t' &&
			ch != ' ')
		{
			this->setTypedString(sub->getCString());
			break;
		}
	}
}
Exemplo n.º 2
0
void BrPrint3D::openFile()
{   BigButton *btn = qobject_cast<BigButton*>(sender());
    QString typeGcode("*.gcode");
    QString typeAll("*.gcode *.stl *.STL");
    if(btn==bt_import){
        filePath = QFileDialog::getOpenFileName(this, "Open File", QDir::homePath(), typeGcode);
    }
    if(btn==bt_open){
        filePath = QFileDialog::getOpenFileName(this, "Open File", QDir::homePath(), typeAll);
    }
        if (!filePath.isEmpty() && QFileInfo(filePath).completeSuffix() == "gcode") {
            QFile gcode(filePath);
            if (gcode.open(QFile::ReadOnly | QFile::Text)) {
                QTextStream in(&gcode);
                QString text = in.readAll();
                vtkView->renderGcode(text);
                gcode.close();
                emit callFilCount(filePath);
                ui->_ManualControl->setGcodePreview(text);
                if (bt_connect->isChecked())
                    bt_play->setEnabled(true);

            }
        }

    else if(QFileInfo(filePath).completeSuffix()=="STL" ||QFileInfo(filePath).completeSuffix()=="stl"){
        vtkView->renderSTL(filePath);
    }
}
Exemplo n.º 3
0
//第一帧计算打字内容
void TopwoType::analyzeTypeString(float f)
{
	TopwoTools* topwo_tools = Topwo::getInstance()->getTopwoTools();

	//一行字符串最小个数
	twuint min_char_count = (twuint)(__type_size.width / this->getTypedFontSize());

	CCString* str = CCString::create(__type_str->getCString());
	CCString *sub = NULL;//存储裁剪的一段话
	twint sub_start = 0;//裁剪的开始位置
	twint line_break_count = 0;//裁剪的次数
	twuint i = min_char_count;//裁剪的结束位置
	while ((i <= __type_char_sum) && (sub = topwo_tools->subUtfString(const_cast<char*>(str->getCString()), sub_start, i + 1)))
	{
		this->setTypedString(sub->getCString());
		if (this->getTypedStringContentSize().width > __type_size.width)
		{//超过行宽
			sub = topwo_tools->subUtfString(const_cast<char*>(str->getCString()), 0, i);
			__type_str->m_sString.insert(strlen(sub->getCString()) + line_break_count, 1, '\n');
			sub_start = i;
			line_break_count++;
			i += min_char_count;
		}
		else
		{
			i++;
		}
	}

	//清空
	this->setTypedString("");

	//重新获取这段话总字符数
	__type_char_sum = topwo_tools->getUtf8Length(const_cast<char*>(__type_str->getCString()));

	if ((__type_interval > -0.00001f && __type_interval < 0.00001f) || (!__type_char_sum))
	{
		typeAll();
	}
	else
	{
		this->openTypeLoop( __type_interval, __type_char_sum, 0);
	}
}