当前位置: 首页>>代码示例>>C++>>正文


C++ RVector函数代码示例

本文整理汇总了C++中RVector函数的典型用法代码示例。如果您正苦于以下问题:C++ RVector函数的具体用法?C++ RVector怎么用?C++ RVector使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了RVector函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateInternal

/**
 * \return Control points of internal spline representation (may be closed).
 */
QList<RVector> RSpline::getControlPointsWrapped() const {
    QList<RVector> ret;

    updateInternal();

#ifndef R_NO_OPENNURBS
    ON_3dPoint onp;
    for (int i=0; i<curve.CVCount(); ++i) {
        curve.GetCV(i, onp);
        ret.append(RVector(onp.x, onp.y));
    }
#endif

    return ret;
}
开发者ID:DanielJSlick,项目名称:qcad,代码行数:18,代码来源:RSpline.cpp

示例2: sizeof

void OpenSMOKE_PostProcessor_RateOfProductionAnalysis::ReadFromBinaryFile(BzzLoad &fLoad)
{
	char dummy[Constants::NAME_SIZE];
	fLoad.fileLoad.read((char*) dummy, sizeof(dummy));
	std::string version = dummy;
	if (version != "V20100417")
		ErrorMessage("This version post processing file is not supported: " + version);
	cout << "Version: " << version << endl;

	// Indices of species
	CheckInBinaryFile(fLoad, "INDICES");
	fLoad >> indices;	

	// Reaction rates
	CheckInBinaryFile(fLoad, "REACTIONRATES");
	fLoad >> reactionRates;

	// Preparing data
	ropa = new OpenSMOKE_RateOfProductionAnalysis();
	BzzVector aux_x = post_processor->get_x();
	ropa->Initialize(post_processor->mix, indices);
	ropa->SetNumberOfPoints(aux_x.Size());
	ropa->Run(reactionRates, aux_x);

	// Formation rates
	{
		ChangeDimensions(post_processor->get_x().Size(), NC, &formationRates);
		BzzVector RVector(NC);
		BzzVector C(NC);
		for(int j=1;j<=post_processor->get_x().Size();j++)
		{
			double T    = post_processor->get_T(j);
			double P_Pa = post_processor->get_P_Pa(j);
			double Ctot = post_processor->get_Ctot(j);
			C = post_processor->get_C(j);
			post_processor->mix->ComputeKineticParameters( T, log(T), 1./T, P_Pa);
			post_processor->mix->ComputeFromConcentrations( T, C, Ctot, &RVector);	// [kmol/m3/s]
			formationRates.SetRow(j, RVector);										// [kmol/m3/s]
		}
	}
	Prepare();
}
开发者ID:acuoci,项目名称:OpenSMOKE,代码行数:42,代码来源:OpenSMOKE_PostProcessor_RateOfProductionAnalysis.cpp

示例3: getDimasz

QList<QSharedPointer<RShape> > RDimensionData::getArrow(
    const RVector& position, double direction) const {

    QList<QSharedPointer<RShape> > ret;
    double arrowSize = getDimasz();

    // architecture tick:
    if (useArchTick()) {
        RVector p1(arrowSize/2, arrowSize/2);

        RLine line(p1, -p1);
        line.rotate(direction, RVector(0,0));
        line.move(position);
        ret.append(QSharedPointer<RLine>(new RLine(line)));
    }

    // standard arrow:
    else {
        RTriangle arrow = RTriangle::createArrow(position, direction, arrowSize);
        ret.append(QSharedPointer<RTriangle>(new RTriangle(arrow)));
    }

    return ret;
}
开发者ID:VixMobile,项目名称:qcad,代码行数:24,代码来源:RDimensionData.cpp

示例4: ChangeDimensions

