Пример #1
0
bool Dip::changePinLabels(bool singleRow, bool sip) {
	if (m_viewID != ViewLayer::SchematicView) return true;

	bool hasLocal = false;
	QStringList labels = getPinLabels(hasLocal);
	if (labels.count() == 0) return true;


	QString svg;
	if (singleRow) {
		svg = MysteryPart::makeSchematicSvg(labels, sip);
	}
	else {
		svg = Dip::makeSchematicSvg(labels);
	}

    QString chipLabel = modelPart()->localProp("chip label").toString();
    if (!chipLabel.isEmpty()) {
        svg =TextUtils::replaceTextElement(svg, "label", chipLabel);
    }

    QTransform  transform = untransform();

	resetLayerKin(svg);
    resetConnectors();

    retransform(transform);

	return true;
}
Пример #2
0
/*!
	sets the position without undo/redo-stuff
*/
void TextLabel::setPosition(const QPointF& point) {
	Q_D(TextLabel);
	if (point != d->position.point) {
		d->position.point = point;
		retransform();
	}
}
Пример #3
0
void CartesianPlotLegend::init(){
	Q_D(CartesianPlotLegend);

	KConfig config;
	KConfigGroup group = config.group( "CartesianPlotLegend" );

	d->labelFont = group.readEntry("LabelsFont", QFont());
	d->labelFont.setPixelSize( Worksheet::convertToSceneUnits( 10, Worksheet::Point ) );

	d->labelColor = Qt::black;
	d->labelColumnMajor = true;
	d->lineSymbolWidth = group.readEntry("LineSymbolWidth", Worksheet::convertToSceneUnits(1, Worksheet::Centimeter));
	d->rowCount = 0;
	d->columnCount = 0;

	d->position.horizontalPosition = CartesianPlotLegend::hPositionRight;
	d->position.verticalPosition = CartesianPlotLegend::vPositionBottom;

	//Title
 	d->title = new TextLabel(this->name(), TextLabel::PlotLegendTitle);
	d->title->setText(this->name());
	addChild(d->title);
	d->title->setHidden(true);
	d->title->setParentGraphicsItem(graphicsItem());
	d->title->graphicsItem()->setFlag(QGraphicsItem::ItemIsMovable, false);
	connect(d->title, SIGNAL(changed()), this, SLOT(retransform()));

	//Background
	d->backgroundType = (PlotArea::BackgroundType) group.readEntry("BackgroundType", (int) PlotArea::Color);
	d->backgroundColorStyle = (PlotArea::BackgroundColorStyle) group.readEntry("BackgroundColorStyle", (int) PlotArea::SingleColor);
	d->backgroundImageStyle = (PlotArea::BackgroundImageStyle) group.readEntry("BackgroundImageStyle", (int) PlotArea::Scaled);
	d->backgroundBrushStyle = (Qt::BrushStyle) group.readEntry("BackgroundBrushStyle", (int) Qt::SolidPattern);
	d->backgroundFileName = group.readEntry("BackgroundFileName", QString());
	d->backgroundFirstColor = group.readEntry("BackgroundFirstColor", QColor(Qt::white));
	d->backgroundSecondColor = group.readEntry("BackgroundSecondColor", QColor(Qt::black));
	d->backgroundOpacity = group.readEntry("BackgroundOpacity", 1.0);

	//Border
	d->borderPen = QPen(group.readEntry("BorderColor", QColor(Qt::black)),
										 group.readEntry("BorderWidth", Worksheet::convertToSceneUnits(1.0, Worksheet::Point)),
										 (Qt::PenStyle) group.readEntry("BorderStyle", (int)Qt::SolidLine));
	d->borderCornerRadius = group.readEntry("BorderCornerRadius", 0.0);
	d->borderOpacity = group.readEntry("BorderOpacity", 1.0);

	//Layout
	d->layoutTopMargin =  group.readEntry("LayoutTopMargin", Worksheet::convertToSceneUnits(0.2, Worksheet::Centimeter));
	d->layoutBottomMargin = group.readEntry("LayoutBottomMargin", Worksheet::convertToSceneUnits(0.2, Worksheet::Centimeter));
	d->layoutLeftMargin = group.readEntry("LayoutLeftMargin", Worksheet::convertToSceneUnits(0.2, Worksheet::Centimeter));
	d->layoutRightMargin = group.readEntry("LayoutRightMargin", Worksheet::convertToSceneUnits(0.2, Worksheet::Centimeter));
	d->layoutVerticalSpacing = group.readEntry("LayoutVerticalSpacing", Worksheet::convertToSceneUnits(0.1, Worksheet::Centimeter));
	d->layoutHorizontalSpacing = group.readEntry("LayoutHorizontalSpacing", Worksheet::convertToSceneUnits(0.1, Worksheet::Centimeter));
	d->layoutColumnCount = group.readEntry("LayoutColumnCount", 1);

	graphicsItem()->setFlag(QGraphicsItem::ItemIsSelectable, true);
	graphicsItem()->setFlag(QGraphicsItem::ItemIsMovable);
	graphicsItem()->setFlag(QGraphicsItem::ItemSendsGeometryChanges);

	this->initActions();
}
Пример #4
0
void CartesianPlotLegend::handlePageResize(double horizontalRatio, double verticalRatio){
	//TODO
	Q_UNUSED(horizontalRatio);
	Q_UNUSED(verticalRatio);
// 	Q_D(const CartesianPlotLegend);

	retransform();
}
Пример #5
0
void TextLabelPrivate::updateTeXImage() {
	QImage resultImage = teXImageFutureWatcher.result();
	if (!resultImage.isNull()) {
		teXImage = resultImage;

		//the size of the tex image was most probably changed.
		//call retransform() to recalculate the position and the bounding box of the label
		retransform();
		emit q->teXImageUpdated(true);
	} else {
		emit q->teXImageUpdated(false);
	}
}
Пример #6
0
/*!
	updates the static text.
 */
