コード例 #1
0
ファイル: rs_insert.cpp プロジェクト: Akaur/qdraw
/**
 * @return Pointer to the block associated with this Insert or
 *   NULL if the block couldn't be found. Blocks are requested
 *   from the blockSource if one was supplied and otherwise from
 *   the closest parent graphic.
 */
RS_Block* RS_Insert::getBlockForInsert() {
	if (block!=NULL) {
		return block;
	}

    RS_BlockList* blkList;

    if (data.blockSource==NULL) {
        if (getGraphic()!=NULL) {
            blkList = getGraphic()->getBlockList();
        } else {
            blkList = NULL;
        }
    } else {
        blkList = data.blockSource;
    }

    RS_Block* blk = NULL;
    if (blkList!=NULL) {
        blk = blkList->find(data.name);
    }

    if (blk!=NULL) {
    }

	block = blk;

    return blk;
}
コード例 #2
0
ファイル: rs_insert.cpp プロジェクト: CERobertson/LibreCAD
/**
 * @return Pointer to the block associated with this Insert or
 *   nullptr if the block couldn't be found. Blocks are requested
 *   from the blockSource if one was supplied and otherwise from
 *   the closest parent graphic.
 */
RS_Block* RS_Insert::getBlockForInsert() const{
	RS_Block* blk = nullptr;
		if (block) {
			blk=block;
			return blk;
        }

    RS_BlockList* blkList;

	if (data.blockSource==nullptr) {
		if (getGraphic()) {
            blkList = getGraphic()->getBlockList();
        } else {
			blkList = nullptr;
        }
    } else {
        blkList = data.blockSource;
    }

	if (blkList) {
        blk = blkList->find(data.name);
    }

	if (blk) {
    }

        block = blk;

    return blk;
}
コード例 #3
0
ファイル: StartText.cpp プロジェクト: qualiaa/Mythos
StartText::StartText(tank::Vectorf pos)
    : GameboyEntity(pos)
{
    makeGraphic<tank::Image>(res::menuStart);

    const float width = getGraphic()->getTextureSize().x;
    getGraphic()->setOrigin({ width / 2.f, 0.f });
}
コード例 #4
0
ファイル: rs_graphicview.cpp プロジェクト: CNClaus/LibreCAD
/**
 * Saves the current view as previous view to which we can
 * switch back later with @see restoreView().
 */
void RS_GraphicView::saveView() {
	if(getGraphic()) getGraphic()->setModified(true);
	QDateTime noUpdateWindow=QDateTime::currentDateTime().addMSecs(-500);
	//do not update view within 500 milliseconds
	if(previousViewTime > noUpdateWindow) return;
	previousViewTime = QDateTime::currentDateTime();
	savedViews[savedViewIndex]=std::make_tuple(offsetX,offsetY,factor);
	savedViewIndex = (savedViewIndex+1)%savedViews.size();
	if(savedViewCount<savedViews.size()) savedViewCount++;

	if(savedViewCount==1){
		emit previous_zoom_state(true);
	}
}
コード例 #5
0
ファイル: rs_dimdiametric.cpp プロジェクト: Aly1029/LibreCAD
/**
 * @return Automatically created label for the default
 * measurement of this dimension.
 */
QString RS_DimDiametric::getMeasuredLabel() {

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

    RS_Graphic* graphic = getGraphic();

    QString ret;
    if (graphic) {
        int dimlunit = getGraphicVariableInt("$DIMLUNIT", 2);
        int dimdec = getGraphicVariableInt("$DIMDEC", 4);
        int dimzin = getGraphicVariableInt("$DIMZIN", 1);
        RS2::LinearFormat format = graphic->getLinearFormat(dimlunit);
        ret = RS_Units::formatLinear(dist, RS2::None, format, dimdec);
        if (format == RS2::Decimal)
            ret = stripZerosLinear(ret, dimzin);
        //verify if units are decimal and comma separator
        if (dimlunit==2){
            if (getGraphicVariableInt("$DIMDSEP", 0) == 44)
                ret.replace(QChar('.'), QChar(','));
        }
    }
    else {
        ret = QString("%1").arg(dist);
    }

    return ret;
}
コード例 #6
0
/**
 * @return Automatically created label for the default
 * measurement of this dimension.
 */
