Ejemplo n.º 1
0
void Common::writeImageFile(PictureData inputPicture)
{
	string widthString = to_string(inputPicture.width);
	string heightString = to_string(inputPicture.height);

	string outputFileName = inputPicture.inputFileName.substr(0,inputPicture.inputFileName.length()-4) + ".ppm";

	//Write image File
	ofstream myfile;
	myfile.open (outputFileName);

	//Write Header
	myfile << "P3\n";
	myfile << "# This image was created by Ben Matern from input file " << inputPicture.inputFileName << "\n";
	myfile << widthString + " " + heightString + "\n";
	myfile << "255\n";

	//Loop through each pixel in the picture.
	for(int y = 0; y < inputPicture.height ; y++)
	{
		for(int x = 0; x < inputPicture.width ; x++)
		{
			string r = getColorValue(inputPicture.pixelArray[ x + y*inputPicture.width ].r);
			string b = getColorValue(inputPicture.pixelArray[ x + y*inputPicture.width ].b);
			string g = getColorValue(inputPicture.pixelArray[ x + y*inputPicture.width ].g);
			myfile << r << g << b;
		}
		//We just finished a row of pixels.
		myfile << "\n";
	}

	myfile << "";
	myfile.close();
}
Ejemplo n.º 2
0
void
GUILane::updateColor(const GUIVisualizationSettings& s) {
    const RGBColor& col = s.laneColorer.getScheme().getColor(getColorValue(s.laneColorer.getActive()));
    osg::Vec4ubArray* colors = dynamic_cast<osg::Vec4ubArray*>(myGeom->getColorArray());
    (*colors)[0].set(col.red(), col.green(), col.blue(), col.alpha());
    myGeom->setColorArray(colors);
}
void
GUIJunctionWrapper::drawGL(const GUIVisualizationSettings& s) const {
    // check whether it is not too small
    if (s.scale * myMaxSize < 1.) {
        return;
    }
    if (!myIsInner && s.drawJunctionShape) {
        glPushMatrix();
        glPushName(getGlID());
        const SUMOReal colorValue = getColorValue(s);
        GLHelper::setColor(s.junctionColorer.getScheme().getColor(colorValue));
        glTranslated(0, 0, getType());
        if (s.scale * myMaxSize < 40.) {
            GLHelper::drawFilledPoly(myJunction.getShape(), true);
        } else {
            GLHelper::drawFilledPolyTesselated(myJunction.getShape(), true);
        }
#ifdef GUIJunctionWrapper_DEBUG_DRAW_NODE_SHAPE_VERTICES
        GLHelper::debugVertices(myJunction.getShape(), 80 / s.scale);
#endif
        glPopName();
        glPopMatrix();
    }
    if (myIsInner) {
        drawName(myJunction.getPosition(), s.scale, s.internalJunctionName);
    } else {
        drawName(myJunction.getPosition(), s.scale, s.junctionName);
    }
}
Ejemplo n.º 4
0
void
GUIPerson::setColor(const GUIVisualizationSettings& s) const {
    const GUIColorer& c = s.personColorer;
    if (!setFunctionalColor(c.getActive())) {
        GLHelper::setColor(c.getScheme().getColor(getColorValue(c.getActive())));
    }
}
Ejemplo n.º 5
0
void SettingsWindow::onSelectorClicked()
{
    Colors emitter = getColorType (QObject::sender());

    /* Configure the color dialog */
    QString color;
    QColorDialog dialog;
    dialog.setCurrentColor (getColorValue (emitter));
    dialog.setOption (QColorDialog::DontUseNativeDialog);

    /* Get new color */
    if (dialog.exec() == QColorDialog::Accepted)
        color = QVariant (dialog.currentColor()).toString();

    /* User clicked the 'Cancel' button in the color dialog */
    else
        return;

    /* Update the line edit that matches the button that called this function */
    switch (emitter)
        {
        case Base:
            m_baseEdit->setText (color);
            break;
        case Highlight:
            m_highlightEdit->setText (color);
            break;
        case Background:
            m_backgroundEdit->setText (color);
            break;
        case Foreground:
            m_foregroundEdit->setText (color);
            break;
        }
}
void
GUIJunctionWrapper::updateColor(const GUIVisualizationSettings& s) {
    const SUMOReal colorValue = getColorValue(s);
    const RGBColor& col = s.junctionColorer.getScheme().getColor(colorValue);
    osg::Vec4ubArray* colors = dynamic_cast<osg::Vec4ubArray*>(myGeom->getColorArray());
    (*colors)[0].set(col.red(), col.green(), col.blue(), col.alpha());
    myGeom->setColorArray(colors);
}
Ejemplo n.º 7
0
void
GUIEdge::setColor(const GUIVisualizationSettings& s) const {
    myMesoColor = RGBColor(0,0,0); // default background color when using multiColor
    const GUIColorer& c = s.edgeColorer;
    if (!setFunctionalColor(c.getActive()) && !setMultiColor(c)) {
        myMesoColor = c.getScheme().getColor(getColorValue(c.getActive()));
    }
}
Ejemplo n.º 8
0
void
GNEJunction::setColor(const GUIVisualizationSettings& s, bool bubble) const {
    GLHelper::setColor(s.junctionColorer.getScheme().getColor(getColorValue(s, bubble)));
    // override with special colors
    if (gSelected.isSelected(getType(), getGlID())) {
        GLHelper::setColor(GNENet::selectionColor);
    }
    if (myAmCreateEdgeSource) {
        glColor3d(0, 1, 0);
    }
}
Ejemplo n.º 9
0
//-------------------------------------------------------------
// CGLTexMgr::texColor() return color mapped into an int value
//-------------------------------------------------------------
int CGLTexMgr::texColor(double v,int options){
    double s=intensity*v;
    int h,indx;
    long value=0;
    int r=0,b=0,g=0,a=255;
    double cval,aval;

    if((options & XPARANCY) > 0){
        aval=getAlphaValue(s);
        a=(int)(255*aval)&0xff;
    }  
    cval=getColorValue(s);
    h = (int)((ncolors - 1) * cval);
    indx = (h % ncolors) * 4;
    r=(int)(255.0*colormap[indx])&0xff;
    g=(int)(255.0*colormap[indx+1])&0xff;
    b=(int)(255.0*colormap[indx+2])&0xff;
    value=(a<<24)|(b<<16)|(g<<8)|(r);
    return (int)value;
}
Ejemplo n.º 10
0
void SettingsWindow::onColorChanged (QString color)
{
    Colors emitter = getColorType (QObject::sender());

    /* The color is empty, use the previous value */
    if (color.isEmpty())
        color = QVariant (getColorValue (emitter)).toString();

    /* Make sure that the color is formatted as a HEX color */
    if (!color.contains ("#"))
        color = "#" + color;

    /* We use CSS to change the color of the preview box */
    QString style = COLOR_RECTANGLE.arg (color);

    /* Update the preview box that matches the line edit that was changed */
    switch (emitter)
        {
        case Base:
            m_baseEdit->setText (color);
            m_baseColor->setStyleSheet (style);
            break;
        case Highlight:
            m_highlightEdit->setText (color);
            m_highlightColor->setStyleSheet (style);
            break;
        case Background:
            m_backgroundEdit->setText (color);
            m_backgroundColor->setStyleSheet (style);
            break;
        case Foreground:
            m_foregroundEdit->setText (color);
            m_foregroundColor->setStyleSheet (style);
            break;
        }
}
Ejemplo n.º 11
0
void
GUIEdge::setColor(const GUIVisualizationSettings& s) const {
    GLHelper::setColor(s.edgeColorer.getScheme().getColor(getColorValue(s.edgeColorer.getActive())));
}
void RptContainer::setBorder(Command command, QVariant values, bool yesFrame) {
    QColor color = values.value<QColor>();    
    if (color.isValid()) {
        setSheetValue(BorderColor,colorToString(color));
    } else {
        color = getColorValue(BorderColor);
    }

    borderColor = color;
    QString strColor = colorToString(color);
    QString stl = this->styleSheet();

    switch(command) {
        case None: {
            if (getColorValue(FrameTop) != "rgba(255,255,255,0)")
                setSheetValue(FrameTop,strColor);
            if (getColorValue(FrameBottom) != "rgba(255,255,255,0)")
                setSheetValue(FrameBottom,strColor);
            if (getColorValue(FrameLeft) != "rgba(255,255,255,0)")
                setSheetValue(FrameLeft,strColor);
            if (getColorValue(FrameRight) != "rgba(255,255,255,0)")
                setSheetValue(FrameRight,strColor);
            break;
        }
        case FrameNo: {
            setSheetValue(FrameTop,"rgba(255,255,255,0)");
            setSheetValue(FrameLeft,"rgba(255,255,255,0)");
            setSheetValue(FrameRight,"rgba(255,255,255,0)");
            setSheetValue(FrameBottom,"rgba(255,255,255,0)");
            break;
        }
        case FrameAll: {
            setSheetValue(FrameTop,strColor);
            setSheetValue(FrameLeft,strColor);
            setSheetValue(FrameRight,strColor);
            setSheetValue(FrameBottom,strColor);
            break;
        }
        case FrameTop:
        case FrameBottom:
        case FrameRight:
        case FrameLeft: {
            if (!yesFrame) strColor = "rgba(255,255,255,0)";
            setSheetValue(command,strColor);
            break;
        }
        case FrameStyle: {
            BorderStyle borderStyle = (BorderStyle)values.toInt();
            int start = stl.indexOf(";border-style:",0,Qt::CaseInsensitive);
            int end = stl.indexOf(";",start+1,Qt::CaseInsensitive);

            switch(borderStyle) {
                case Solid: {
                    stl.replace(start,end-start,";border-style:solid");
                    break;
                }
                case Dashed: {
                    stl.replace(start,end-start,";border-style:dashed");
                    break;
                }
                case Dotted: {
                    stl.replace(start,end-start,";border-style:dotted");
                    break;
                }
                case Dot_dash: {
                    stl.replace(start,end-start,";border-style:dot-dash");
                    break;
                }
                case Dot_dot_dash: {
                    stl.replace(start,end-start,";border-style:dot-dot-dash");
                    break;
                }
                case Double: {
                    stl.replace(start,end-start,";border-style:double");
                    break;
                }
                default: return;
            }
            setStyleSheet(stl);
            break;
        }
        case FrameWidth: {
            int start = stl.indexOf(";border-width:",0,Qt::CaseInsensitive);
            int end = stl.indexOf(";",start+1,Qt::CaseInsensitive);
            stl.replace(start,end-start,";border-width:"+values.toString()+"px");
            setStyleSheet(stl);
            borderWidth = values.toInt();
            break;
        }
        default: return;
    }
}
Ejemplo n.º 13
0
// constructeur
Commandant::Commandant(bool col) : Unite(col,7){
    # ifdef DEBUG
    cout << "[" << this << "]Commandant " << getColorValue(col) << " construit" << endl;
    # endif
}
Ejemplo n.º 14
0
// constructeur
Espion::Espion(bool col) : Unite(col,1){
    # ifdef DEBUG
    cout << "[" << this << "]Espion " << getColorValue(col) << " construit" << endl;
    # endif
}
Ejemplo n.º 15
0
// constructeur
Eclaireur::Eclaireur(bool col) : Unite(col,2){
    # ifdef DEBUG
    cout << "[" << this << "]Eclaireur " << getColorValue(col) << " construit" << endl;
    # endif
}
Ejemplo n.º 16
0
void
GNELane::drawGL(const GUIVisualizationSettings& s) const {
    glPushMatrix();
    glPushName(getGlID());
    glTranslated(0, 0, getType());
    const bool selectedEdge = gSelected.isSelected(myParentEdge.getType(), myParentEdge.getGlID());
    const bool selected = gSelected.isSelected(getType(), getGlID());
    if (mySpecialColor != 0) {
        GLHelper::setColor(*mySpecialColor);
    } else if (selected) {
        GLHelper::setColor(GNENet::selectedLaneColor);
    } else if (selectedEdge) {
        GLHelper::setColor(GNENet::selectionColor);
    } else {
        const GUIColorer& c = s.laneColorer;
        if (!setFunctionalColor(c.getActive()) && !setMultiColor(c)) {
            GLHelper::setColor(c.getScheme().getColor(getColorValue(c.getActive())));
        }
    };

    // draw lane
    // check whether it is not too small
    const SUMOReal selectionScale = selected || selectedEdge ? s.selectionScale : 1;
    const SUMOReal exaggeration = selectionScale * s.laneWidthExaggeration; // * s.laneScaler.getScheme().getColor(getScaleValue(s.laneScaler.getActive()));
    if (s.scale * exaggeration < 1.) {
        if (myShapeColors.size() > 0) {
            GLHelper::drawLine(getShape(), myShapeColors);
        } else {
            GLHelper::drawLine(getShape());
        }
        glPopMatrix();
    } else {
        if (drawAsRailway(s)) {
            // draw as railway
            const SUMOReal halfRailWidth = 0.725 * exaggeration;
            if (myShapeColors.size() > 0) {
                GLHelper::drawBoxLines(getShape(), myShapeRotations, myShapeLengths, myShapeColors, halfRailWidth);
            } else {
                GLHelper::drawBoxLines(getShape(), myShapeRotations, myShapeLengths, halfRailWidth);
            }
            RGBColor current = GLHelper::getColor();
            glColor3d(1, 1, 1);
            glTranslated(0, 0, .1);
            GLHelper::drawBoxLines(getShape(), myShapeRotations, myShapeLengths, halfRailWidth - 0.2);
            GLHelper::setColor(current);
            drawCrossties(0.3 * exaggeration, 1 * exaggeration, 1 * exaggeration);
        } else {
            // the actual lane
            // reduce lane width to make sure that a selected edge can still be seen
            const SUMOReal halfWidth = selectionScale * (myParentEdge.getNBEdge()->getLaneWidth(myIndex) / 2 - (selectedEdge ? .3 : 0));
            if (myShapeColors.size() > 0) {
                GLHelper::drawBoxLines(getShape(), myShapeRotations, myShapeLengths, myShapeColors, halfWidth);
            } else {
                GLHelper::drawBoxLines(getShape(), myShapeRotations, myShapeLengths, halfWidth);
            }
        }
        glPopMatrix();
        if (exaggeration == 1) {
            drawMarkings(selectedEdge, exaggeration);
        }

        // draw ROWs only if target junction has a valid logic)
        if (myParentEdge.getDest()->isLogicValid() && s.scale > 3) {
            drawArrows();
        }
    }

    glPopName();
}