void TextLabelPrivate::updateText() {
	if (textWrapper.teXUsed) {
		QFuture<QImage> future = QtConcurrent::run(TeXRenderer::renderImageLaTeX, textWrapper.text, teXFontColor, teXFontSize, teXImageResolution);
		teXImageFutureWatcher.setFuture(future);

		//don't need to call retransorm() here since it is done in updateTeXImage
		//when the asynchronous rendering of the image is finished.
	} else {
		staticText.setText(textWrapper.text);

		//the size of the label was most probably changed.
		//call retransform() to recalculate the position and the bounding box of the label
		retransform();
	}
}
Пример #7
0
void saveTGA(struct biqstruct * biq, struct targa * tga, char filename[]) {

	uint i;
	int x,y;
	uchar * src;

	FILE * file = fopen(filename,"wb");

	/* Type conversion table */
	const uchar tgatypes[4] = { 0x03, 0x01, 0x02, 0x02 };
	const uchar biqbpp[4]   = { 8, 8, 24, 24 };

	if (file==NULL) {
		printf("Failed to create %s.\n",filename);
		return;
	}


	memset(tga, 0 , sizeof(struct targa)-2*sizeof(void *)-2);
	tga->type   = tgatypes[biq->type];

	/* Bugfix: set CLUT properties */
	if (tga->type==0x01) {
		tga->hasclut   = 0x01;
		tga->clutstart = 0x0000;
		tga->clutlen   = 0x1801;	/* This is very weird, but it seems to work */
	}

	tga->width  = biq->width;
	tga->height = biq->height;
	tga->bits   = biqbpp[biq->type];

#ifdef BIGENDIAN
/*	tga->clutstart = BYTESWAP(tga->clutstart); /* = 0, either way */
	tga->clutlen = BYTESWAP(tga->clutlen);

	tga->width  = BYTESWAP(tga->width);
	tga->height = BYTESWAP(tga->height);

#endif

	/* Write file header, this works on both big and little endian machines */
	fwrite(tga, 1, sizeof(struct targa)-2*sizeof(void *)-2, file);


	/* Color mapped filetype? */
	if (tga->type==0x01) {

		/* Write out color map to file */
		for (i=0;i<NUM_COLORS;i++) {
			putc(biq->clut[i].b,file);
			putc(biq->clut[i].g,file);
			putc(biq->clut[i].r,file);
		}
	}


	/* Perform inverse Wavelet transform */
	retransform(biq,tga,L);

	/* Save image (bottom to top)*/

	/* 24bpp */
	if (tga->bits==24) {

		for (y=biq->height-1;y>=0;y--) {
			src = &biq->coeff[y*biq->width*sizeof(uchar)];

			for (x=0;x<biq->width;x++) {

				/* Write B, G and R layers in interlaved order*/
				putc(src[2*biq->height*biq->width*sizeof(uchar)],file);
				putc(src[biq->height*biq->width*sizeof(uchar)],file);
				putc(*src++,file);
			}
		}
	}

	/* 8bpp */
	else {

		src=&biq->coeff[biq->width*sizeof(uchar)*(biq->height-1)];
		do {
			fwrite(src,biq->width*sizeof(uchar),sizeof(uchar),file);
		} while ((src -= biq->width*sizeof(uchar)) >= biq->coeff);

	}

	fclose(file);
}
Пример #8
0
void MapCloudDisplay::update( float wall_dt, float ros_dt )
{
	rviz::PointCloud::RenderMode mode = (rviz::PointCloud::RenderMode) style_property_->getOptionInt();

	if (needs_retransform_)
	{
		retransform();
		needs_retransform_ = false;
	}

	{
		boost::mutex::scoped_lock lock(new_clouds_mutex_);
		if( !new_cloud_infos_.empty() )
		{
			float size;
			if( mode == rviz::PointCloud::RM_POINTS ) {
				size = point_pixel_size_property_->getFloat();
			} else {
				size = point_world_size_property_->getFloat();
			}

			std::map<int, CloudInfoPtr>::iterator it = new_cloud_infos_.begin();
			std::map<int, CloudInfoPtr>::iterator end = new_cloud_infos_.end();
			for (; it != end; ++it)
			{
				CloudInfoPtr cloud_info = it->second;

				cloud_info->cloud_.reset( new rviz::PointCloud() );
				cloud_info->cloud_->addPoints( &(cloud_info->transformed_points_.front()), cloud_info->transformed_points_.size() );
				cloud_info->cloud_->setRenderMode( mode );
				cloud_info->cloud_->setAlpha( alpha_property_->getFloat() );
				cloud_info->cloud_->setDimensions( size, size, size );
				cloud_info->cloud_->setAutoSize(false);

				cloud_info->manager_ = context_->getSceneManager();

				cloud_info->scene_node_ = scene_node_->createChildSceneNode();

				cloud_info->scene_node_->attachObject( cloud_info->cloud_.get() );
				cloud_info->scene_node_->setVisible(false);

				cloud_infos_.insert(*it);
			}

			new_cloud_infos_.clear();
		}
	}

	{
		boost::recursive_mutex::scoped_try_lock lock( transformers_mutex_ );

		if( lock.owns_lock() )
		{
			if( new_xyz_transformer_ || new_color_transformer_ )
			{
				M_TransformerInfo::iterator it = transformers_.begin();
				M_TransformerInfo::iterator end = transformers_.end();
				for (; it != end; ++it)
				{
					const std::string& name = it->first;
					TransformerInfo& info = it->second;

					setPropertiesHidden( info.xyz_props, name != xyz_transformer_property_->getStdString() );
					setPropertiesHidden( info.color_props, name != color_transformer_property_->getStdString() );
				}
			}
		}

		new_xyz_transformer_ = false;
		new_color_transformer_ = false;
	}

	int totalPoints = 0;
	int totalNodesShown = 0;
	{
		// update poses
		boost::mutex::scoped_lock lock(current_map_mutex_);
		if(!current_map_.empty())
		{
			for (std::map<int, rtabmap::Transform>::iterator it=current_map_.begin(); it != current_map_.end(); ++it)
			{
				std::map<int, CloudInfoPtr>::iterator cloudInfoIt = cloud_infos_.find(it->first);
				if(cloudInfoIt != cloud_infos_.end())
				{
					totalPoints += cloudInfoIt->second->transformed_points_.size();
					cloudInfoIt->second->pose_ = it->second;
					Ogre::Vector3 framePosition;
					Ogre::Quaternion frameOrientation;
					if (context_->getFrameManager()->getTransform(cloudInfoIt->second->message_->header, framePosition, frameOrientation))
					{
						// Multiply frame with pose
						Ogre::Matrix4 frameTransform;
						frameTransform.makeTransform( framePosition, Ogre::Vector3(1,1,1), frameOrientation);
						const rtabmap::Transform & p = cloudInfoIt->second->pose_;
						Ogre::Matrix4 pose(p[0], p[1], p[2], p[3],
										 p[4], p[5], p[6], p[7],
										 p[8], p[9], p[10], p[11],
										 0, 0, 0, 1);
						frameTransform = frameTransform * pose;
						Ogre::Vector3 posePosition = frameTransform.getTrans();
						Ogre::Quaternion poseOrientation = frameTransform.extractQuaternion();
						poseOrientation.normalise();

						cloudInfoIt->second->scene_node_->setPosition(posePosition);
						cloudInfoIt->second->scene_node_->setOrientation(poseOrientation);
						cloudInfoIt->second->scene_node_->setVisible(true);
						++totalNodesShown;
					}
					else
					{
						ROS_ERROR("MapCloudDisplay: Could not update pose of node %d", it->first);
					}

				}
			}
			//hide not used clouds
			for(std::map<int, CloudInfoPtr>::iterator iter = cloud_infos_.begin(); iter!=cloud_infos_.end(); ++iter)
			{
				if(current_map_.find(iter->first) == current_map_.end())
				{
					iter->second->scene_node_->setVisible(false);
				}
			}
		}
	}

	this->setStatusStd(rviz::StatusProperty::Ok, "Points", tr("%1").arg(totalPoints).toStdString());
	this->setStatusStd(rviz::StatusProperty::Ok, "Nodes", tr("%1 shown of %2").arg(totalNodesShown).arg(cloud_infos_.size()).toStdString());
}