QString RS_DimLinear::getMeasuredLabel() {
    // direction of dimension line
    RS_Vector dirDim;
    dirDim.setPolar(100.0, edata.angle);

    // construction line for dimension line
    RS_ConstructionLine dimLine(NULL,
                                RS_ConstructionLineData(data.definitionPoint,
                                                        data.definitionPoint + dirDim));

    RS_Vector dimP1 = dimLine.getNearestPointOnEntity(edata.extensionPoint1);
    RS_Vector dimP2 = dimLine.getNearestPointOnEntity(edata.extensionPoint2);

    // Definitive dimension line:
    double dist = dimP1.distanceTo(dimP2);

        RS_Graphic* graphic = getGraphic();

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

    return ret;
}
コード例 #7
0
ファイル: rs_block.cpp プロジェクト: Ngassa/LibreCAD
/**
 * Sets the parent documents modified status to 'm'.
 */
void RS_Block::setModified(bool m) {
    RS_Graphic* p = getGraphic();
    if (p) {
        p->setModified(m);
    }
    modified = m;
}
コード例 #8
0
ファイル: rs_entity.cpp プロジェクト: Seablade/vec2web
/**
 * Sets a variable value for the parent graphic object.
 *
 * @param key Variable name (e.g. "$DIMASZ")
 * @param val Default value
 */
void RS_Entity::addGraphicVariable(const RS_String& key,
                                   const RS_String& val, int code) {
    RS_Graphic* graphic = getGraphic();
    if (graphic!=NULL) {
        graphic->addVariable(key, val, code);
    }
}
コード例 #9
0
ファイル: rs_block.cpp プロジェクト: JGabriel85/LibreCAD
RS_LayerList* RS_Block::getLayerList() {
    RS_Graphic* g = getGraphic();
    if (g!=NULL) {
        return g->getLayerList();
    } else {
        return NULL;
    }
}
コード例 #10
0
ファイル: rs_block.cpp プロジェクト: Ngassa/LibreCAD
bool RS_Block::save(bool isAutoSave) {
    RS_Graphic* g = getGraphic();
    if (g) {
        return g->save(isAutoSave);
    } else {
        return false;
    }
}
コード例 #11
0
ファイル: rs_entity.cpp プロジェクト: Seablade/vec2web
/**
 * Sets the layer of this entity to the layer with the given name 
 */
void RS_Entity::setLayer(const RS_String& name) {
    RS_Graphic* graphic = getGraphic();
    if (graphic!=NULL) {
        layer = graphic->findLayer(name);
    } else {
        layer = NULL;
    }
}
コード例 #12
0
ファイル: rs_entity.cpp プロジェクト: Seablade/vec2web
/**
 * @return The unit the parent graphic works on or None if there's no
 * parent graphic.
 */
RS2::Unit RS_Entity::getGraphicUnit() {
    RS_Graphic* graphic = getGraphic();
    RS2::Unit ret = RS2::None;
    if (graphic!=NULL) {
        ret = graphic->getUnit();
    }
    return ret;
}
コード例 #13
0
ファイル: rs_block.cpp プロジェクト: Ngassa/LibreCAD
bool RS_Block::saveAs(const QString& filename, RS2::FormatType type, bool force) {
    RS_Graphic* g = getGraphic();
    if (g) {
        return g->saveAs(filename, type, force);
    } else {
        return false;
    }
}
コード例 #14
0
ファイル: rs_entity.cpp プロジェクト: Seablade/vec2web
/**
 * A safe member function to return the given variable.
 *
 * @param key Variable name (e.g. "$DIMASZ")
 * @param def Default value
 *
 * @return value of variable or default value if the given variable
 *    doesn't exist.
 */
int RS_Entity::getGraphicVariableInt(const RS_String& key, int def) {
    RS_Graphic* graphic = getGraphic();
    int ret=def;
    if (graphic!=NULL) {
        ret = graphic->getVariableInt(key, def);
    }
    return ret;
}
コード例 #15
0
ファイル: rs_entity.cpp プロジェクト: Seablade/vec2web
/**
 * A safe member function to return the given variable.
 *
 * @param key Variable name (e.g. "$DIMASZ")
 * @param def Default value
 *
 * @return value of variable or default value if the given variable
 *    doesn't exist.
 */
