Пример #1
0
/**
 * \return Color of this entity.
 *
 * \param resolve Resolve color if ByLayer or ByBlock.
 */
RColor REntityData::getColor(bool resolve, const QStack<RBlockReferenceEntity*>& blockRefStack) const {

    if (!resolve) {
        return getColor();
    }

    if (color.isByLayer()) {
        if (document==NULL) {
            qWarning() << "REntityData::getColor: "
                          "color is ByLayer but layer is NULL "
                          "and document is NULL";
            return RColor(Qt::white);
        }
        QSharedPointer<RLayer> l = document->queryLayerDirect(layerId);
        if (l.isNull()) {
            qWarning() << "REntityData::getColor: "
                          "color is ByLayer but layer is invalid";
            return RColor(Qt::white);
        }
        return l->getColor();
    }

    if (color.isByBlock()) {
        if (blockRefStack.isEmpty()) {
            return RColor(Qt::white);
        }
        return blockRefStack.top()->getColor(true, blockRefStack);
    }

    return getColor();
}
Пример #2
0
/**
 * \return List of known colors.
 *
 * \param onlyFixed Only fixed colors, not ByLayer, ByBlock, ...
 */
QList<QPair<QString, RColor> > RColor::getList(bool onlyFixed) {
    init();
    QList<QPair<QString, RColor> > l = list;
    //if (combineBw) {
    //    QString name = RColor(Qt::black).getName();
    //    l.removeAll(QPair<QString, RColor> (name, Qt::black));
    //    name = RColor(Qt::white).getName();
    //    l.removeAll(QPair<QString, RColor> (name, Qt::white));
    //} else {
    //    QString name = RColor(Qt::black, RColor::BlackWhite).getName();
    //    l.removeAll(QPair<QString, RColor> (name, RColor(Qt::black,
    //            RColor::BlackWhite)));
    //}
    if (!onlyFixed) {
        return l;
    }

    // remove "By Layer"
    QString name = RColor(RColor::ByLayer).getName();
    l.removeAll(QPair<QString, RColor> (name, RColor(RColor::ByLayer)));

    // remove "By Block"
    name = RColor(RColor::ByBlock).getName();
    l.removeAll(QPair<QString, RColor> (name, RColor(RColor::ByBlock)));

    return l;
}
Пример #3
0
// ****************************************************************************
//
//  Function Name:	RGraphicColorInterfaceImp::GetColor( )
//
//  Description:		Return the color of the graphic stored in the view
//
//  Returns:			The color
//
//  Exceptions:		kMemory, kUnknownException
//
// ****************************************************************************
//
RColor RGraphicColorInterfaceImp::GetColor( ) const
{
	RGraphic*	pGraphic	= m_pView->GetGraphicDocument( )->GetGraphic( );
	if ( pGraphic )
		return pGraphic->GetMonochromeColor( );
	return RColor( kBlack );
}
Пример #4
0
/**
 * Creates a color from the given CAD code (index 0...256).
 */
RColor RColor::createFromCadIndex(int code) {
    // special colors:
    if (code==0) {
        return RColor(RColor::ByBlock);
    }
    if (code==256) {
        return RColor(RColor::ByLayer);
    }

    // normal indexed colors:
    if (code>0 && code<256) {
        RColor c;
        c.setRgbF(cadColors[code][0], cadColors[code][1], cadColors[code][2]);
        return c;
    }

    return RColor();
}
Пример #5
0
/**
 * \return Color of this entity.
 *
 * \param resolve Resolve color if ByLayer or ByBlock.
 */