void OpenSMOKE_SensitivityAnalysis_Fast_Flame1D::BuildJAlfaMatrix(BzzVector &T, BzzVector &rho, BzzVector &Cp, vector<string> list_of_names,
																  const double P_Pascal, BzzMatrix &X)
{
	int S_NC = list_of_names.size();
	int S_NV = NV-NC+S_NC;
	int S_NE = S_NV*N;
	ChangeDimensions(S_NE, NP, &S_S);
	BzzVector xVector(NC);
	BzzVector cVector(NC);
	BzzVector RVector(NC);

	for(int n=1;n<=N_BLOCKS+1;n++)
	{
		int iStart;
		int iEnd;
		if (n<N_BLOCKS+1)
		{
			cout << "Internal block..." << endl;
			iStart	= NP_BLOCK*(n-1)+1;
			iEnd	= NP_BLOCK*n;
		}
		else
		{
			cout << "Last block..." << endl;
			iStart	= NP_BLOCK*(n-1)+1;
			iEnd	= NP;
			ChangeDimensions(NE, NP_RESIDUAL, &JAlfa);
			ChangeDimensions(NE, NP_RESIDUAL, &S);
		}

		cout << "Sensitivity Block #" << n << "/" << N_BLOCKS+1 << endl;
		
		JAlfa=0;
		for(int iPoint=1;iPoint<=N;iPoint++)
		{
			int index = (iPoint-1)*NV;

			JAlfaPoint = 0.;
			
			if (iPoint == 1 || iPoint == N)
			{
			}
			else
			{

				double cTot = P_Pascal  / (Constants::R_J_kmol*T[iPoint]);
				X.GetRow(iPoint,&xVector);
				cVector = cTot*xVector;

				mix->ComputeKineticParameters(T[iPoint], log(T[iPoint]), 1./T[iPoint], P_Pascal);
				mix->ComputeFromConcentrations(T[iPoint], cVector, cTot, &RVector);

				if (kindOfParameter == FREQUENCY_FACTOR)						mix->GiveMe_Jalfa_A(JAlfaPoint, nu, T[iPoint], indexSpecies, indexTemperature, parameters);
				else if (kindOfParameter == FREQUENCY_FACTOR_AND_TRANSPORT_PROPERTIES)	mix->GiveMe_Jalfa_A(JAlfaPoint, nu, T[iPoint], indexSpecies, indexTemperature, parameters);
				else ErrorMessage("Wrong Sensitivity Parameter");
				//if (kindOfParameter == BETA)				mix->GiveMe_Jalfa_Beta(JAlfaPoint, nu, T[iPoint], indexSpecies, indexTemperature, parameters);
				//if (kindOfParameter == ACTIVATION_ENERGY)	mix->GiveMe_Jalfa_Eatt(JAlfaPoint, nu, T[iPoint], indexSpecies, indexTemperature, parameters);

				for(int k=1;k<=NP;k++)
					if (parameters[k] <= 0.)	ErrorMessage("Parameters must be larger than zero!");
			}

			// Temperature equations
			if (Cp[1]<0) // this means no energy equation
			{
				for(int j=iStart;j<=iEnd;j++)
					JAlfa[index+indexTemperature][j-iStart+1] = 0;
			}
			else
			{
				for(int j=iStart;j<=iEnd;j++)
					JAlfa[index+indexTemperature][j-iStart+1] = JAlfaPoint[indexTemperature][j]/(rho[iPoint]*Cp[iPoint]);
			}

			// Species equations
			for(int i=1;i<=NC;i++)
				for(int j=iStart;j<=iEnd;j++)
					JAlfa[index+indexSpecies+i-1][j-iStart+1] = JAlfaPoint[indexSpecies+i-1][j]/rho[iPoint];
		}

		JAlfa *= -1.;
		Solve(AFactorized, JAlfa, &S);

		for(int k=iStart;k<=iEnd;k++)
		{
			int j;

			// First Rows 
			for(j=1;j<=indexSpecies-1;j++)
				for(int i=1;i<=N;i++)
					S_S[(i-1)*S_NV+j][k] = S[(i-1)*NV+j][k-iStart+1];

			// Species Rows
			for(j=1;j<=S_NC;j++)
			{
				int index = mix->recognize_species(list_of_names[j-1]);
				for(int i=1;i<=N;i++)
					S_S[(i-1)*S_NV+(j+indexSpecies-1)][k] = S[(i-1)*NV+(index+indexSpecies-1)][k-iStart+1];
			}
		}
//.........这里部分代码省略.........
开发者ID:acuoci,项目名称:OpenSMOKE,代码行数:101,代码来源:OpenSMOKE_SensitivityAnalysis_Fast_Flame1D.cpp

示例5: interpolate

RVector interpolate(const Mesh & mesh, const RVector & data,
                    const RVector & x, bool verbose){
    return interpolate(mesh, data, x,
                       RVector(x.size(), 0.0), RVector(x.size(), 0.0));
}
开发者ID:Moouuzi,项目名称:gimli,代码行数:5,代码来源:interpolate.cpp

示例6: tan

void ROrthoGrid::paintCursor(const RVector& pos) {
    // crosshair size:
    double s = 0;
    if (!RSettings::getShowLargeCrosshair()) {
        s = view.mapDistanceFromView(25);
    }

    RBox b = view.getBox();
    if (isometric) {
        double dxp, dyp, dxn, dyn;
        if (RSettings::getShowLargeCrosshair()) {
            dxp = b.c2.x - pos.x;
            dyp = tan(M_PI/6) * dxp;
            dxn = pos.x - b.c1.x;
            dyn = tan(M_PI/6) * dxn;
        }
        else {
            dxp = dxn = cos(M_PI/6) * s;
            dyp = dyn = sin(M_PI/6) * s;
        }

        // .-´
        if (projection==RS::IsoTop || projection==RS::IsoRight) {
            view.paintGridLine(RLine(pos + RVector(dxp,dyp), pos - RVector(dxn,dyn)));
        }
        // `-.
        if (projection==RS::IsoTop || projection==RS::IsoLeft) {
            view.paintGridLine(RLine(pos + RVector(dxp,-dyp), pos - RVector(dxn,-dyn)));
        }

        // |
        if (projection==RS::IsoRight || projection==RS::IsoLeft) {
            if (RSettings::getShowLargeCrosshair()) {
                view.paintGridLine(RLine(RVector(pos.x, b.c1.y), RVector(pos.x, b.c2.y)));
            }
            else {
                view.paintGridLine(RLine(RVector(pos.x, pos.y - s), RVector(pos.x, pos.y + s)));
            }
        }
    }
    else {
        if (RSettings::getShowLargeCrosshair()) {
            view.paintGridLine(RLine(RVector(b.c1.x, pos.y), RVector(b.c2.x, pos.y)));
            view.paintGridLine(RLine(RVector(pos.x, b.c1.y), RVector(pos.x, b.c2.y)));
        }
        else {
            double s = view.mapDistanceFromView(25);
            RVector sx(s, 0);
            RVector sy(0, s);
            view.paintGridLine(RLine(pos-sx, pos+sx));
            view.paintGridLine(RLine(pos-sy, pos+sy));
        }
    }
}
开发者ID:Jackieee,项目名称:qcad,代码行数:54,代码来源:ROrthoGrid.cpp

示例7: if

void ROrthoGrid::paintRuler(RRuler& ruler, qreal devicePixelRatio) {
    RDocument* doc = view.getDocument();
    if (doc == NULL) {
        return;
    }

    RS::Unit unit = doc->getUnit();
    RS::LinearFormat linearFormat = doc->getLinearFormat();

    // use grid spacing if available or auto grid spacing:
    RVector localSpacing = spacing;
    if (!localSpacing.isValid() ||
        (autoSpacing.isValid() && autoSpacing.getMagnitude2d() < localSpacing.getMagnitude2d())) {
        localSpacing = autoSpacing;
    }

    // use meta grid spacing if available or auto meta grid spacing:
    RVector localMetaSpacing = metaSpacing;
    if (!localMetaSpacing.isValid() ||
        (autoMetaSpacing.isValid() && autoMetaSpacing.getMagnitude2d() < localMetaSpacing.getMagnitude2d())) {
        //localMetaSpacing = autoMetaSpacing;
    }

    //if (!localMetaSpacing.isValid()) {
    //    qDebug() << "no local meta spacing";
    //    return;
    //}

    if (localSpacing.getMagnitude()<1.0e-6 || localMetaSpacing.getMagnitude()<1.0e-6)  {
        //qDebug() << "local (meta) spacing too small";
        return;
    }

    RVector min = gridBox.getCorner1();
    RVector max = gridBox.getCorner2();
    bool isHorizontal = ruler.getOrientation() == Qt::Horizontal;

    double tickSpacing;
    //if (!RUnit::isMetric(doc->getUnit())) {
    if (isFractionalFormat(linearFormat) && !RUnit::isMetric(unit)) {
        if (isHorizontal) {
            tickSpacing = localSpacing.x;
        } else {
            tickSpacing = localSpacing.y;
        }
    } else {
        if (isHorizontal) {
            tickSpacing = localMetaSpacing.x;
        } else {
            tickSpacing = localMetaSpacing.y;
        }
        if (view.mapDistanceToView(tickSpacing) >= 80) {
            tickSpacing /= 10;
        } else if (view.mapDistanceToView(tickSpacing) >= 30) {
            tickSpacing /= 5;
        } else if (view.mapDistanceToView(tickSpacing) >= 20) {
            tickSpacing /= 2;
        }
    }

    // ideal tick spacing in pixels:
    int pSpacing = (int) ceil(view.mapDistanceToView(tickSpacing));

    QString l1 = RUnit::getLabel(isHorizontal ? min.x : min.y, *doc, false, true);
    QString l2 = RUnit::getLabel(isHorizontal ? max.x : max.y, *doc, false, true);
    int labelWidth = std::max(
            QFontMetrics(ruler.getFont()).boundingRect(l1).width(),
            QFontMetrics(ruler.getFont()).boundingRect(l2).width()) + 15;

    // smallest displayable distance between labels in steps (ticks):
    int minLabelStep = 1;
    if (pSpacing>0) {
        minLabelStep = labelWidth / pSpacing + 1;
    }

    int labelStep = minLabelStep;
    //if (!RUnit::isMetric(doc->getUnit())) {
    if (isFractionalFormat(linearFormat) && !RUnit::isMetric(unit)) {
        // non metric
        double f = 1.0/128;
        do {
            if (localMetaSpacing.isValid()) {
                if (isHorizontal) {
                    labelStep = RMath::mround(localMetaSpacing.x / localSpacing.x) * f;
                } else {
                    labelStep = RMath::mround(localMetaSpacing.y / localSpacing.y) * f;
                }
            }
            else {
                labelStep = (int)f;
            }
            f = f * 2;
            if (f>65536) {
                labelStep = -1;
            }
        } while (labelStep < minLabelStep && labelStep>=0);
    } else {
        // metric
        if (labelStep >= 3 && labelStep <= 4) {
            labelStep = 5;
//.........这里部分代码省略.........
开发者ID:Jackieee,项目名称:qcad,代码行数:101,代码来源:ROrthoGrid.cpp

示例8: inchAutoscale

QList<RVector> ROrthoGrid::getIdealGridSpacing(RGraphicsView& view, int minPixelSpacing, const RVector& minSpacing, const RVector& minMetaSpacing) {
    RS::Unit unit = view.getDocument()->getUnit();
    RS::LinearFormat linearFormat = view.getDocument()->getLinearFormat();
    QList<RVector> ret;

    if (isFractionalFormat(linearFormat) && !RUnit::isMetric(unit)) {
        double idealInchSpacing = RUnit::convert(view.mapDistanceFromView(qMax(minPixelSpacing, 1)), unit, RS::Inch);

        RVector spacing = RUnit::convert(minSpacing, unit, RS::Inch);
        spacing.x = inchAutoscale(spacing.x, idealInchSpacing, unit);
        spacing.y = inchAutoscale(spacing.y, idealInchSpacing, unit);
        spacing = RUnit::convert(spacing, RS::Inch, unit);

        // never drop below min spacing:
        if (spacing.x<minSpacing.x) {
            spacing.x = minSpacing.x;
        }
        if (spacing.y<minSpacing.y) {
            spacing.y = minSpacing.y;
        }

        RVector metaSpacing = spacing; // RVector(1.0 / 64, 1.0 / 64, 1.0 / 64);
        metaSpacing.x = inchAutoscale(metaSpacing.x, idealInchSpacing * 4, unit);
        metaSpacing.y = inchAutoscale(metaSpacing.y, idealInchSpacing * 4, unit);
        metaSpacing = RUnit::convert(metaSpacing, RS::Inch, unit);

        // never drop below min spacing:
        if (metaSpacing.x<minMetaSpacing.x) {
            metaSpacing.x = minMetaSpacing.x;
        }
        if (metaSpacing.y<minMetaSpacing.y) {
            metaSpacing.y = minMetaSpacing.y;
        }

        // foot: never show meta grid of < 1 foot:
        if (unit==RS::Foot) {
            if (metaSpacing.x<1.0) {
                metaSpacing.x = 1.0;
            }
            if (metaSpacing.y<1.0) {
                metaSpacing.y = 1.0;
            }
        }

//        if (metaSpacing.x < this->metaSpacing.x) {
//            metaSpacing.x = this->metaSpacing.x;
//        }

        ret.append(spacing);
        ret.append(metaSpacing);
        return ret;
    } else {
        // ideal (minimum) grid spacing for the given view (some odd number):
        double idealSpacing = view.mapDistanceFromView(qMax(minPixelSpacing, 1));

        // idealSpacing = minSpacing * idealFactor
        RVector idealFactor(idealSpacing / minSpacing.x,
                            idealSpacing / minSpacing.y);

        // idealFactor = minSpacing * 10^n
        RVector n(log(idealFactor.x / minSpacing.x) / log(10.0),
                  log(idealFactor.y / minSpacing.y) / log(10.0));

        // factor = minSpacing * 10^ceil(n)
        RVector factor(minSpacing.x * pow(10.0, ceil(n.x - 1.0e-6)),
                       minSpacing.y * pow(10.0, ceil(n.y - 1.0e-6)));

        // never drop below min spacing:
        if (factor.x<1.0) {
            factor.x = 1.0;
        }
        if (factor.y<1.0) {
            factor.y = 1.0;
        }

        // grid spacing:
        double x, y;
        x = minSpacing.x * factor.x;
        y = minSpacing.y * factor.y;
        ret.append(RVector(x,y));

        // meta grid spacing:
        double mx, my;
        if (RMath::isNaN(minMetaSpacing.x)) {
            mx = x * 10;
        }
        else {
            //mx = minMetaSpacing.x * factor.x;
            mx = minMetaSpacing.x;
        }

        if (RMath::isNaN(minMetaSpacing.y)) {
            my = y * 10;
        }
        else {
            //my = minMetaSpacing.y * factor.y;
            my = minMetaSpacing.y;
        }
        ret.append(RVector(mx, my));

//.........这里部分代码省略.........
开发者ID:Jackieee,项目名称:qcad,代码行数:101,代码来源:ROrthoGrid.cpp

示例9: getProjection

void ROrthoGrid::paintGridLines(const RVector& space, const RBox& box, bool meta) {
    if (!space.isValid()) {
        return;
    }

    // updates cache if necessary:
    getProjection();
    isIsometric();

    RVector min = box.getCorner1();
    RVector max = box.getCorner2();

    double deltaX = max.x - min.x;
    double deltaY = max.y - min.y;

    if (deltaX / space.x > 1e3 || deltaY / space.y > 1e3) {
        return;
    }

    double dx = deltaY / tan(M_PI/6);
    if (isometric) {
        min.x -= dx;
        max.x += dx;
    }
    int c;
    double x;
    for (x=min.x, c=0; x<max.x; x+=space.x, c++) {
        //int x2 = RMath::mround(x/space.x);
        //if (!isometric || c%2==0) {
        if (isometric) {
            if (projection==RS::IsoTop || projection==RS::IsoRight) {
                view.paintGridLine(RLine(RVector(x, min.y), RVector(x+dx, max.y)));
            }
            if (projection==RS::IsoTop || projection==RS::IsoLeft) {
                view.paintGridLine(RLine(RVector(x, min.y), RVector(x-dx, max.y)));
            }

            // vertical grid lines:
            if (projection==RS::IsoRight || projection==RS::IsoLeft) {
                view.paintGridLine(RLine(RVector(x, min.y), RVector(x, max.y)));
                view.paintGridLine(RLine(RVector(x-space.x/2, min.y), RVector(x-space.x/2, max.y)));
            }
        }
        else {
            view.paintGridLine(RLine(RVector(x, min.y), RVector(x, max.y)));
        }
        //}
    }

    // horizontal lines:
    if (!isometric) {
        for (double y=min.y; y<max.y; y+=space.y) {
            view.paintGridLine(RLine(RVector(min.x, y), RVector(max.x, y)));
        }
    }
}
开发者ID:Jackieee,项目名称:qcad,代码行数:56,代码来源:ROrthoGrid.cpp

示例10: QMainWindow

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");
}
开发者ID:konysulphrea,项目名称:qcad,代码行数:84,代码来源:MainWindow.cpp

示例11: qWarning

/**
 * Updates the grid information, in particular the grid spacing and
 * grid region to the current view port.
 */
void ROrthoGrid::update(bool force) {
    if (!force && viewBox==view.getBox()) {
        return;
    }

    viewBox = view.getBox();
    int viewportNumber = view.getViewportNumber();

    RDocument* doc = view.getDocument();
    if (doc == NULL) {
        qWarning() << "ROrthoGrid::update: document is NULL";
        return;
    }

    RGraphicsScene* scene = view.getScene();
    if (scene==NULL) {
        qWarning() << "ROrthoGrid::update: scene is NULL";
        return;
    }

    RS::ProjectionRenderingHint hint =  scene->getProjectionRenderingHint();

    // for 3d views, we have no convenient way to calculate the grid dimensions:
    if (hint == RS::RenderThreeD) {
        gridBox = RBox(RVector(-1000, -1000), RVector(1000, 1000));
        spacing = RVector(10.0, 10.0);
        return;
    }

    QString key;

    key = QString("Grid/IsometricGrid0%1").arg(viewportNumber);
    isometric = doc->getVariable(key, false, true).toBool();

    RS::Unit unit = doc->getUnit();
    RS::LinearFormat linearFormat = doc->getLinearFormat();

    // default values for missing configurations and 'auto' settings:
    minSpacing.valid = true;
    minMetaSpacing.valid = true;
    if (isFractionalFormat(linearFormat) && !RUnit::isMetric(unit)) {
        //minSpacing.x = minSpacing.y = RNANDOUBLE;
        //minMetaSpacing.x = minMetaSpacing.y = RNANDOUBLE;
        minSpacing.x = minSpacing.y = RUnit::convert(1.0, RS::Inch, unit) / 1024;
        minMetaSpacing.x = minMetaSpacing.y = RUnit::convert(1.0, RS::Inch, unit) / 1024;
    }
    else {
        minSpacing.x = minSpacing.y = 1.0e-6;
        minMetaSpacing.x = minMetaSpacing.y = RNANDOUBLE;
        //minSpacing.x = minSpacing.y = RNANDOUBLE;
        //minMetaSpacing.x = minMetaSpacing.y = 1.0e-6;
    }

    key = QString("Grid/GridSpacingX0%1").arg(viewportNumber);
    QVariant strSx = doc->getVariable(key, QVariant(), true);
    key = QString("Grid/GridSpacingY0%1").arg(viewportNumber);
    QVariant strSy = doc->getVariable(key, QVariant(), true);

    spacing.valid = true;

    bool autoX = !strSx.isValid() || strSx.toString()=="auto";
    bool autoY = !strSy.isValid() || strSy.toString()=="auto";

    // grid spacing x:
    if (!autoX) {
        // fixed:
        double d = RMath::eval(strSx.toString());
        if (!RMath::hasError() && d>RS::PointTolerance) {
            minSpacing.x = spacing.x = d;
        }
    }

    // grid spacing y:
    if (!autoY) {
        double d = RMath::eval(strSy.toString());
        if (!RMath::hasError() && d>RS::PointTolerance) {
            minSpacing.y = spacing.y = d;
        }
    }




    // meta grid:
    key = QString("Grid/MetaGridSpacingX0%1").arg(viewportNumber);
    QVariant strMsx = doc->getVariable(key, QVariant(), true);
    key = QString("Grid/MetaGridSpacingY0%1").arg(viewportNumber);
    QVariant strMsy = doc->getVariable(key, QVariant(), true);

    metaSpacing.valid = true;

    bool metaAutoX = !strMsx.isValid() || strMsx.toString()=="auto";
    bool metaAutoY = !strMsy.isValid() || strMsy.toString()=="auto";

    // meta grid spacing x:
    if (!metaAutoX) {
//.........这里部分代码省略.........
开发者ID:Jackieee,项目名称:qcad,代码行数:101,代码来源:ROrthoGrid.cpp

示例12: getLinetypePattern

void RExporter::exportLine(const RLine& line, double offset) {
    if (!line.isValid()) {
        return;
    }

    double length = line.getLength();

    if (length>1e100 || length<RS::PointTolerance) {
        return;
    }

    RLinetypePattern p = getLinetypePattern();

    // continuous line or
    // we are in draft mode or
    // QCAD is configured to show screen based line patterns
    if (!p.isValid() || p.getNumDashes() == 1 || draftMode || screenBasedLinetypes) {
        exportLineSegment(line);
        return;
    }

    p.scale(getPatternFactor());
    double patternLength = p.getPatternLength();
    

    // avoid huge number of small segments due to very fine 
    // pattern or long lines:
    if (patternLength<RS::PointTolerance || length / patternLength > 5000) {
        exportLineSegment(line);
        return;
    }

    double angle = line.getAngle();
    RVector* vp = NULL;
    vp = new RVector[p.getNumDashes()];
    for (int i = 0; i < p.getNumDashes(); ++i) {
        vp[i] = RVector(cos(angle) * fabs(p.getDashLengthAt(i)),
                        sin(angle) * fabs(p.getDashLengthAt(i)));
    }

    bool optimizeEnds = false;
    if (RMath::isNaN(offset)) {
        offset = getPatternOffset(length, p);
        optimizeEnds = true;
    }
    else {
        double num = ceil(offset / patternLength);
        offset -= num * patternLength;
    }

    bool done = false;
    int i = 0;
    RVector cursor(line.getStartPoint() + RVector::createPolar(offset, angle));
    double total = offset;
    bool dashFound = false;
    bool gapFound = false;
    RVector p1 = line.getStartPoint();
    RVector p2 = p1;

    do {
        if (dashFound && !gapFound) {
            // don't shoot over end of line:
            if (total + fabs(p.getDashLengthAt(i)) >= length - 1.0e-6) {
                if (optimizeEnds) {
                    exportLineSegment(RLine(p1, line.endPoint));
                }
                else {
                    exportLineSegment(RLine(p1, p2));
                }
                break;
            }
            exportLineSegment(RLine(p1, p2));
        }

        // dash, no gap. note that a dash can have a length of 0.0 (point):
        if (p.getDashLengthAt(i) > -RS::PointTolerance) {
            // check if we're on the line already:
            if (total + p.getDashLengthAt(i) > 0) {
                p1 = cursor;

                // no gap at the beginning of the line:
                if (total < 0 || (!dashFound && optimizeEnds)) {
                    p1 = line.startPoint;
                }

                p2 = cursor + vp[i];
                if (!p2.equalsFuzzy(line.startPoint, 1.0e-6)) {
                    dashFound = true;
                }
            }
            gapFound = false;
        }

        // gap:
        else {
            gapFound = true;
        }

        cursor += vp[i];
        total += fabs(p.getDashLengthAt(i));
//.........这里部分代码省略.........
开发者ID:DanielJSlick,项目名称:qcad,代码行数:101,代码来源:RExporter.cpp

示例13: RVector

RVector TravelTimeDijkstraModelling::createDefaultStartModel() {
    return RVector(this->regionManager().parameterCount(), findMedianSlowness());
}
开发者ID:gimli-org,项目名称:gimli,代码行数:3,代码来源:ttdijkstramodelling.cpp

示例14: scale

bool REntityData::scale(double scaleFactor, const RVector& center) {
    return scale(RVector(scaleFactor, scaleFactor, scaleFactor), center);
}
开发者ID:VixMobile,项目名称:qcad,代码行数:3,代码来源:REntityData.cpp

示例15: if

bool RSolidEntity::setProperty(RPropertyTypeId propertyTypeId,
        const QVariant& value, RTransaction* transaction) {
    bool ret = REntity::setProperty(propertyTypeId, value, transaction);

    if (propertyTypeId==PropertyPoint1X || propertyTypeId==PropertyPoint1Y || propertyTypeId==PropertyPoint1Z) {
        RVector v = data.getVertexAt(0);
        if (propertyTypeId==PropertyPoint1X) {
            v.x = value.toDouble();
        }
        else if (propertyTypeId==PropertyPoint1Y) {
            v.y = value.toDouble();
        }
        else if (propertyTypeId==PropertyPoint1Z) {
            v.z = value.toDouble();
        }
        data.setVertexAt(0, v);
        ret = true;
    }
    else if (propertyTypeId==PropertyPoint2X || propertyTypeId==PropertyPoint2Y || propertyTypeId==PropertyPoint2Z) {
        RVector v = data.getVertexAt(1);
        if (propertyTypeId==PropertyPoint2X) {
            v.x = value.toDouble();
        }
        else if (propertyTypeId==PropertyPoint2Y) {
            v.y = value.toDouble();
        }
        else if (propertyTypeId==PropertyPoint2Z) {
            v.z = value.toDouble();
        }
        data.setVertexAt(1, v);
        ret = true;
    }
    else if (propertyTypeId==PropertyPoint3X || propertyTypeId==PropertyPoint3Y || propertyTypeId==PropertyPoint3Z) {
        RVector v = data.getVertexAt(2);
        if (propertyTypeId==PropertyPoint3X) {
            v.x = value.toDouble();
        }
        else if (propertyTypeId==PropertyPoint3Y) {
            v.y = value.toDouble();
        }
        else if (propertyTypeId==PropertyPoint3Z) {
            v.z = value.toDouble();
        }
        data.setVertexAt(2, v);
        ret = true;
    }
    else if (propertyTypeId==PropertyPoint4X || propertyTypeId==PropertyPoint4Y || propertyTypeId==PropertyPoint4Z) {
        if (data.countVertices()<4) {
            data.appendVertex(RVector(0,0,0));
        }

        RVector v = data.getVertexAt(3);
        if (propertyTypeId==PropertyPoint4X) {
            v.x = value.toDouble();
        }
        else if (propertyTypeId==PropertyPoint4Y) {
            v.y = value.toDouble();
        }
        else if (propertyTypeId==PropertyPoint4Z) {
            v.z = value.toDouble();
        }
        data.setVertexAt(3, v);
        ret = true;
    }

    return ret;
}
开发者ID:fallenwind,项目名称:qcad,代码行数:67,代码来源:RSolidEntity.cpp


注:本文中的RVector函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。