double RS_Entity::getGraphicVariableDouble(const RS_String& key, double def) {
    RS_Graphic* graphic = getGraphic();
    double ret=def;
    if (graphic!=NULL) {
        ret = graphic->getVariableDouble(key, def);
    }
    return ret;
}
コード例 #16
0
ファイル: rs_block.cpp プロジェクト: Ngassa/LibreCAD
RS_BlockList* RS_Block::getBlockList() {
    RS_Graphic* g = getGraphic();
    if (g) {
        return g->getBlockList();
    } else {
        return NULL;
    }
}
コード例 #17
0
ファイル: rs_entity.cpp プロジェクト: Aly1029/LibreCAD
/**
 * Sets the layer of this entity to the layer with the given name
 */
void RS_Entity::setLayer(const QString& name) {
    RS_Graphic* graphic = getGraphic();
    if (graphic) {
        layer = graphic->findLayer(name);
    } else {
		layer = nullptr;
    }
}
コード例 #18
0
ファイル: rs_entity.cpp プロジェクト: Seablade/vec2web
/**
 * Sets the layer of this entity to the current layer of
 * the graphic this entity is in. If this entity (and none
 * of its parents) are in a graphic the layer is set to NULL.
 */
void RS_Entity::setLayerToActive() {
    RS_Graphic* graphic = getGraphic();

    if (graphic!=NULL) {
        layer = graphic->getActiveLayer();
    } else {
        layer = NULL;
    }
}
コード例 #19
0
ファイル: rs_entity.cpp プロジェクト: Aly1029/LibreCAD
/**
 * Sets the layer of this entity to the current layer of
 * the graphic this entity is in. If this entity (and none
 * of its parents) are in a graphic the layer is set to nullptr.
 */
void RS_Entity::setLayerToActive() {
    RS_Graphic* graphic = getGraphic();

    if (graphic) {
        layer = graphic->getActiveLayer();
    } else {
		layer = nullptr;
    }
}
コード例 #20
0
ファイル: rs_entity.cpp プロジェクト: Seablade/vec2web
/**
 * A safe member function to return the given variable.
 *
 * @param key Variable name (e.g. "$DIMASZ")
 * @param def Default value
 *
 * @return value of variable or default value if the given variable
 *    doesn't exist.
 */
RS_String RS_Entity::getGraphicVariableString(const RS_String& key,
        const RS_String&  def) {
    RS_Graphic* graphic = getGraphic();
    RS_String ret=def;
    if (graphic!=NULL) {
        ret = graphic->getVariableString(key, def);
    }
    return ret;
}
コード例 #21
0
ファイル: rs_entity.cpp プロジェクト: Aly1029/LibreCAD
/**
 * A safe member function to return the given variable.
 *
 * @param key Variable name (e.g. "$DIMASZ")
 * @param def Default value
 *
 * @return value of variable or default value if the given variable
 *    doesn't exist.
 */
QString RS_Entity::getGraphicVariableString(const QString& key,
		const QString&  def) const
{
    RS_Graphic* graphic = getGraphic();
    QString ret=def;
	if (graphic) {
        ret = graphic->getVariableString(key, def);
    }
    return ret;
}
コード例 #22
0
ファイル: rs_entity.cpp プロジェクト: Seablade/vec2web
/**
 * @return Factor for scaling the line styles considering the current 
 * paper scaling and the fact that styles are stored in Millimeter.
 */