RColor REntityData::getColor(bool resolve, const QStack<REntity*>& blockRefStack) const {

    if (!resolve) {
        return getColor();
    }

    if (color.isByLayer()) {
        if (document==NULL) {
            qWarning() << "REntityData::getColor: "
                          "color is ByLayer but layer is NULL "
                          "and document is NULL";
            return RColor(Qt::white);
        }
        QSharedPointer<RLayer> l = document->queryLayerDirect(layerId);
        if (l.isNull()) {
            qWarning() << "REntityData::getColor: "
                          "color is ByLayer but layer is invalid";
            return RColor(Qt::white);
        }

        if (RSettings::isLayer0CompatibilityOn()) {
            // entity in block on layer 0, use attributes of block reference if compatibility mode is on:
            if (l->getName()=="0") {
                if (blockRefStack.isEmpty()) {
                    return l->getColor();
                }
                return blockRefStack.top()->getColor(true, blockRefStack);
            }
        }

        return l->getColor();
    }

    if (color.isByBlock()) {
        if (blockRefStack.isEmpty()) {
            return RColor(Qt::white);
        }
        return blockRefStack.top()->getColor(true, blockRefStack);
    }

    return getColor();
}
Пример #6
0
RColor RColor::createFromName(const QString& name) {
    init();

    QListIterator<QPair<QString, RColor> > it(list);
    while (it.hasNext()) {
        QPair<QString, RColor> p = it.next();
        if (p.first == name) {
            return p.second;
        }
    }

    return RColor(name);
}
Пример #7
0
QBrush RExporter::getBrush(const RPainterPath& path) {
    if (path.isFixedBrushColor()) {
        // brush is fixed color (text color given):
        QBrush brush = currentBrush;
        QColor color = path.getBrush().color();
        // color fixed to "by layer":
        if (color==RColor::CompatByLayer) {
            if (currentLayer!=NULL) {
                color = currentLayer->getColor();
            }
            else {
                qWarning("color by layer but current layer is NULL");
                Q_ASSERT(false);
            }
        }
        // color fixed to "by block" (which really means by block reference):
        if (color==RColor::CompatByBlock) {
            if (!blockRefStack.isEmpty()) {
                QStack<REntity*> newBlockRefStack;
                newBlockRefStack = blockRefStack;
                newBlockRefStack.pop();
                color = blockRefStack.top()->getColor(true, newBlockRefStack);
            }
            else {
                // this can happen (by block at top level):
                color = RColor(Qt::white);
                //qWarning("color by block but current block reference is NULL");
                //Q_ASSERT(false);
            }
        }
        REntity* e=getEntity();
        if (e!=NULL && e->isSelected()) {
            brush.setColor(RSettings::getSelectionColor());
        }
        else {
            brush.setColor(color);
        }
        return brush;
    }
    else {
        // brush is current brush or no brush:
        if (path.getBrush().style()!=Qt::NoBrush) {
            // brush is current brush:
            return currentBrush;
        }
        else {
            return path.getBrush();
        }
    }
}
Пример #8
0
// ****************************************************************************
//
// Function Name:		RPsd3RuledLineGraphic::GetOutlinePath( )
//
// Description:		Compute and return the path the encompases the path of this graphic
//
// Returns:				nothing
//
// Exceptions:			None
//
// ****************************************************************************
//
BOOLEAN RPsd3RuledLineGraphic::GetOutlinePath( RPath& path, const RRealSize& size, const R2dTransform& transform )
{	
	R2dTransform rLineTransform = transform;
	RRealSize rLineSize = size;
	if (!m_fHorizontal)
	{
		rLineSize.m_dx = size.m_dy;
		rLineSize.m_dy = size.m_dx;
		rLineTransform.PreRotateAboutOrigin(::DegreesToRadians(-90.0));
		rLineTransform.PreTranslate(0.0, -rLineSize.m_dy);		
	}

	Render( NULL, &path, rLineSize, rLineTransform, RIntRect(0,0,0,0), RColor(kBlack) );
	return TRUE;
}
Пример #9
0
void REventHandler::drawInfoLabel(QPainter* painter, const RTextLabel& textLabel) {
    RVector pos = textLabel.getPosition();
    QString text = textLabel.getText();

    RVector p = graphicsView->mapToView(pos);
    // info labels might have individual colors in future
    //var color = RSettings.getColor("GraphicsViewColors/TextLabelColor", new RColor(249,198,31));
    RColor color = RSettings::getColor("GraphicsViewColors/MeasurementToolsColor", RColor(155,220,112));
    painter->setPen(color);

    if (!text.isEmpty()) {
        QFont font = RSettings::getInfoLabelFont();
        font.setPointSizeF(font.pointSizeF()*graphicsView->getDevicePixelRatio());
        QFontMetrics fm(font);
        int w = fm.width(text)+10;
        int h = fm.height()+10;
        //fm.destroy();
        painter->setFont(font);
        painter->drawText(p.x - w - 15, p.y + h + 5, w, h, Qt::AlignHCenter | Qt::AlignVCenter, text, NULL);
    }
}
Пример #10
0
void Vehicle::buildVehicle(float angle0, float magnitude0, float angle1,
		float magnitude1, float angle2, float magnitude2, float angle3,
		float magnitude3, float angle4, float magnitude4, float angle5,
		float magnitude5, float angle6, float magnitude6, float angle7,
		float magnitude7, unsigned int wheel0axis, float wheel0radius,
		float wheel0angle, unsigned int wheel1axis, float wheel1radius,
		float wheel1angle) {

	float angletot = angle0 + angle1 + angle2 + angle3 + angle4 + angle5
			+ angle6 + angle7;

	//	float a0 = (2 * M_PI) * (angle0 / angletot);
	float a0 = M_PI / 4;
	float a1 = 2 * a0;
	float a2 = 3 * a0;
	float a3 = 4 * a0;
	float a4 = 5 * a0;
	float a5 = 6 * a0;
	float a6 = 7 * a0;
	float a7 = 8 * a0;
	vector[0].set(magnitude0 * cos(a0), magnitude0 * sin(a0), 0);
	//	float a1 = (2 * M_PI) * (angle1 / angletot);

	vector[1].set(magnitude1 * cos(a1), magnitude1 * sin(a1), 0);
	//	float a2 = (2 * M_PI) * (angle2 / angletot);

	vector[2].set(magnitude2 * cos(a2), magnitude2 * sin(a2), 0);
	//	float a3 = (2 * M_PI) * (angle3 / angletot);

	vector[3].set(magnitude3 * cos(a3), magnitude3 * sin(a3), 0);
	//	float a4 = (2 * M_PI) * (angle4 / angletot);
	vector[4].set(magnitude4 * cos(a4), magnitude4 * sin(a4), 0);
	//	float a5 = (2 * M_PI) * (angle5 / angletot);
	vector[5].set(magnitude5 * cos(a5), magnitude5 * sin(a5), 0);
	//	float a6 = (2 * M_PI) * (angle6 / angletot);
	vector[6].set(magnitude6 * cos(a6), magnitude6 * sin(a6), 0);
	//	float a7 = (2 * M_PI) * (angle7 / angletot);
	vector[7].set(magnitude7 * cos(a7), magnitude7 * sin(a7), 0);
	RVector3f o(0, 0, 0);

	RTriMesh mesh;
	for (int i = 0; i < 7; i++) {
		mesh.addTriangle(o, vector[i], vector[i + 1], o, RColor(255, 255, 255));
		//		mesh.addTriangle(o, vector[i + 1], vector[i], o, RColor(255, 255, 255));

	}
	mesh.addTriangle(o, vector[7], vector[0], o, RColor(255, 255, 255));
	//	mesh.addTriangle(o, vector[0], vector[7], o, RColor(255, 255, 255));
	//mesh.addTriangle(RVector3f(0,0,0),RVector3f(500,500,0),RVector3f(0,500,0));

	body = parent->newEntity();
	body->setPosition(0, 1000, 0);
	body->setTriMesh(mesh);
	//body->setTriMesh(mesh);
	body->setTriMeshPhysics(1);
	body->set2DXYPhysics();

	wheel0 = parent->newEntity();
	wheel0->setPosition(0, 1000, 0);
	wheel0->setRotation(90, 0, 0);
	wheel0->setCylinderMesh(wheel0radius, 50, 10, RColor(255, 0, 255));
	wheel0->setCylinderPhysics(1);
	wheel0->addPointConstraint(o, body, vector[wheel0axis]);
	wheel0->set2DXYPhysics();
	wheel0->physicalObject->getRigidBody()->setActivationState(false);

	wheel1 = parent->newEntity();
	wheel1->setPosition(0, 1000, 0);
	wheel1->setRotation(90, 0, 0);
	wheel1->setCylinderMesh(wheel1radius, 50, 10, RColor(0, 255, 255));
	wheel1->setCylinderPhysics(1);
	wheel1->addPointConstraint(o, body, vector[wheel1axis]);
	wheel1->set2DXYPhysics();
	wheel1->physicalObject->getRigidBody()->setActivationState(false);
	//	REntity* wheel2 = parent->newEntity();
	//	wheel2->setCylinderMesh(100, 50 ,10,RColor(255,0,255));
	//	wheel2->setCylinderPhysics(1);

	//mesh.add
}
Пример #11
0
RColor RPathOutlineAttribImp::GetColor()
{
	return RColor( m_sOutlineFormat.m_yPenColor );
}
Пример #12
0
/**
 * The default implementation calls the \ref REntity::exportEntity() function
 * of the entity.
 * This method may use the \c currentEntity stack to access the
 * entity that is currently being exported.
 * Exporters can choose to reimplement this function to export an entity
 * in a target platform specific manner (e.g. to optimize things for
 * a specific platform).
 */