double RS_Entity::getStyleFactor(RS_GraphicView* view) {
    double styleFactor = 1.0;

    if (view!=NULL) {
        if (view->isPrinting()==false && view->isDraftMode()) {
            styleFactor = 1.0/view->getFactor().x;
        } else {
            //styleFactor = getStyleFactor();
            // the factor caused by the unit:
            RS2::Unit unit = RS2::None;
            RS_Graphic* g = getGraphic();
            if (g!=NULL) {
                unit = g->getUnit();
                //double scale = g->getPaperScale();
                styleFactor = RS_Units::convert(1.0, RS2::Millimeter, unit);
                // / scale;
            }

            // the factor caused by the line width:
            if (((int)getPen(true).getWidth())>0) {
                styleFactor *= ((double)getPen(true).getWidth()/100.0);
            } else if (((int)getPen(true).getWidth())==0) {
                styleFactor *= 0.01;
            }
        }

        if (view->isPrinting() || view->isPrintPreview() || view->isDraftMode()==false) {
            RS_Graphic* graphic = getGraphic();
            if (graphic!=NULL && graphic->getPaperScale()>1.0e-6) {
                styleFactor /= graphic->getPaperScale();
            }
        }
    }

	//RS_DEBUG->print("stylefactor: %f", styleFactor);
	//RS_DEBUG->print("viewfactor: %f", view->getFactor().x);

	if (styleFactor*view->getFactor().x<0.2) {
		styleFactor = -1.0;
	}

    return styleFactor;
}
コード例 #23
0
ファイル: rs_dimaligned.cpp プロジェクト: DietmarK/LC2DK
/**
 * @return Automatically creted label for the default
 * measurement of this dimension.
 */
QString RS_DimAligned::getMeasuredLabel() {
    double dist = edata.extensionPoint1.distanceTo(edata.extensionPoint2);

        RS_Graphic* graphic = getGraphic();

    QString ret;
        if (graphic!=NULL) {
                ret = RS_Units::formatLinear(dist, graphic->getUnit(),
                        graphic->getLinearFormat(), graphic->getLinearPrecision());
        }
        else {
        ret = QString("%1").arg(dist);
        }
    return ret;
}
コード例 #24
0
/**
 * @return Automatically created label for the default
 * measurement of this dimension.
 */
QString RS_DimRadial::getMeasuredLabel() {

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

    RS_Graphic* graphic = getGraphic();

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

    return ret;
}
コード例 #25
0
ファイル: rs_dimlinear.cpp プロジェクト: Azen2011/LibreCAD
/**
 * @return Automatically created label for the default
 * measurement of this dimension.
 */
QString RS_DimLinear::getMeasuredLabel() {
    // direction of dimension line
	RS_Vector dirDim = RS_Vector::polar(100.0, edata.angle);

    // construction line for dimension line
	RS_ConstructionLine dimLine(nullptr,
								RS_ConstructionLineData(data.definitionPoint,
														data.definitionPoint + dirDim));

    RS_Vector dimP1 = dimLine.getNearestPointOnEntity(edata.extensionPoint1);
    RS_Vector dimP2 = dimLine.getNearestPointOnEntity(edata.extensionPoint2);

    // Definitive dimension line:
    double dist = dimP1.distanceTo(dimP2) * getGeneralFactor();

        RS_Graphic* graphic = getGraphic();

    QString ret;
        if (graphic) {
            int dimlunit = getGraphicVariableInt("$DIMLUNIT", 2);
            int dimdec = getGraphicVariableInt("$DIMDEC", 4);
            int dimzin = getGraphicVariableInt("$DIMZIN", 1);
            RS2::LinearFormat format = graphic->getLinearFormat(dimlunit);
            ret = RS_Units::formatLinear(dist, RS2::None, format, dimdec);
            if (format == RS2::Decimal)
                ret = stripZerosLinear(ret, dimzin);
            //verify if units are decimal and comma separator
            if (format == RS2::Decimal || format == RS2::ArchitecturalMetric){
                if (getGraphicVariableInt("$DIMDSEP", 0) == 44)
                    ret.replace(QChar('.'), QChar(','));
            }
        }
        else {
        ret = QString("%1").arg(dist);
        }

    return ret;
}
コード例 #26
0
ファイル: rs_entity.cpp プロジェクト: Aly1029/LibreCAD
/**
 * Sets a variable value for the parent graphic object.
 *
 * @param key Variable name (e.g. "$DIMASZ")
 * @param val Default value
 */
void RS_Entity::addGraphicVariable(const QString& key, double val, int code) {
    RS_Graphic* graphic = getGraphic();
    if (graphic) {
        graphic->addVariable(key, val, code);
    }
}