void RExporter::exportCurrentEntity(bool preview, bool forceSelected) {
    REntity* entity = getEntity();
    if (entity==NULL) {
        return;
    }

    // if this exporter exports a visual
    // representation of the drawing (scene, view, print)...
    if (isVisualExporter()) {
        // ... only export entities on visible layers:
        if (currentLayer!=NULL && currentLayer->isFrozen()) {
            return;
        }

        // ... only export entities in visible blocks:
        RBlockReferenceEntity* blockRef = dynamic_cast<RBlockReferenceEntity*>(entity);
        if (blockRef!=NULL) {
            RBlock::Id blockId = blockRef->getReferencedBlockId();
            if (blockId!=RBlock::INVALID_ID) {
                QSharedPointer<RBlock> block = document->queryBlockDirect(blockId);
                if (!block.isNull() && block->isFrozen()) {
                    return;
                }
            }
        }
    }

    setEntityAttributes(forceSelected);

    //bool sblt = getScreenBasedLinetypes();
    if ((forceSelected || entity->isSelected()) && RSettings::getUseSecondarySelectionColor()) {
        // first part of two color selection:
        //setScreenBasedLinetypes(true);
        twoColorSelectedMode = true;
    }

    entity->exportEntity(*this, preview, forceSelected);

    // selected? export again with second color and pattern:
    if (visualExporter) {
        if ((forceSelected || entity->isSelected()) &&
            RSettings::getUseSecondarySelectionColor() &&
            entity->getType()!=RS::EntityBlockRef &&
            entity->getType()!=RS::EntityText &&
            entity->getType()!=RS::EntityAttribute &&
            entity->getType()!=RS::EntityAttributeDefinition) {

            RColor secondarySelectionColor = RSettings::getColor("GraphicsViewColors/SecondarySelectionColor", RColor(Qt::white));
            setColor(secondarySelectionColor);
            //setStyle(Qt::CustomDashLine);
            setDashPattern(QVector<qreal>() << 2 << 3);
            entity->exportEntity(*this, preview, forceSelected);
        }
    }
    twoColorSelectedMode = false;
    //setScreenBasedLinetypes(sblt);
}
Пример #13
0
QColor RGraphicsView::getBackgroundColor() {
    if (!backgroundColor.isValid()) {
        backgroundColor = RSettings::getColor("GraphicsViewColors/BackgroundColor", RColor(0,0,0));
    }
    return backgroundColor;
}
Пример #14
0
MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent)
{
    resize(800, 600);
    
    // init script handler for ECMAScript:
    RScriptHandlerRegistry::registerScriptHandler(
        RScriptHandlerEcma::factory,
        RScriptHandlerEcma::getSupportedFileExtensionsStatic()
    );
    RScriptHandlerEcma* handler = 
        dynamic_cast<RScriptHandlerEcma*>(RScriptHandlerRegistry::getGlobalScriptHandler("js"));

    // create central widget from UI file:
    // this widget contains a child called 'Viewport00'. This child
    // widget will be filled with our graphics display with scroll
    // bars, etc.
    QFile file("support/examples/mainwindow/MyDisplay.ui");
    file.open(QIODevice::ReadOnly);
    QUiLoader loader;
    QWidget* widget = loader.load(&file, this);
    file.close();

    setCentralWidget(widget);

    // create drawing document with document interface:
    RMemoryStorage* storage = new RMemoryStorage();
    RSpatialIndexNavel* spatialIndex = new RSpatialIndexNavel();
    RDocument* document = new RDocument(*storage, *spatialIndex);
    documentInterface = new RDocumentInterface(*document);

    // import a DXF file into the drawing:
    documentInterface->importFile("support/examples/mainwindow/drawing_file_to_display.dxf");

    // operation used to add various objects:
    RAddObjectOperation* op;


    // add a layer 'MyLayer':
    QSharedPointer<RLayer> layer = 
        QSharedPointer<RLayer>(
            new RLayer(document, "MyLayer")
        );
    layer->setLinetypeId(document->getLinetypeId("continuous"));
    op = new RAddObjectOperation(layer);
    documentInterface->applyOperation(op);
    RLayer::Id layerId = layer->getId();
    

    // create and add a line entity:
    QSharedPointer<RLineEntity> lineEntity = 
        QSharedPointer<RLineEntity>(
            new RLineEntity(document, RLineData(RVector(0,0), RVector(100,0)))
        );

    // set attributes:
    lineEntity->setLayerId(layerId);
    lineEntity->setColor(RColor(0,128,255));
    lineEntity->setLinetypeId(document->getLinetypeId("dashed"));
    lineEntity->setLineweight(RLineweight::Weight100);

    // set a custom property:
    lineEntity->setCustomProperty("MyIntProperty", 77);
    lineEntity->setCustomProperty("MyStringProperty", "Some text");

    op = new RAddObjectOperation(
        lineEntity, 
        false       // false: don't use current attributes but 
                    //        custom attributes set above
    );

    // add the line entity to the drawing:
    documentInterface->applyOperation(op);


    // make 'widget' and 'documentInterface' available for the script engine:
    QScriptEngine& engine = handler->getScriptEngine();
    QScriptValue globalObject = engine.globalObject();
    globalObject.setProperty("widget", engine.newQObject(widget));
    globalObject.setProperty("documentInterface", qScriptValueFromValue(&engine, documentInterface));

    // call script to initialize viewport (add scroll bars, rulers, etc.):
    handler->doScript("support/examples/mainwindow/init_viewport.js");
}
Пример #15
0
RColor RSettings::getSelectionColor() {
    if (selectionColor==NULL) {
        selectionColor = new RColor(getColor("GraphicsViewColors/SelectionColor", RColor(164,70,70,128)));
    }
    return *selectionColor;
}
Пример #16
0
//****************************************************************************
//
// Function Name: FillData
//
// Description:   Fills an HeadlineDataStruct with the Headline 
//						depth effect data
//
// Returns:       None
//
// Exceptions:	   None
//
//****************************************************************************
void RHeadlineDepthPage::FillData( RHeadlineInterface* pInterface, RComponentView* pComponentView )
{
	//
	// Set the depth effects
	//

	if (m_data.nDataType == kShadowType)
	{
		// Clear any depth effects
		pInterface->SetProjectionEffect( kNoProjection ) ;

		RSoftShadowSettings settings;

		settings.m_fShadowOn           = TRUE;
		settings.m_fShadowOpacity      = m_data.nOpacity / 100.0;
		settings.m_fShadowEdgeSoftness = m_data.nEdgeSoftness  / 100.0;
		settings.m_fShadowOffset       = m_data.nOffset / 65535.0;

		settings.m_fShadowAngle = -m_wndBlendAngle.GetAngle();
		settings.m_fShadowColor = m_btnColor.GetColor().GetSolidColor();
		pComponentView->SetShadowSettings( settings );
	}
	else
	{
		if (pComponentView->HasShadow())
		{
			// Clear any shadow settings
			RSoftShadowSettings settings;
			pComponentView->GetShadowSettings( settings );
			settings.m_fShadowOn = FALSE;

			pComponentView->SetShadowSettings( settings );
		}

		RIntPoint ptVanish(
			int(cos(m_angle) * m_data.nVanishPointX + 0.5),
			int(sin(m_angle) * m_data.nVanishPointY + 0.5) ) ;

		pInterface->SetNumStages( m_data.nNumStages ) ;
		pInterface->SetProjectionEffect( (EProjectionEffects) m_data.nSelProjection ) ;
		pInterface->SetProjectionDepth( m_data.flDepth ) ;
		pInterface->SetProjectionVanishPoint( ptVanish ) ;
		pInterface->SetProjectionFillColor( m_btnColor.GetColor() ) ;

		pInterface->SetShadowEffect( (EShadowEffects) m_data.nSelShadow ) ;
		pInterface->SetShadowDepth( m_data.flDepth ) ;
		pInterface->SetShadowVanishPoint( ptVanish ) ;
		pInterface->SetShadowFillColor( m_btnColor.GetColor() ) ;

		if (m_data.fBlend && m_data.nSelProjection > kNoProjection)
		{
	//		EFramedEffects eFrameEffect ;
	//		pInterface->GetBehindEffect( eFrameEffect ) ;

			RColor crBlendColor ;
			pInterface->GetBehindColor( crBlendColor ) ;

			if (RColor::kTransparent == crBlendColor.GetFillMethod())
			{
				crBlendColor = RSolidColor( kWhite ) ;
			}

			RSolidColor crBlendArray[] = 	{ 
				m_btnColor.GetColor().GetSolidColor(),
				crBlendColor.GetSolidColor() } ;

			crBlendColor = RColor( crBlendArray, 2, m_angle ) ;
			pInterface->SetProjectionFillColor( crBlendColor ) ;
		}
	}

	if (m_data.nSelProjection > kNoProjection || m_data.nDataType == kShadowType)
	{
		EOutlineEffects eOutlineEffect ;
		pInterface->GetOutlineEffect( eOutlineEffect ) ;

		//
		// The user selected a depth option which is mutually exclusive 
		// with the emboss and deboss outline options, so we need to clear 
		// the emboss/deboss option if it is set.
		//
		switch (eOutlineEffect)
		{
		case kEmbossedOutline: 
		case kDebossedOutline:
		case kBlurredOutline:
			{
//				RColor crBehindColor ;
//				pInterface->GetBehindColor( crBehindColor ) ;
//				EFramedEffects eFrameEffect = (RColor::kTransparent == 
//					crBehindColor.GetFillMethod() ? kFrameNoFrame : kSimpleFrame) ;

				// Clear the outline effect
				pInterface->SetOutlineEffect( kSimpleFill ) ;

				// Set the appropriate behind effect.
//				pInterface->SetBehindEffect( eFrameEffect ) ;
			}
		}
	}
}
Пример #17
0
void RWinColorPalette::OnPaint( )
{
	CPaintDC dc( this );
	RDcDrawingSurface ds;
	ds.Initialize( (HDC) dc ) ;

	CRect rcWindow;
	GetClientRect( rcWindow );
	RIntRect rcClient( rcWindow );

	RBitmapImage&	biPalette	= GetPaletteBitmapImage();
	biPalette.LockImage( );
	biPalette.Render( ds, rcClient );
	biPalette.UnlockImage( );
	ds.DetachDCs();

	CClientDC dcClient( this );
	ds.Initialize( (HDC) dcClient ) ;

	RColor crOldFill = ds.GetFillColor();
	RColor crOldPen  = ds.GetPenColor();

	if (m_ptSelected.m_x >= 0 && m_ptSelected.m_y >= 0)
	{
		//
		// Draw selected cell

		RIntRect rcSelected( 
			m_ptSelected.m_x + 1,
			m_ptSelected.m_y + 1,
			m_ptSelected.m_x + kCellSize.m_dx - 1,
			m_ptSelected.m_y + kCellSize.m_dy - 1 );

		RSolidColor crBlack( kBlack );
		RSolidColor crHilight( GetSysColor( COLOR_BTNHILIGHT ) );
		ds.Draw3dRect( rcSelected, crBlack, crHilight );

		RSolidColor crShadow( GetSysColor( COLOR_BTNSHADOW ) );
		rcSelected.m_Top -= 1; rcSelected.m_Left -= 1;
		ds.Draw3dRect( rcSelected, crShadow, crHilight );

		if (GetFocus() == this)
		{
			RSolidColor rSolid = GetSysColor( COLOR_HIGHLIGHT );
			RColor rSelected( rSolid );

			rcSelected.Inflate( RIntSize( 1, 1 ), RIntSize( 2, 2 ) );
			ds.SetPenColor( RColor( rSelected ) );
			ds.FrameRectangle( rcSelected );
		}
	}

	if (m_crHilited != (COLORREF) -1L)
	{
		// Draw color chip
		m_rcColorChip = RIntRect( 
			m_ptHilited.m_x,
			m_ptHilited.m_y,
			m_ptHilited.m_x + 2 * kCellSize.m_dx,
			m_ptHilited.m_y + 2 * kCellSize.m_dy );

		YIntDimension xOffset( 2 * kCellSize.m_dx );
		YIntDimension yOffset( 2 * kCellSize.m_dy );

		if (m_rcColorChip.m_Right + xOffset > rcWindow.right)
		{
			xOffset = -3 * kCellSize.m_dx;
		}

		if (m_rcColorChip.m_Bottom + yOffset > rcWindow.bottom)
		{
			yOffset = -3 * kCellSize.m_dy;
		}

		m_rcColorChip.Offset( RIntSize( xOffset, yOffset ) );

		RColor crFill = RSolidColor( m_crHilited );
		RColor crPen = RSolidColor( kWhite );

		ds.SetPenColor( crPen );
		ds.SetFillColor( crFill );
		ds.FillRectangle( m_rcColorChip );
		ds.FrameRectangle( m_rcColorChip );
	}
	else
	{
		m_rcColorChip = RIntRect( 0, 0, 1, 1 );
	}

	ds.SetPenColor( crOldPen );
	ds.SetFillColor( crOldFill );
	ds.DetachDCs();
}
Пример #18
0
void RColor::init() {
    if (isInitialized) {
        return;
    }

    isInitialized = true;

    init(tr("By Layer"), RColor(RColor::ByLayer));
    init(tr("By Block"), RColor(RColor::ByBlock));
    init(tr("Red"), RColor(Qt::red));
    init(tr("Green"), RColor(Qt::green));
    init(tr("Blue"), RColor(Qt::blue));
    init(tr("Cyan"), RColor(Qt::cyan));
    init(tr("Magenta"), RColor(Qt::magenta));
    init(tr("Yellow"), RColor(Qt::yellow));
    init(tr("Orange"), RColor(255,127,0));
    init(tr("Dark Red"), RColor(Qt::darkRed));
    init(tr("Dark Green"), RColor(Qt::darkGreen));
    init(tr("Dark Blue"), RColor(Qt::darkBlue));
    init(tr("Dark Cyan"), RColor(Qt::darkCyan));
    init(tr("Dark Magenta"), RColor(Qt::darkMagenta));
    init(tr("Dark Yellow"), RColor(Qt::darkYellow));
    init(tr("Black"), RColor(Qt::black));
    init(tr("Gray"), RColor(Qt::gray));
    init(tr("Light Gray"), RColor(Qt::lightGray));
    init(tr("White"), RColor(Qt::white));
    init(tr("Others..."), RColor());
}
Пример #19
0
//****************************************************************************
//
// Function Name: ApplyData
//
// Description:   Applies HeadlineDataStruct effect's data
//                to the Headline depth controls
//
// Returns:       None
//
// Exceptions:	   None
//
//****************************************************************************
void RHeadlineDepthPage::ApplyData( RHeadlineInterface* pInterface, RComponentView* pComponentView )
{
	// Set the effects data
	//////////////////////////

	EProjectionEffects eProjEffects ;
	EShadowEffects eShadowEffects ;
	RIntPoint ptVanish ;
	RColor crFillColor ;
	int nNumStages ;


	pInterface->GetNumStages( nNumStages ) ;
	pInterface->GetProjectionEffect( eProjEffects ) ;
	pInterface->GetProjectionDepth( m_data.flDepth ) ;
	pInterface->GetShadowEffect( eShadowEffects ) ;
	pInterface->GetProjectionFillColor( crFillColor ) ;
	pInterface->GetProjectionVanishPoint( ptVanish ) ;

	if (eShadowEffects > kNoShadow)
	{
		// Currently these options are shared, but in
		// pre-existing data they may not be.
		pInterface->GetShadowFillColor( crFillColor ) ;
		pInterface->GetShadowVanishPoint( ptVanish ) ;
	}

	if (pComponentView->HasShadow())
	{
		RSoftShadowSettings settings;
		pComponentView->GetShadowSettings( settings );

		m_data.nDataType      = kShadowType;
		m_data.nOpacity       = ::Round( settings.m_fShadowOpacity * 100 );
		m_data.nEdgeSoftness  = ::Round( settings.m_fShadowEdgeSoftness * 100 );
		m_data.nOffset        = ::Round( settings.m_fShadowOffset * 65535 );

		m_wndBlendAngle.SetAngle( -settings.m_fShadowAngle );
		m_angle = m_wndBlendAngle.GetAngle();

		m_btnColor.SetColor( RColor( settings.m_fShadowColor ) ) ;
	}
	else
	{
		m_data.nDataType      = kDepthType ;
		m_data.nNumStages     = nNumStages ;
		m_data.nSelProjection = eProjEffects ;
		m_data.nSelShadow     = eShadowEffects ;
		m_data.fBlend			 = sWORD( RColor::kGradient == crFillColor.GetFillMethod() ) ;

		m_wndBlendAngle.SetAngle( atan2( YRealDimension( ptVanish.m_y ), 
			YRealDimension( ptVanish.m_x ) ) ) ;

		m_btnColor.SetColor( RColor(crFillColor.GetSolidColor()) ) ;

		m_angle = m_wndBlendAngle.GetAngle()  ;

		YAngle angle = fmod((double)m_angle, (double)(2.0 * kPI));
		if (angle < 0.0) angle += 2.0 * kPI;
		const YRealDimension kAngleDelta = 0.00001;
		
		if (::AreFloatsEqual(angle, kPI / 2.0, kAngleDelta) || ::AreFloatsEqual(angle, 3.0 * kPI / 2.0, kAngleDelta))
			m_data.nVanishPointX = 0;
		else
			m_data.nVanishPointX = ptVanish.m_x / cos( m_angle ) ;
		
		if (::AreFloatsEqual(angle, 0.0, kAngleDelta) || ::AreFloatsEqual(angle, kPI, kAngleDelta))
			m_data.nVanishPointY = 0;
		else
			m_data.nVanishPointY = ptVanish.m_y / sin( m_angle ) ;

/*		if (m_data.nSelShadow > kNoShadow)
		{
			pInterface->GetShadowDepth( m_data.flDepth ) ;

			m_data.nDataType      = kShadowType;
			m_data.nOpacity       = 100;
			m_data.nEdgeSoftness  = 0;
			m_data.nOffset        = 10; // TODO: determine from vanishing point

			FillData( pInterface, pComponentView );
		}
*/	}


	if (GetSafeHwnd())
	{
		// Set the image selection
		EnumResourceNames( 
			AfxGetResourceHandle(),				// resource-module handling
			cResourceType,							// pointer to resource type 
			(ENUMRESNAMEPROC) SelectResItem,	// pointer to callback function 
			(LONG) this ) ; 						// application-defined parameter 

		m_btnColor.EnableWindow( m_gcImageList.GetCurSel() != 0 ) ;
	}
}
Пример #20
0
RColor RSettings::getReferencePointColor() {
    if (referencePointColor==NULL) {
        referencePointColor = new RColor(getColor("GraphicsViewColors/ReferencePointColor", RColor(0,0,172)));
    }
    return *referencePointColor;
}
Пример #21
0
void REventHandler::drawSnapLabel(QPainter* painter, const RVector& pos, const RVector& posRestriction, const QString& text) {
    RVector p = graphicsView->mapToView(pos);
    RVector pr = RVector::invalid;
    if (posRestriction.isValid()) {
        pr = graphicsView->mapToView(posRestriction);
    }
    RColor color = RSettings::getColor("GraphicsViewColors/TextLabelColor", RColor(249,198,31));
    painter->setPen(color);

    QFont font = RSettings::getSnapLabelFont();
    font.setPointSizeF(font.pointSizeF()*graphicsView->getDevicePixelRatio());
    QFontMetrics fm(font);
    painter->setFont(font);

    int offset = 5 * graphicsView->getDevicePixelRatio();

    if (!text.isEmpty()) {
        painter->drawText(
            p.x + offset, p.y + offset,
            fm.width(text)+10, fm.height()+10,
            Qt::AlignHCenter | Qt::AlignVCenter,
            text, NULL);
    }

    painter->drawEllipse(p.x-offset, p.y-offset, offset*2, offset*2);

    // restriction position:
    if (pr.isSane()) {
        painter->drawLine(pr.x, pr.y-offset, pr.x+offset, pr.y);
        painter->drawLine(pr.x+offset, pr.y, pr.x, pr.y+offset);
        painter->drawLine(pr.x, pr.y+offset, pr.x-offset, pr.y);
        painter->drawLine(pr.x-offset, pr.y, pr.x, pr.y-offset);
    }

    // display distance/angle:
    int display = RSettings::getIntValue("DisplaySettings/DisplayDistanceAngle", 0);
    if (display == 0) {
        return;
    }

    RDocumentInterface* di = graphicsView->getDocumentInterface();
    RDocument* doc = graphicsView->getDocument();

    RVector relativeZero = di->getRelativeZero();

    double dist, angle;
    if (posRestriction.isSane()) {
        dist = relativeZero.getDistanceTo(posRestriction);
        angle = relativeZero.getAngleTo(posRestriction);
    } else {
        dist = relativeZero.getDistanceTo(pos);
        angle = relativeZero.getAngleTo(pos);
    }

    int lp = doc->getLinearPrecision();
    QString distStr = RUnit::doubleToString(dist, lp);

    angle = RMath::rad2deg(angle);
    int ap = doc->getAnglePrecision();
    QString angStr = RUnit::doubleToString(angle, ap);

    QString sep = RSettings::getStringValue("Input/PolarCoordinateSeparator", "<");

    color = RSettings::getColor("GraphicsViewColors/MeasurementToolsColor", RColor(155,220,112));
    painter->setPen(color);
    QString displayText;
    switch (display) {
    case 0:
        displayText = "";
        break;
    case 1:
        displayText = distStr + sep + angStr + QChar(0x00b0);
        break;
    case 2:
        displayText = distStr;
        break;
    case 3:
        displayText = angStr + QChar(0x00b0);
        break;
    default:
        displayText = "";
    }

    if (!displayText.isEmpty()) {
        painter->drawText(
                    p.x + offset, p.y - 3*offset - fm.height(),
                    fm.width(displayText)+10, fm.height()+10,
                    Qt::AlignHCenter | Qt::AlignVCenter,
                    displayText, NULL);
    }
}
Пример #22
0
RColor RSettings::getStartReferencePointColor() {
    if (startReferencePointColor==NULL) {
        startReferencePointColor = new RColor(getColor("GraphicsViewColors/StartReferencePointColor", RColor(192,0,32)));
    }
    return *startReferencePointColor;
}
Пример #23
0
RColor RSettings::getSecondaryReferencePointColor() {
    if (secondaryReferencePointColor==NULL) {
        secondaryReferencePointColor = new RColor(getColor("GraphicsViewColors/SecondaryReferencePointColor", RColor(0,128,172)));
    }
    return *secondaryReferencePointColor;
}
Пример #24
0
RColor RSettings::getEndReferencePointColor() {
    if (endReferencePointColor==NULL) {
        endReferencePointColor = new RColor(getColor("GraphicsViewColors/EndReferencePointColor", RColor(0,0,172)));
    }
    return *endReferencePointColor;
}