void ResultsJsInterface::showAnalysesMenu(QString options)
{
	Json::Value menuOptions;

	Json::Reader parser;
	parser.parse(fq(options), menuOptions);

	QIcon _copyIcon = QIcon(":/icons/copy.png");
	QIcon _citeIcon = QIcon(":/icons/cite.png");
	QIcon _codeIcon = QIcon(":/icons/code-icon.png");
	QIcon _collapseIcon = QIcon(":/icons/collapse.png");
	QIcon _expandIcon = QIcon(":/icons/expand.png");
	QIcon _saveImageIcon = QIcon(":/icons/document-save-as.png");
	QIcon _editImageIcon = QIcon(":/icons/editImage.png");

	_analysisMenu->clear();

	QString objName = tq(menuOptions["objectName"].asString());

	if (menuOptions["hasCollapse"].asBool())
	{
		Json::Value collapseOptions = menuOptions["collapseOptions"];
		QIcon icon = collapseOptions["collapsed"].asBool() ? _expandIcon : _collapseIcon;
		_analysisMenu->addAction(icon, tq(collapseOptions["menuText"].asString()), this, SLOT(collapseSelected()));
		_analysisMenu->addSeparator();
	}

	if (menuOptions["hasEditTitle"].asBool())
	{
		_analysisMenu->addAction("Edit Title", this, SLOT(editTitleSelected()));
		_analysisMenu->addSeparator();
	}

	if (menuOptions["hasCopy"].asBool())
		_analysisMenu->addAction(_copyIcon, "Copy", this, SLOT(copySelected()));

	if (menuOptions["hasLaTeXCode"].asBool())  // TODO: || menuOptions["hasPlainText"].asBool())
	{
		_copySpecialMenu = _analysisMenu->addMenu(tr("&Copy special"));

		_copySpecialMenu->addAction(_codeIcon, "LaTeX code", this, SLOT(latexCodeSelected()));

		QAction *copyTextAction = new QAction("Copy text");
		// connect(copyTextAction, SIGNAL(triggered), this, SLOT(copyTextSelected));
		copyTextAction->setEnabled(false);
		_copySpecialMenu->addAction(copyTextAction);
	}

	if (menuOptions["hasCite"].asBool())
	{
		_analysisMenu->addSeparator();
		_analysisMenu->addAction(_citeIcon, "Copy Citations", this, SLOT(citeSelected()));
	}

	if (menuOptions["hasSaveImg"].asBool())
	{
		_analysisMenu->addAction(_saveImageIcon, "Save Image As", this, SLOT(saveImage()));
	}
#ifdef JASP_DEBUG
    if (menuOptions["hasEditImg"].asBool())
    {
        _analysisMenu->addAction(_editImageIcon, "Edit Image", this, SLOT(editImage()));
    }
#endif

	if (menuOptions["hasNotes"].asBool())
	{
		_analysisMenu->addSeparator();

		Json::Value noteOptions = menuOptions["noteOptions"];

		for (Json::ValueIterator iter = noteOptions.begin(); iter != noteOptions.end(); iter++)
		{
			Json::Value noteOption = *iter;
			QAction *a1 = _analysisMenu->addAction(tq(noteOption["menuText"].asString()), this, SLOT(noteSelected()));

			a1->setDisabled(noteOption["visible"].asBool());


			QString call = QString("window.notesMenuClicked('%1', %2);").arg(tq(noteOption["key"].asString())).arg(noteOption["visible"].asBool() ? "false" : "true");

			a1->setData(call);
		}
	}


	if (menuOptions["hasRemove"].asBool())
	{
		_analysisMenu->addSeparator();
		_analysisMenu->addAction("Remove " + objName, this, SLOT(removeSelected()));
	}

	if (menuOptions["hasRemoveAllAnalyses"].asBool())
	{
		_analysisMenu->addSeparator();
		_analysisMenu->addAction("Remove All ", _mainWindow, SLOT(removeAllAnalyses()));
	}

	if (menuOptions["hasRefreshAllAnalyses"].asBool())
	{
		_analysisMenu->addSeparator();
		_analysisMenu->addAction("Refresh All ", _mainWindow, SLOT(refreshAllAnalyses()));
	}

	QPoint point = _webViewResults->mapToGlobal(QPoint(round(menuOptions["rX"].asInt() * _webViewZoom), round(menuOptions["rY"].asInt() * _webViewZoom)));

	_analysisMenu->move(point);
	_analysisMenu->show();
}
예제 #2
0
  void hessian(RawArray<const T,2> x, RawArray<T,4> hess) const {
    // Temporary arrays and views
    GEODE_ASSERT(x.sizes()==vec(n+3,d) && hess.sizes()==vec(n+3,4,d,d));
    const auto sx = smallx.flat.raw(),
               sv = smallv.flat.raw();

    // Collect quadrature points
    const int e = 1+8*d+8*d*(d-1);
    Array<T,3> tq(    n,quads,e,uninit);
    Array<T,4> xq(vec(n,quads,e,d),uninit);
    Array<T,4> vq(vec(n,quads,e,d),uninit);
    for (int i=0;i<n;i++) {
      T_INFO(i)
      for (int q=0;q<quads;q++) {
        const T s = samples[q],
                t = t1+dt*s;
        for (int j=0;j<e;j++)
          tq(i,q,j) = t;
        SPLINE_INFO(s)
        for (int a=0;a<d;a++) {
          X_INFO(i,a)
          const T x = a0*x0+a1*x1+a2*x2+a3*x3,
                  v = b0*x0+b1*x1+b2*x2+b3*x3;
          for (int j=0;j<e;j++) {
            xq(i,q,j,a) = x;
            vq(i,q,j,a) = v;
          }
          int j = 1;
          for (int b=0;b<d;b++) {
            const T xb = sx[b],
                    vb = sv[b];
            xq(i,q,j++,a) -= xb;
            xq(i,q,j++,a) += xb;
            vq(i,q,j++,a) -= vb;
            vq(i,q,j++,a) += vb;
            xq(i,q,j  ,a) -= xb;
            vq(i,q,j++,a) -= vb;
            xq(i,q,j  ,a) -= xb;
            vq(i,q,j++,a) += vb;
            xq(i,q,j  ,a) += xb;
            vq(i,q,j++,a) -= vb;
            xq(i,q,j  ,a) += xb;
            vq(i,q,j++,a) += vb;
            for (int c=b+1;c<d;c++) {
              const T xc = sx[c],
                      vc = sv[c];
              xq(i,q,j++,a) -= xb+xc;
              xq(i,q,j++,a) -= xb-xc;
              xq(i,q,j++,a) += xb-xc;
              xq(i,q,j++,a) += xb+xc;
              vq(i,q,j++,a) -= vb+vc;
              vq(i,q,j++,a) -= vb-vc;
              vq(i,q,j++,a) += vb-vc;
              vq(i,q,j++,a) += vb+vc;

              vq(i,q,j++,a) -= sv[b];
              xq(i,q,j  ,a) -= sx[b];
              vq(i,q,j++,a) += sv[b];
              xq(i,q,j  ,a) += sx[b];
              vq(i,q,j++,a) -= sv[b];
              xq(i,q,j  ,a) += sx[b];
              vq(i,q,j++,a) += sv[b];
            }
          }
        }
      }
    }

    // Compute energies
    const auto Uq_ = U(tq.reshape_own(n*quads*d4),NdArray<const T>(q2shape,xq.flat),NdArray<const T>(q2shape,vq.flat));
    GEODE_ASSERT(Uq_.size()==n*quads*d4);
    const auto Uq = Uq_.reshape(n,quads,d4);

    // Accumulate
    grad.fill(0);
    const auto inv_2s = GEODE_RAW_ALLOCA(d,Vector<T,2>);
    for (int a=0;a<d;a++)
      inv_2s[a] = vec(.5/sx[a],.5/sv[a]);
    for (int i=0;i<n;i++) {
      T_INFO(i)
      for (int q=0;q<quads;q++) {
        const T s = samples[q],
                w = dt*weights[q];
        SPLINE_INFO(s)
        for (int b=0;b<d;b++) {
          const T wx = w*inv_2s[b].x*(Uq(i,q,4*b+1)-Uq(i,q,4*b  )),
                  wv = w*inv_2s[b].y*(Uq(i,q,4*b+3)-Uq(i,q,4*b+2));
          grad(i  ,b) += a0*wx+b0*wv;
          grad(i+1,b) += a1*wx+b1*wv;
          grad(i+2,b) += a2*wx+b2*wv;
          grad(i+3,b) += a3*wx+b3*wv;
        }
      }
    }
  }
int mainProc(int argc, char **argv) {
    argv += (argc > 0);
    argc -= (argc > 0);

    option::Stats stats(usage, argc, argv);
    vector<option::Option> options(stats.options_max);
    vector<option::Option> buffer(stats.buffer_max);
    option::Parser parse(usage, argc, argv, options.data(), buffer.data());

    if (parse.error()) {
        option::printUsage(cerr, usage);
        return 1;
    }

    for (auto &option : options) {
        if (option.desc && option.desc->index == UNKNOWN) {
            cerr << "Unknown option: " << option.name << endl;
            option::printUsage(cout, usage);
            return 1;
        }
    }

    if (options[HELP]) {
        option::printUsage(cout, usage);
        return 0;
    }

    size_t numThreads = 1;
    if (options[THREADS]) {
        int num = atoi(options[THREADS].arg);
        if (num < 1) {
            cerr << "Illegal number of threads" << endl;
            exit(1);
        }
        numThreads = num;
    }

    unordered_set<string> dictionaries;
    for (option::Option* opt = options[DICT]; opt; opt = opt->next()) {
        dictionaries.insert(opt->arg);
    }

    string modelFilename;
    if (options[MODEL]) {
        modelFilename = options[MODEL].arg;
    }
    else {
        option::printUsage(cerr, usage);
        return 1;
    }

    NgramDictionaryDecoder decoder(modelFilename, dictionaries);

    hwm::task_queue tq(numThreads);
    queue<future<void>> futureQueue;

    while (true) {
        auto seq = Utility::readSequence(cin);
        vector<string> ret;
        vector<size_t> lengths;
        bool emptyFlag = seq.empty();
        future<void> f = tq.enqueue(&NgramDictionaryDecoder::decode_and_return_lengths, decoder, seq, &ret, &lengths);
        futureQueue.push(move(f));

        if ((numThreads == 1 || !cin) && !futureQueue.empty()) {
            futureQueue.front().wait();
        }
        while (!futureQueue.empty() && futureQueue.front().wait_for(std::chrono::seconds(0)) == std::future_status::ready) {
            futureQueue.front().get();
            futureQueue.pop();
            for (size_t i = 0; i < ret.size(); ++i) {
                cout << seq[i] << "\t" << ret[i] << "\n";
            }
            cout << endl;
        }
        if (!cin && emptyFlag && futureQueue.empty()) {
            break;
        }
    }

    return 0;
}
예제 #4
0
int main( int argc, char **argv )
{
	//setup optimization variables
	std::string opt_env= "OSG_OPTIMIZER=COMBINE_ADJACENT_LODS SHARE_DUPLICATE_STATE MERGE_GEOMETRY MAKE_FAST_GEOMETRY CHECK_GEOMETRY OPTIMIZE_TEXTURE_SETTINGS STATIC_OBJECT_DETECTION";
#ifdef WIN32
	_putenv(opt_env.c_str());
#else
	char * writable = new char[opt_env.size() + 1];
	std::copy(opt_env.begin(), opt_env.end(), writable);
	writable[opt_env.size()] = '\0'; // don't forget the terminating 0
	putenv(writable);
	delete[] writable;
#endif

	const bool enableShadows = true;

	// use an ArgumentParser object to manage the program arguments.
	osg::ArgumentParser arguments(&argc,argv);

	// construct the viewer.
	osgViewer::Viewer viewer(arguments);

	// add the stats handler
	viewer.addEventHandler(new osgViewer::StatsHandler);
	viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()));

	osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;

	keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() );
	keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() );
	keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() );
	keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() );
	keyswitchManipulator->addMatrixManipulator( '5', "Orbit", new osgGA::OrbitManipulator() );
	keyswitchManipulator->addMatrixManipulator( '6', "FirstPerson", new osgGA::FirstPersonManipulator() );
	keyswitchManipulator->addMatrixManipulator( '7', "Spherical", new osgGA::SphericalManipulator() );
	viewer.setCameraManipulator( keyswitchManipulator.get() );

	//Add sample data path

	osgDB::Registry::instance()->getDataFilePathList().push_back("../data");
	osgDB::Registry::instance()->getDataFilePathList().push_back("./data"); //hack to be able to runt from GCC out dir

	osg::DisplaySettings::instance()->setNumMultiSamples(8);

	//Load terrain
	osg::ref_ptr<osg::Node> terrain = osgDB::readNodeFile("lz.osg");
	if(!terrain)
	{
		std::cerr  << "Terrain mesh not found\n";
		return 0;
	}

	osg::Group* group = new osg::Group;
	group->addChild(terrain);


	//Create mesh LODs
	osgVegetation::MeshLODVector lods;
	lods.push_back(osgVegetation::MeshLOD("trees/fir01_l0.osg",50));
	lods.push_back(osgVegetation::MeshLOD("trees/fir01_l1.osg",200));

	//Create one mesh layers with LODS
	osgVegetation::MeshLayer  spruce(lods);
	spruce.Density = 0.1;
	spruce.Height.set(0.5,0.5);
	spruce.Width.set(0.5,0.5);
	spruce.Scale.set(0.8,0.9);
	spruce.ColorIntensity.set(3.0,3.0);
	spruce.TerrainColorRatio = 1.0;
	spruce.UseTerrainIntensity = false;
	spruce.CoverageMaterials.push_back(WOODS);

	//Create mesh data that hold all mesh layers
	osgVegetation::MeshData tree_data;
	tree_data.ReceiveShadows = enableShadows;
	
	//Add layers
	tree_data.Layers.push_back(spruce);

	osg::ComputeBoundsVisitor  cbv;
	
	terrain->accept(cbv);
	
	osg::BoundingBoxd bb(cbv.getBoundingBox()._min, cbv.getBoundingBox()._max);

	//osg::Vec3d bb_size = bb._max - bb._min;

	//Down size bb for faster generation...useful for testing purpose
	//bb._min = bb._min + bb_size*0.3;
	//bb._max = bb._max - bb_size*0.3;

	osg::Node* tree_node = NULL;

	//Create coverage data used by the terrain query class
	osgVegetation::CoverageData cd;

	//...add the materials, here we match material name with colors
	cd.CoverageMaterials.push_back(osgVegetation::CoverageData::CoverageMaterial(GRASS,osgVegetation::CoverageColor(0,0,1,1)));
	cd.CoverageMaterials.push_back(osgVegetation::CoverageData::CoverageMaterial(WOODS,osgVegetation::CoverageColor(1,1,1,1)));
	cd.CoverageMaterials.push_back(osgVegetation::CoverageData::CoverageMaterial(ROAD,osgVegetation::CoverageColor(0,0,1,1)));
	cd.CoverageMaterials.push_back(osgVegetation::CoverageData::CoverageMaterial(DIRT,osgVegetation::CoverageColor(1,0,0,1)));

	//Create terrain query class and by feeding terrain and coverage data
	osgVegetation::TerrainQuery tq(terrain.get(),cd);

	//create scattering class
	osgVegetation::EnvironmentSettings env_settings;
	osgVegetation::MeshQuadTreeScattering scattering(&tq,env_settings);

	try{
		//Start generation
		tree_node = scattering.generate(bb,tree_data);
		group->addChild(tree_node);
	}
	catch(std::exception& e)
	{
		std::cerr << e.what();
		return 0;
	}

	//Add light and shadows
	osg::Light* pLight = new osg::Light;
	pLight->setDiffuse( osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f) );
	osg::Vec4 lightPos(1,0.5,1,0);
	pLight->setPosition(lightPos);		// last param	w = 0.0 directional light (direction)
	osg::Vec3f lightDir(-lightPos.x(),-lightPos.y(),-lightPos.z());
	lightDir.normalize();
	pLight->setDirection(lightDir);
	pLight->setAmbient(osg::Vec4(0.3f, 0.3f, 0.3f, 1.0f) );
	//pLight->setDiffuse(osg::Vec4(0.0f, 0.0f, 0.0f, 1.0f) );

	osg::LightSource* pLightSource = new osg::LightSource;
	pLightSource->setLight( pLight );
	group->addChild( pLightSource );


	static int ReceivesShadowTraversalMask = 0x1;
	static int CastsShadowTraversalMask = 0x2;

	osg::ref_ptr<osgShadow::ShadowedScene> shadowedScene = new osgShadow::ShadowedScene;
	osgShadow::ShadowSettings* settings = shadowedScene->getShadowSettings();
	settings->setReceivesShadowTraversalMask(ReceivesShadowTraversalMask);
	settings->setCastsShadowTraversalMask(CastsShadowTraversalMask);
	settings->setShadowMapProjectionHint(osgShadow::ShadowSettings::PERSPECTIVE_SHADOW_MAP);

	unsigned int unit=2;
	settings->setBaseShadowTextureUnit(unit);

	double n=0.8;
	settings->setMinimumShadowMapNearFarRatio(n);

	unsigned int numShadowMaps = 2;
	settings->setNumShadowMapsPerLight(numShadowMaps);

	int mapres = 1024;
	settings->setTextureSize(osg::Vec2s(mapres,mapres));
	//settings->setShaderHint(osgShadow::ShadowSettings::PROVIDE_VERTEX_AND_FRAGMENT_SHADER);

	osg::ref_ptr<osgShadow::ViewDependentShadowMap> vdsm = new osgShadow::ViewDependentShadowMap;
	shadowedScene->setShadowTechnique(vdsm.get());
	terrain->setNodeMask(ReceivesShadowTraversalMask);
	tree_node->setNodeMask(CastsShadowTraversalMask | ReceivesShadowTraversalMask);

	if(enableShadows)
	{
		shadowedScene->addChild(group);
		viewer.setSceneData(shadowedScene);
	}
	else
	{
		viewer.setSceneData(group);
	}


	return viewer.run();
}
예제 #5
0
  void gradient(RawArray<const T,2> x, RawArray<T,2> grad) const {
    // Temporary arrays and views
    GEODE_ASSERT(x.sizes()==vec(n+3,d) && grad.sizes()==x.sizes());
    const auto sx = smallx.flat.raw(),
               sv = smallv.flat.raw();

    // Collect quadrature points
    const int e = 4*d;
    Array<T,3> tq(    n,quads,e,uninit);
    Array<T,4> xq(vec(n,quads,e,d),uninit);
    Array<T,4> vq(vec(n,quads,e,d),uninit);
    for (int i=0;i<n;i++) {
      T_INFO(i)
      for (int q=0;q<quads;q++) {
        const T s = samples[q],
                t = t1+dt*s;
        for (int j=0;j<e;j++)
          tq(i,q,j) = t;
        SPLINE_INFO(s)
        for (int a=0;a<d;a++) {
          X_INFO(i,a)
          const T x = a0*x0+a1*x1+a2*x2+a3*x3,
                  v = b0*x0+b1*x1+b2*x2+b3*x3;
          for (int j=0;j<e;j++) {
            xq(i,q,j,a) = x;
            vq(i,q,j,a) = v;
          }
        }
        for (int a=0;a<d;a++) {
          xq(i,q,4*a  ,a) -= sx[a];
          xq(i,q,4*a+1,a) += sx[a];
          vq(i,q,4*a+2,a) -= sv[a];
          vq(i,q,4*a+3,a) += sv[a];
        }
      }
    }

    // Compute energies
    const auto Uq_ = U(tq.reshape_own(n*quads*e),NdArray<const T>(q2shape,xq.flat),NdArray<const T>(q2shape,vq.flat));
    GEODE_ASSERT(Uq_.size()==n*quads*e);
    const auto Uq = Uq_.reshape(n,quads,e);

    // Accumulate
    grad.fill(0);
    const auto inv_2s = GEODE_RAW_ALLOCA(d,Vector<T,2>);
    for (int a=0;a<d;a++)
      inv_2s[a] = vec(.5/sx[a],.5/sv[a]);
    for (int i=0;i<n;i++) {
      T_INFO(i)
      for (int q=0;q<quads;q++) {
        const T s = samples[q],
                w = dt*weights[q];
        SPLINE_INFO(s)
        for (int a=0;a<d;a++) {
          const T wx = w*inv_2s[a].x*(Uq(i,q,4*a+1)-Uq(i,q,4*a  )),
                  wv = w*inv_2s[a].y*(Uq(i,q,4*a+3)-Uq(i,q,4*a+2));
          grad(i  ,a) += a0*wx+b0*wv;
          grad(i+1,a) += a1*wx+b1*wv;
          grad(i+2,a) += a2*wx+b2*wv;
          grad(i+3,a) += a3*wx+b3*wv;
        }
      }
    }
  }
QString OnlineDataManager::getLocalPath(QString nodePath) const {

    QString name = QString(QCryptographicHash::hash(nodePath.toLatin1(),QCryptographicHash::Md5).toHex());
    std::string tempFile = tempfiles_createSpecific("online", fq(name));
    return tq(tempFile);
}
예제 #7
0
int
run_main (int argc, ACE_TCHAR *argv[])
{
  ACE_START_TEST (ACE_TEXT ("Network_Adapters_Test"));

#if defined (ACE_WIN32)
#if !defined (ACE_HAS_WINCE)
  SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE);
#endif
#else /* #if defined (ACE_WIN32) */
  // Set a handler for SIGSEGV signal to call for abort.
  ACE_Sig_Action sa1 ((ACE_SignalHandler) sigsegv_handler, SIGSEGV);
#endif /* #if defined (ACE_WIN32) */
  if (::parse_args (argc, argv) == -1)
    {
      return -1;
    }

  ACE_Reactor * main_reactor = 0;
  ACE_NEW_RETURN (main_reactor, ACE_Reactor, -1);

  (void) ACE_High_Res_Timer::global_scale_factor ();

  // Change the source of time in the reactor to the high-resolution
  // timer.  Why does this test require such precision for a 1 second
  // timer is beyond me ...  I think it is a cut&paste error.
  //
  // The use of auto_ptr<> is optional, ACE uses dangerous memory
  // management idioms everywhere, I thought I could demonstrate how
  // to do it right in at least one test.  Notice the lack of
  // ACE_NEW_RETURN, that monstrosity has no business in proper C++
  // code ...
  auto_ptr<ACE_Timer_Heap_Variable_Time_Source> tq(
      new ACE_Timer_Heap_Variable_Time_Source);
  // ... notice how the policy is in the derived timer queue type.
  // The abstract timer queue does not have a time policy ...
  tq->set_time_policy(&ACE_High_Res_Timer::gettimeofday_hr);
  // ... and then the timer queue is replaced.  Strangely, the reactor
  // does *not* copy the timers, it just deletes the existing timer
  // queue ....
  main_reactor->timer_queue(tq.get());
  // ... the reactor does not assume ownership

  /**
   * Stop_Handler's is supposed to stop the activity of all
   * handlers by a SIGINT signal.  We create and activate here an object of
   * Stop_Handler and pass an instance of reactor (main_reactor),
   * running demultiplexing event loop in the "main thread".
   */
  Stop_Handler* stop_handler = 0;
  ACE_NEW_RETURN (stop_handler, Stop_Handler (main_reactor), -1);
  if (stop_handler->open () == -1)
    {
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("(%P|%t) %p\n"),
                  ACE_TEXT ("main() - stop_handler->open")));
      ACE_OS::exit(-2);
    }

  ACE_TCHAR *ping_status = 0;
  ACE_NEW_RETURN (ping_status, ACE_TCHAR[number_of_ping_points], -1);

  // wait_echo_reply_timer is in msec
  int seconds = 0;
  int milliseconds = 0;
  seconds = wait_echo_reply_timer / 1000;
  milliseconds =  wait_echo_reply_timer % 1000;
  ACE_Time_Value const wait_timer (seconds, milliseconds);

  Echo_Handler *ping_handler = 0;
  ACE_NEW_RETURN (ping_handler, Echo_Handler, -1);

  if (ACE_OS::strlen (local_ip_to_bind))
    {
      // We are willing to bind the raw-socket to a certain adapter,
      // probably because we are willing to check connectivity/etc
      // of the local adapter.
      ACE_INET_Addr local_adapter;
      local_adapter.set ((u_short) 0, local_ip_to_bind);
      if (ping_handler->open (main_reactor,
                              wait_timer,
                              ping_points_addrs,
                              number_of_ping_points,
                              ping_status,
                              2,  // max_attempts_number
                              local_adapter) == -1)
        {
          int res = 0;
          // If this process doesn't have privileges to open a raw socket, log
          // a warning instead of an error.
          if (errno == EPERM || errno == EACCES)
            {
              ACE_ERROR ((LM_WARNING,
                          ACE_TEXT ("(%P|%t) main() - ping_handler->open: ")
                          ACE_TEXT ("insufficient privs to run this test\n")));
            }
          else
            {
              ACE_ERROR ((LM_ERROR,
                          ACE_TEXT ("(%P|%t) %p\n"),
                          ACE_TEXT ("main() - ping_handler->open")));
              res = -4;
            }
          delete ping_handler;
          delete [] ping_status;
          delete main_reactor;
          delete stop_handler;

          ACE_END_TEST;
          return res;
        }
    }
  else
    {
      // Binding to a local adapter is not of our interest. We just
      // are willing to check all these remote IPs, to monitor, that
      // they are alive.
      if (ping_handler->open (main_reactor,
                              wait_timer,
                              ping_points_addrs,
                              number_of_ping_points,
                              ping_status,
                              2) == -1)   // max_attempts_number
        {
          int res = 0;
          if (errno == EPERM || errno == EACCES)
            {
              ACE_ERROR ((LM_WARNING,
                          ACE_TEXT ("(%P|%t) main() - ping_handler->open: ")
                          ACE_TEXT ("insufficient privs to run this test\n")));
            }
          else
            {
              ACE_ERROR ((LM_ERROR,
                          ACE_TEXT ("(%P|%t) %p\n"),
                          ACE_TEXT ("main() - ping_handler->open")));
              res = -4;
            }
          delete ping_handler;
          delete [] ping_status;
          delete main_reactor;
          delete stop_handler;

          ACE_END_TEST;
          return res;
        }
    }

  Repeats_Handler *repeats_handler = 0;
  ACE_NEW_RETURN (repeats_handler, Repeats_Handler, -1);
  if (repeats_handler->open (ping_handler,
                             main_reactor,
                             repeats_seconds_timer) == -1)
    {
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("(%P|%t) %p\n"),
                  ACE_TEXT ("main() - repeats_handler->open")));

      delete repeats_handler;
      delete ping_handler;
      delete [] ping_status;
      delete main_reactor;
      delete stop_handler;

      ACE_END_TEST;
      return -4;
    }

  stop_handler->register_handler (repeats_handler);
  stop_handler->register_handler (ping_handler);

  // Demultiplexing event loop of the main_reactor.
  while (main_reactor->reactor_event_loop_done () == 0)
    {
      main_reactor->run_reactor_event_loop ();
    }

  ACE_DEBUG ((LM_INFO,
              ACE_TEXT ("(%P|%t|%T) \"Network_Adapters_Test\" main() - ")
              ACE_TEXT ("out of reactor's loop.\n")));

  delete repeats_handler;
  delete ping_handler;
  delete [] ping_status;
  delete main_reactor;
  delete stop_handler;

  ACE_END_TEST;
  return 0;
}
예제 #8
0
QTCEXPORT(void*,qtc_QScriptEngine_fromScriptQObjectValue)(wchar_t* x0, void* x1, void* x2)
{
  QString tq(from_method(x0));
  QObject*tx1 = *((QPointer<QObject>*)x1);
  if (tx1->property(QTC_PROP).isValid()) tx1 = (((qtc_DynamicQObject *)tx1)->parent());
  QObject*tx2 = *((QPointer<QObject>*)x2);
  int x;
  x = qsn_hash->value(tq, -1);
  switch (x) {
    case 0:
      {
      QAbstractButton * tc = ((QScriptEngine*)tx1)->fromScriptValue<QAbstractButton*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QAbstractButton> * ttc = new QPointer<QAbstractButton>(tc);
      return (void*)(ttc);
      }
      break;
    case 1:
      {
      QAbstractItemView * tc = ((QScriptEngine*)tx1)->fromScriptValue<QAbstractItemView*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QAbstractItemView> * ttc = new QPointer<QAbstractItemView>(tc);
      return (void*)(ttc);
      }
      break;
    case 2:
      {
      QAbstractScrollArea * tc = ((QScriptEngine*)tx1)->fromScriptValue<QAbstractScrollArea*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QAbstractScrollArea> * ttc = new QPointer<QAbstractScrollArea>(tc);
      return (void*)(ttc);
      }
      break;
    case 3:
      {
      QAbstractSlider * tc = ((QScriptEngine*)tx1)->fromScriptValue<QAbstractSlider*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QAbstractSlider> * ttc = new QPointer<QAbstractSlider>(tc);
      return (void*)(ttc);
      }
      break;
    case 4:
      {
      QAbstractSpinBox * tc = ((QScriptEngine*)tx1)->fromScriptValue<QAbstractSpinBox*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QAbstractSpinBox> * ttc = new QPointer<QAbstractSpinBox>(tc);
      return (void*)(ttc);
      }
      break;
    case 5:
      {
      QAbstractTableModel * tc = ((QScriptEngine*)tx1)->fromScriptValue<QAbstractTableModel*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QAbstractTableModel> * ttc = new QPointer<QAbstractTableModel>(tc);
      return (void*)(ttc);
      }
      break;
    case 6:
      {
      QAbstractTextDocumentLayout * tc = ((QScriptEngine*)tx1)->fromScriptValue<QAbstractTextDocumentLayout*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QAbstractTextDocumentLayout> * ttc = new QPointer<QAbstractTextDocumentLayout>(tc);
      return (void*)(ttc);
      }
      break;
    case 7:
      {
      QAction * tc = ((QScriptEngine*)tx1)->fromScriptValue<QAction*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QAction> * ttc = new QPointer<QAction>(tc);
      return (void*)(ttc);
      }
      break;
    case 8:
      {
      QActionGroup * tc = ((QScriptEngine*)tx1)->fromScriptValue<QActionGroup*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QActionGroup> * ttc = new QPointer<QActionGroup>(tc);
      return (void*)(ttc);
      }
      break;
    case 9:
      {
      QApplication * tc = ((QScriptEngine*)tx1)->fromScriptValue<QApplication*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QApplication> * ttc = new QPointer<QApplication>(tc);
      return (void*)(ttc);
      }
      break;
    case 10:
      {
      QBoxLayout * tc = ((QScriptEngine*)tx1)->fromScriptValue<QBoxLayout*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QBoxLayout> * ttc = new QPointer<QBoxLayout>(tc);
      return (void*)(ttc);
      }
      break;
    case 11:
      {
      QButtonGroup * tc = ((QScriptEngine*)tx1)->fromScriptValue<QButtonGroup*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QButtonGroup> * ttc = new QPointer<QButtonGroup>(tc);
      return (void*)(ttc);
      }
      break;
    case 12:
      {
      QCalendarWidget * tc = ((QScriptEngine*)tx1)->fromScriptValue<QCalendarWidget*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QCalendarWidget> * ttc = new QPointer<QCalendarWidget>(tc);
      return (void*)(ttc);
      }
      break;
    case 13:
      {
      QCheckBox * tc = ((QScriptEngine*)tx1)->fromScriptValue<QCheckBox*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QCheckBox> * ttc = new QPointer<QCheckBox>(tc);
      return (void*)(ttc);
      }
      break;
    case 14:
      {
      QComboBox * tc = ((QScriptEngine*)tx1)->fromScriptValue<QComboBox*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QComboBox> * ttc = new QPointer<QComboBox>(tc);
      return (void*)(ttc);
      }
      break;
    case 15:
      {
      QDial * tc = ((QScriptEngine*)tx1)->fromScriptValue<QDial*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QDial> * ttc = new QPointer<QDial>(tc);
      return (void*)(ttc);
      }
      break;
    case 16:
      {
      QDialog * tc = ((QScriptEngine*)tx1)->fromScriptValue<QDialog*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QDialog> * ttc = new QPointer<QDialog>(tc);
      return (void*)(ttc);
      }
      break;
    case 17:
      {
      QDialogButtonBox * tc = ((QScriptEngine*)tx1)->fromScriptValue<QDialogButtonBox*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QDialogButtonBox> * ttc = new QPointer<QDialogButtonBox>(tc);
      return (void*)(ttc);
      }
      break;
    case 18:
      {
      QDockWidget * tc = ((QScriptEngine*)tx1)->fromScriptValue<QDockWidget*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QDockWidget> * ttc = new QPointer<QDockWidget>(tc);
      return (void*)(ttc);
      }
      break;
    case 19:
      {
      QDoubleSpinBox * tc = ((QScriptEngine*)tx1)->fromScriptValue<QDoubleSpinBox*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QDoubleSpinBox> * ttc = new QPointer<QDoubleSpinBox>(tc);
      return (void*)(ttc);
      }
      break;
    case 20:
      {
      QErrorMessage * tc = ((QScriptEngine*)tx1)->fromScriptValue<QErrorMessage*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QErrorMessage> * ttc = new QPointer<QErrorMessage>(tc);
      return (void*)(ttc);
      }
      break;
    case 21:
      {
      QFocusFrame * tc = ((QScriptEngine*)tx1)->fromScriptValue<QFocusFrame*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QFocusFrame> * ttc = new QPointer<QFocusFrame>(tc);
      return (void*)(ttc);
      }
      break;
    case 22:
      {
      QFontComboBox * tc = ((QScriptEngine*)tx1)->fromScriptValue<QFontComboBox*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QFontComboBox> * ttc = new QPointer<QFontComboBox>(tc);
      return (void*)(ttc);
      }
      break;
    case 23:
      {
      QGLWidget * tc = ((QScriptEngine*)tx1)->fromScriptValue<QGLWidget*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QGLWidget> * ttc = new QPointer<QGLWidget>(tc);
      return (void*)(ttc);
      }
      break;
    case 24:
      {
      QGridLayout * tc = ((QScriptEngine*)tx1)->fromScriptValue<QGridLayout*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QGridLayout> * ttc = new QPointer<QGridLayout>(tc);
      return (void*)(ttc);
      }
      break;
    case 25:
      {
      QGroupBox * tc = ((QScriptEngine*)tx1)->fromScriptValue<QGroupBox*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QGroupBox> * ttc = new QPointer<QGroupBox>(tc);
      return (void*)(ttc);
      }
      break;
    case 26:
      {
      QHBoxLayout * tc = ((QScriptEngine*)tx1)->fromScriptValue<QHBoxLayout*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QHBoxLayout> * ttc = new QPointer<QHBoxLayout>(tc);
      return (void*)(ttc);
      }
      break;
    case 27:
      {
      QHeaderView * tc = ((QScriptEngine*)tx1)->fromScriptValue<QHeaderView*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QHeaderView> * ttc = new QPointer<QHeaderView>(tc);
      return (void*)(ttc);
      }
      break;
    case 28:
      {
      QIODevice * tc = ((QScriptEngine*)tx1)->fromScriptValue<QIODevice*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QIODevice> * ttc = new QPointer<QIODevice>(tc);
      return (void*)(ttc);
      }
      break;
    case 29:
      {
      QLCDNumber * tc = ((QScriptEngine*)tx1)->fromScriptValue<QLCDNumber*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QLCDNumber> * ttc = new QPointer<QLCDNumber>(tc);
      return (void*)(ttc);
      }
      break;
    case 30:
      {
      QLabel * tc = ((QScriptEngine*)tx1)->fromScriptValue<QLabel*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QLabel> * ttc = new QPointer<QLabel>(tc);
      return (void*)(ttc);
      }
      break;
    case 31:
      {
      QLayout * tc = ((QScriptEngine*)tx1)->fromScriptValue<QLayout*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QLayout> * ttc = new QPointer<QLayout>(tc);
      return (void*)(ttc);
      }
      break;
    case 32:
      {
      QLineEdit * tc = ((QScriptEngine*)tx1)->fromScriptValue<QLineEdit*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QLineEdit> * ttc = new QPointer<QLineEdit>(tc);
      return (void*)(ttc);
      }
      break;
    case 33:
      {
      QMenu * tc = ((QScriptEngine*)tx1)->fromScriptValue<QMenu*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QMenu> * ttc = new QPointer<QMenu>(tc);
      return (void*)(ttc);
      }
      break;
    case 34:
      {
      QMenuBar * tc = ((QScriptEngine*)tx1)->fromScriptValue<QMenuBar*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QMenuBar> * ttc = new QPointer<QMenuBar>(tc);
      return (void*)(ttc);
      }
      break;
    case 35:
      {
      QMessageBox * tc = ((QScriptEngine*)tx1)->fromScriptValue<QMessageBox*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QMessageBox> * ttc = new QPointer<QMessageBox>(tc);
      return (void*)(ttc);
      }
      break;
    case 36:
      {
      QProgressBar * tc = ((QScriptEngine*)tx1)->fromScriptValue<QProgressBar*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QProgressBar> * ttc = new QPointer<QProgressBar>(tc);
      return (void*)(ttc);
      }
      break;
    case 37:
      {
      QProgressDialog * tc = ((QScriptEngine*)tx1)->fromScriptValue<QProgressDialog*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QProgressDialog> * ttc = new QPointer<QProgressDialog>(tc);
      return (void*)(ttc);
      }
      break;
    case 38:
      {
      QPushButton * tc = ((QScriptEngine*)tx1)->fromScriptValue<QPushButton*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QPushButton> * ttc = new QPointer<QPushButton>(tc);
      return (void*)(ttc);
      }
      break;
    case 39:
      {
      QRubberBand * tc = ((QScriptEngine*)tx1)->fromScriptValue<QRubberBand*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QRubberBand> * ttc = new QPointer<QRubberBand>(tc);
      return (void*)(ttc);
      }
      break;
    case 40:
      {
      QScrollArea * tc = ((QScriptEngine*)tx1)->fromScriptValue<QScrollArea*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QScrollArea> * ttc = new QPointer<QScrollArea>(tc);
      return (void*)(ttc);
      }
      break;
    case 41:
      {
      QScrollBar * tc = ((QScriptEngine*)tx1)->fromScriptValue<QScrollBar*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QScrollBar> * ttc = new QPointer<QScrollBar>(tc);
      return (void*)(ttc);
      }
      break;
    case 42:
      {
      QSlider * tc = ((QScriptEngine*)tx1)->fromScriptValue<QSlider*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QSlider> * ttc = new QPointer<QSlider>(tc);
      return (void*)(ttc);
      }
      break;
    case 43:
      {
      QSpinBox * tc = ((QScriptEngine*)tx1)->fromScriptValue<QSpinBox*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QSpinBox> * ttc = new QPointer<QSpinBox>(tc);
      return (void*)(ttc);
      }
      break;
    case 44:
      {
      QTabBar * tc = ((QScriptEngine*)tx1)->fromScriptValue<QTabBar*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QTabBar> * ttc = new QPointer<QTabBar>(tc);
      return (void*)(ttc);
      }
      break;
    case 45:
      {
      QTabWidget * tc = ((QScriptEngine*)tx1)->fromScriptValue<QTabWidget*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QTabWidget> * ttc = new QPointer<QTabWidget>(tc);
      return (void*)(ttc);
      }
      break;
    case 46:
      {
      QTextBrowser * tc = ((QScriptEngine*)tx1)->fromScriptValue<QTextBrowser*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QTextBrowser> * ttc = new QPointer<QTextBrowser>(tc);
      return (void*)(ttc);
      }
      break;
    case 47:
      {
      QTextDocument * tc = ((QScriptEngine*)tx1)->fromScriptValue<QTextDocument*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QTextDocument> * ttc = new QPointer<QTextDocument>(tc);
      return (void*)(ttc);
      }
      break;
    case 48:
      {
      QTextEdit * tc = ((QScriptEngine*)tx1)->fromScriptValue<QTextEdit*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QTextEdit> * ttc = new QPointer<QTextEdit>(tc);
      return (void*)(ttc);
      }
      break;
    case 49:
      {
      QVBoxLayout * tc = ((QScriptEngine*)tx1)->fromScriptValue<QVBoxLayout*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QVBoxLayout> * ttc = new QPointer<QVBoxLayout>(tc);
      return (void*)(ttc);
      }
      break;
    case 50:
      {
      QWidget * tc = ((QScriptEngine*)tx1)->fromScriptValue<QWidget*>((const QScriptValue&)(*(QScriptValue*)tx2));
      QPointer<QWidget> * ttc = new QPointer<QWidget>(tc);
      return (void*)(ttc);
      }
      break;
    default:
      break;
  }
  return (void*)(NULL);
}
예제 #9
0
MainWindow::MainWindow(QWidget *parent) :
	QMainWindow(parent),
	ui(new Ui::MainWindow)
{
	_log = NULL;
	_tableModel = NULL;
	_currentOptionsWidget = NULL;
	_currentAnalysis = NULL;

	_optionsForm = NULL;

	_package = new DataSetPackage();

	_package->isModifiedChanged.connect(boost::bind(&MainWindow::packageChanged, this, _1));
	QShortcut *saveShortcut = new QShortcut(QKeySequence("Ctrl+S"), this);
	QObject::connect(saveShortcut, SIGNAL(activated()), this, SLOT(saveKeysSelected()));
	QShortcut *openShortcut = new QShortcut(QKeySequence("Ctrl+O"), this);
	QObject::connect(openShortcut, SIGNAL(activated()), this, SLOT(openKeysSelected()));

	ui->setupUi(this);

	int initalTableWidth = 530;

	QList<int> sizes = QList<int>();
	sizes.append(initalTableWidth);
	ui->splitter->setSizes(sizes);

	ui->tabBar->setFocusPolicy(Qt::NoFocus);
	ui->tabBar->addTab("File");
#ifdef QT_DEBUG
	ui->tabBar->addTab("Variables"); // variables view
#endif
	ui->tabBar->addTab("Common");
#ifndef __linux__
	ui->tabBar->addOptionsTab(); // no SEM under linux for now
#endif
	ui->tabBar->addHelpTab();

	connect(ui->tabBar, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
	connect(ui->tabBar, SIGNAL(helpToggled(bool)), this, SLOT(helpToggled(bool)));

	ui->ribbonAnalysis->setDataSetLoaded(false);
	ui->ribbonSEM->setDataSetLoaded(false);
	ui->ribbonR11tLearn->setDataSetLoaded(false);

#ifdef QT_DEBUG
	ui->webViewResults->page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
	ui->webViewHelp->page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
#else
	ui->webViewResults->setContextMenuPolicy(Qt::NoContextMenu);
	ui->webViewHelp->setContextMenuPolicy(Qt::NoContextMenu);
#endif

	tempfiles_init(ProcessInfo::currentPID()); // needed here so that the LRNAM can be passed the session directory


	_odm = new OnlineDataManager(this);

	QVariant osfUsernameV = _settings.value("OSFUsername");
	QVariant osfPasswordV = _settings.value("OSFPassword", "");

	if (osfUsernameV.canConvert(QMetaType::QString) && osfPasswordV.canConvert(QMetaType::QString))
	{
		QString username = osfUsernameV.toString();
		QString password = osfPasswordV.toString();
		_odm->setAuthentication(OnlineDataManager::OSF, username, password);
	}

	_loader.setOnlineDataManager(_odm);
	ui->backStage->setOnlineDataManager(_odm);

	// the LRNAM adds mime types to local resources; important for SVGs
	ui->webViewResults->page()->setNetworkAccessManager(new LRNAM(tq(tempfiles_sessionDirName()), this));
	ui->webViewResults->setUrl(QUrl(QString("qrc:///core/index.html")));
	connect(ui->webViewResults, SIGNAL(loadFinished(bool)), this, SLOT(resultsPageLoaded(bool)));
	connect(ui->webViewResults, SIGNAL(scrollValueChanged()), this, SLOT(scrollValueChangedHandle()));

	_tableModel = new DataSetTableModel();
	ui->tableView->setModel(_tableModel);

#ifdef QT_DEBUG  // variables view
	ui->tabBar->setCurrentIndex(2);
#else
	ui->tabBar->setCurrentIndex(1);
#endif

	ui->tableView->setVerticalScrollMode(QTableView::ScrollPerPixel);
	ui->tableView->setHorizontalScrollMode(QTableView::ScrollPerPixel);

	_analyses = new Analyses();
	_engineSync = new EngineSync(_analyses, this);
	connect(_engineSync, SIGNAL(engineTerminated()), this, SLOT(fatalError()));

	connect(_analyses, SIGNAL(analysisResultsChanged(Analysis*)), this, SLOT(analysisResultsChangedHandler(Analysis*)));
	connect(_analyses, SIGNAL(analysisUserDataLoaded(Analysis*)), this, SLOT(analysisUserDataLoadedHandler(Analysis*)));

	connect(ui->ribbonAnalysis, SIGNAL(itemSelected(QString)), this, SLOT(itemSelected(QString)));
	connect(ui->ribbonSEM, SIGNAL(itemSelected(QString)), this, SLOT(itemSelected(QString)));
	connect(ui->ribbonR11tLearn, SIGNAL(itemSelected(QString)), this, SLOT(itemSelected(QString)));
	connect(ui->backStage, SIGNAL(dataSetIORequest(FileEvent*)), this, SLOT(dataSetIORequest(FileEvent*)));
	connect(ui->backStage, SIGNAL(exportSelected(QString)), this, SLOT(exportSelected(QString)));

	_progressIndicator = new ProgressWidget(ui->tableView);
	_progressIndicator->setAutoFillBackground(true);
	_progressIndicator->resize(400, 100);
	_progressIndicator->move(100, 80);
	_progressIndicator->hide();

	connect(&_loader, SIGNAL(progress(QString,int)), _progressIndicator, SLOT(setStatus(QString,int)));

	connect(this, SIGNAL(analysisSelected(int)), this, SLOT(analysisSelectedHandler(int)));
	connect(this, SIGNAL(analysisUnselected()), this, SLOT(analysisUnselectedHandler()));
	connect(this, SIGNAL(saveTempImage(int, QString, QByteArray)), this, SLOT(saveTempImageHandler(int, QString, QByteArray)));
	connect(this, SIGNAL(displayMessageFromResults(QString)),  this, SLOT(displayMessageFromResultsHandler(QString)));
	connect(this, SIGNAL(pushToClipboard(QString, QString, QString)), this, SLOT(pushToClipboardHandler(QString, QString, QString)));
	connect(this, SIGNAL(pushImageToClipboard(QByteArray, QString)), this, SLOT(pushImageToClipboardHandler(QByteArray, QString)));
	connect(this, SIGNAL(saveTextToFile(QString, QString)), this, SLOT(saveTextToFileHandler(QString, QString)));
	connect(this, SIGNAL(analysisChangedDownstream(int, QString)), this, SLOT(analysisChangedDownstreamHandler(int, QString)));
	connect(this, SIGNAL(showAnalysesMenu(QString)), this, SLOT(showAnalysesMenuHandler(QString)));
	connect(this, SIGNAL(removeAnalysisRequest(int)), this, SLOT(removeAnalysisRequestHandler(int)));
	connect(this, SIGNAL(updateUserData(int, QString)), this, SLOT(updateUserDataHandler(int, QString)));
	connect(this, SIGNAL(simulatedMouseClick(int, int, int)), this, SLOT(simulatedMouseClickHandler(int, int, int)));
	connect(this, SIGNAL(resultsDocumentChanged()), this, SLOT(resultsDocumentChangedHandler()));

#ifdef __APPLE__
	_scrollbarWidth = 3;
#else
	_scrollbarWidth = qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent);
#endif

	_buttonPanel = new QWidget(ui->panelMid);
	_buttonPanelLayout = new QVBoxLayout(_buttonPanel);
	_buttonPanelLayout->setSpacing(6);
	_buttonPanelLayout->setContentsMargins(0, _buttonPanelLayout->contentsMargins().top(), _buttonPanelLayout->contentsMargins().right(), 0);

	_buttonPanel->setLayout(_buttonPanelLayout);

	_okButton = new QPushButton(QString("OK"), _buttonPanel);
	_okButton->setDefault(true);
	_runButton = new QPushButton(QString("Run"), _buttonPanel);
	_menuButton = new QPushButton(QString("..."), _buttonPanel);

	QMenu *menu = new QMenu(_menuButton);
	menu->addAction("Remove Analysis", this, SLOT(analysisRemoved()));
	_menuButton->setMenu(menu);

	_buttonPanelLayout->addWidget(_okButton);
	_buttonPanelLayout->addWidget(_runButton);
	_buttonPanelLayout->addWidget(_menuButton);
	_buttonPanelLayout->addStretch();

	_buttonPanel->resize(_buttonPanel->sizeHint());
	_buttonPanel->move(ui->panelMid->width() - _buttonPanel->width() - _scrollbarWidth, 0);

	connect(_okButton, SIGNAL(clicked()), this, SLOT(analysisOKed()));
	connect(_runButton, SIGNAL(clicked()), this, SLOT(analysisRunned()));

	connect(ui->splitter, SIGNAL(splitterMoved(int,int)), this, SLOT(splitterMovedHandler(int,int)));

	_analysisMenu = new QMenu(this);
	connect(_analysisMenu, SIGNAL(aboutToHide()), this, SLOT(menuHidding()));

	updateUIFromOptions();

	_tableViewWidthBeforeOptionsMadeVisible = -1;

	QUrl userGuide = QUrl::fromLocalFile(AppDirs::help() + "/index.html");
	ui->webViewHelp->setUrl(userGuide);
	connect(ui->webViewHelp, SIGNAL(loadFinished(bool)), this, SLOT(helpFirstLoaded(bool)));
	ui->panelHelp->hide();

	setAcceptDrops(true);

#ifdef __WIN32__
	QApplication::setFont(ui->tableView->font());
#endif

	setupOptionPanelSize();

	ui->panelMid->hide();
}
예제 #10
0
QTCEXPORT(void*,qtc_QScriptEngine_toScriptQObjectValue)(wchar_t* x0, void* x1, void* x2)
{
  QString tq(from_method(x0));
  QObject*tx1 = *((QPointer<QObject>*)x1);
  if (tx1->property(QTC_PROP).isValid()) tx1 = (((qtc_DynamicQObject *)tx1)->parent());
  QObject*tx2 = *((QPointer<QObject>*)x2);
  QScriptValue * tc = NULL;
  int x;
  x = qso_hash->value(tq, -1);
  switch (x) {
    case 0:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QAbstractButton*>((QAbstractButton*)tx2));
      break;
    case 1:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QAbstractItemView*>((QAbstractItemView*)tx2));
      break;
    case 2:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QAbstractScrollArea*>((QAbstractScrollArea*)tx2));
      break;
    case 3:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QAbstractSlider*>((QAbstractSlider*)tx2));
      break;
    case 4:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QAbstractSpinBox*>((QAbstractSpinBox*)tx2));
      break;
    case 5:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QAbstractTableModel*>((QAbstractTableModel*)tx2));
      break;
    case 6:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QAbstractTextDocumentLayout*>((QAbstractTextDocumentLayout*)tx2));
      break;
    case 7:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QAction*>((QAction*)tx2));
      break;
    case 8:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QActionGroup*>((QActionGroup*)tx2));
      break;
    case 9:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QApplication*>((QApplication*)tx2));
      break;
    case 10:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QBoxLayout*>((QBoxLayout*)tx2));
      break;
    case 11:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QButtonGroup*>((QButtonGroup*)tx2));
      break;
    case 12:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QCalendarWidget*>((QCalendarWidget*)tx2));
      break;
    case 13:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QCheckBox*>((QCheckBox*)tx2));
      break;
    case 14:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QComboBox*>((QComboBox*)tx2));
      break;
    case 15:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QDial*>((QDial*)tx2));
      break;
    case 16:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QDialog*>((QDialog*)tx2));
      break;
    case 17:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QDialogButtonBox*>((QDialogButtonBox*)tx2));
      break;
    case 18:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QDockWidget*>((QDockWidget*)tx2));
      break;
    case 19:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QDoubleSpinBox*>((QDoubleSpinBox*)tx2));
      break;
    case 20:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QErrorMessage*>((QErrorMessage*)tx2));
      break;
    case 21:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QFocusFrame*>((QFocusFrame*)tx2));
      break;
    case 22:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QFontComboBox*>((QFontComboBox*)tx2));
      break;
    case 23:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QGLWidget*>((QGLWidget*)tx2));
      break;
    case 24:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QGridLayout*>((QGridLayout*)tx2));
      break;
    case 25:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QGroupBox*>((QGroupBox*)tx2));
      break;
    case 26:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QHBoxLayout*>((QHBoxLayout*)tx2));
      break;
    case 27:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QHeaderView*>((QHeaderView*)tx2));
      break;
    case 28:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QIODevice*>((QIODevice*)tx2));
      break;
    case 29:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QLCDNumber*>((QLCDNumber*)tx2));
      break;
    case 30:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QLabel*>((QLabel*)tx2));
      break;
    case 31:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QLayout*>((QLayout*)tx2));
      break;
    case 32:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QLineEdit*>((QLineEdit*)tx2));
      break;
    case 33:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QMenu*>((QMenu*)tx2));
      break;
    case 34:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QMenuBar*>((QMenuBar*)tx2));
      break;
    case 35:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QMessageBox*>((QMessageBox*)tx2));
      break;
    case 36:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QProgressBar*>((QProgressBar*)tx2));
      break;
    case 37:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QProgressDialog*>((QProgressDialog*)tx2));
      break;
    case 38:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QPushButton*>((QPushButton*)tx2));
      break;
    case 39:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QRubberBand*>((QRubberBand*)tx2));
      break;
    case 40:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QScrollArea*>((QScrollArea*)tx2));
      break;
    case 41:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QScrollBar*>((QScrollBar*)tx2));
      break;
    case 42:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QSlider*>((QSlider*)tx2));
      break;
    case 43:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QSpinBox*>((QSpinBox*)tx2));
      break;
    case 44:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QTabBar*>((QTabBar*)tx2));
      break;
    case 45:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QTabWidget*>((QTabWidget*)tx2));
      break;
    case 46:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QTextBrowser*>((QTextBrowser*)tx2));
      break;
    case 47:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QTextDocument*>((QTextDocument*)tx2));
      break;
    case 48:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QTextEdit*>((QTextEdit*)tx2));
      break;
    case 49:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QVBoxLayout*>((QVBoxLayout*)tx2));
      break;
    case 50:
      tc = new QScriptValue(((QScriptEngine*)tx1)->toScriptValue<QWidget*>((QWidget*)tx2));
      break;
    default:
      break;
  }
  return (void*)(tc);
}
예제 #11
0
QTCEXPORT(void*,qtc_QScriptEngine_fromScriptValue)(wchar_t* x0, void* x1, void* x2)
{
  QString tq(from_method(x0));
  QObject*tx1 = *((QPointer<QObject>*)x1);
  if (tx1->property(QTC_PROP).isValid()) tx1 = (((qtc_DynamicQObject *)tx1)->parent());
  int x;
  x = qsn_hash->value(tq, -1);
  void * rv;
  switch (x) {
    case 0:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QBrush*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 1:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QColor*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 2:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QFont*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 3:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QGLColormap*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 4:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QGLContext*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 5:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QGLFormat*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 6:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QGLFramebufferObject*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 7:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QGLPixelBuffer*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 8:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QKeyEvent*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 9:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QMouseEvent*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 10:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QPaintEvent*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 11:
      rv = (void*)(((QScriptEngine*)tx1)->fromScriptValue<QPainter*>((const QScriptValue&)(*(QScriptValue*)x2)));
      return rv;
      break;
    case 12:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QPainterPath*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 13:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QPalette*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 14:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QPen*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 15:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QPixmap*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 16:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QPixmapCache*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 17:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QResizeEvent*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 18:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QTextCharFormat*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 19:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QTextCursor*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 20:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QTextFormat*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    case 21:
      return (void*)(((QScriptEngine*)tx1)->fromScriptValue<QTextStream*>((const QScriptValue&)(*(QScriptValue*)x2)));
      break;
    default:
      break;
  }
  return (void*)(NULL);
}
예제 #12
0
void MainWindow::dataSetLoaded(const QString &dataSetName, DataSetPackage *package, const QString &filename)
{
	setWindowTitle(dataSetName);

	_tableModel->setDataSet(package->dataSet);
	ui->backStage->setFileLoaded(true, filename);
	_analyses->clear();

	ui->tableView->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents);

	_alert->hide();

	if (_inited == false)
	{
		ui->webViewResults->page()->mainFrame()->addToJavaScriptWindowObject("jasp", this);
		_inited = true;
	}

	if (package->hasAnalyses)
	{
		bool errorFound = false;

		int corruptAnalyses = 0;
		stringstream errorMsg;
		stringstream corruptionStrings;
		Json::Value analysesData = package->analysesData;
		if (!analysesData.isArray() || analysesData.isNull())
		{
			errorFound = true;
			errorMsg << "An error has been detected and analyses could not be loaded.";
		}
		else
		{
			for (Json::ValueIterator iter = analysesData.begin(); iter != analysesData.end(); iter++)
			{
				try
				{
					QString name = QString();
					Json::Value &analysisData = *iter;

					name = QString::fromStdString(analysisData["name"].asString());
					int id = analysisData["id"].asInt();

					Json::Value &optionsJson = analysisData["options"];
					Json::Value &resultsJson = analysisData["results"];

					Analysis::Status status = Analysis::getStatusValue(analysisData["status"].asString());

					Analysis *analysis = _analyses->create(name, id, &optionsJson, status);

					analysis->setResults(resultsJson);
				}
				catch (runtime_error e)
				{
					errorFound = true;
					corruptionStrings << "\n" << (++corruptAnalyses) << ": " << e.what();
				}
				catch (exception e)
				{
					errorFound = true;
					corruptionStrings << "\n" << (++corruptAnalyses) << ": " << e.what();
				}
			}
		}

		if (corruptAnalyses == 1)
			errorMsg << "An error was detected in an analyses. This analyses has been removed for the following reason:\n" << corruptionStrings.str();
		else if (corruptAnalyses > 1)
			errorMsg << "Errors were detected in " << corruptAnalyses << " analyses. These analyses have been removed for the following reasons:\n" << corruptionStrings.str();

		if (errorFound)
			QMessageBox::warning(this, "", tq(errorMsg.str()));
	}

	package->setLoaded();
	updateMenuEnabledDisabledStatus();

	if (_engineSync->engineStarted() == false)
		_engineSync->start();
}
예제 #13
0
MainWindow::MainWindow(QWidget *parent) :
	QMainWindow(parent),
	ui(new Ui::MainWindow)
{
	_inited = false;
	_tableModel = NULL;
	_currentOptionsWidget = NULL;
	_currentAnalysis = NULL;

	_optionsForm = NULL;

	_package = new DataSetPackage();

	_package->isModifiedChanged.connect(boost::bind(&MainWindow::packageChanged, this, _1));
	QShortcut *saveShortcut = new QShortcut(QKeySequence("Ctrl+S"), this);
	QObject::connect(saveShortcut, SIGNAL(activated()), this, SLOT(saveKeysSelected()));
	QShortcut *openShortcut = new QShortcut(QKeySequence("Ctrl+O"), this);
	QObject::connect(openShortcut, SIGNAL(activated()), this, SLOT(openKeysSelected()));

	ui->setupUi(this);

	QList<int> sizes = QList<int>();
	sizes.append(590);
	ui->splitter->setSizes(sizes);

	ui->tabBar->setFocusPolicy(Qt::NoFocus);
	ui->tabBar->addTab("File");
	ui->tabBar->addTab("Common");
	ui->tabBar->addOptionsTab();
	ui->tabBar->addHelpTab();

	connect(ui->tabBar, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
	connect(ui->tabBar, SIGNAL(helpToggled(bool)), this, SLOT(helpToggled(bool)));

#ifdef __WIN32__
	QFont font = ui->tabBar->font();
	font.setPointSize(10);
	ui->tabBar->setFont(font);
#endif

	ui->ribbonAnalysis->setEnabled(false);
	ui->ribbonSEM->setEnabled(false);
	ui->ribbonR11tLearn->setEnabled(false);

#ifdef QT_DEBUG
	ui->webViewResults->page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
	ui->webViewHelp->page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
#else
	ui->webViewResults->setContextMenuPolicy(Qt::NoContextMenu);
	ui->webViewHelp->setContextMenuPolicy(Qt::NoContextMenu);
#endif

	tempfiles_init(ProcessInfo::currentPID()); // needed here so that the LRNAM can be passed the session directory

	// the LRNAM adds mime types to local resources; important for SVGs
	ui->webViewResults->page()->setNetworkAccessManager(new LRNAM(tq(tempfiles_sessionDirName()), this));
	ui->webViewResults->setUrl(QUrl(QString("qrc:///core/index.html")));
	connect(ui->webViewResults, SIGNAL(loadFinished(bool)), this, SLOT(resultsPageLoaded(bool)));

	_tableModel = new DataSetTableModel();
	ui->tableView->setModel(_tableModel);
	ui->tabBar->setCurrentIndex(1);

	ui->tableView->setVerticalScrollMode(QTableView::ScrollPerPixel);
	ui->tableView->setHorizontalScrollMode(QTableView::ScrollPerPixel);

	_analyses = new Analyses();
	_engineSync = new EngineSync(_analyses, this);
	connect(_engineSync, SIGNAL(engineTerminated()), this, SLOT(fatalError()));

	connect(_analyses, SIGNAL(analysisResultsChanged(Analysis*)), this, SLOT(analysisResultsChangedHandler(Analysis*)));

	connect(ui->ribbonAnalysis, SIGNAL(itemSelected(QString)), this, SLOT(itemSelected(QString)));
	connect(ui->ribbonSEM, SIGNAL(itemSelected(QString)), this, SLOT(itemSelected(QString)));
	connect(ui->ribbonR11tLearn, SIGNAL(itemSelected(QString)), this, SLOT(itemSelected(QString)));
	connect(ui->backStage, SIGNAL(dataSetSelected(QString)), this, SLOT(dataSetSelected(QString)));
	connect(ui->backStage, SIGNAL(closeDataSetSelected()), this, SLOT(dataSetCloseRequested()));
	connect(ui->backStage, SIGNAL(exportSelected(QString)), this, SLOT(exportSelected(QString)));
	connect(ui->backStage, SIGNAL(saveSelected(QString)), this, SLOT(saveSelected(QString)));

	_alert = new ProgressWidget(ui->tableView);
	_alert->setAutoFillBackground(true);
	_alert->resize(400, 100);
	_alert->move(100, 80);
	_alert->hide();

	connect(&_loader, SIGNAL(complete(const QString&, DataSetPackage*, const QString&)), this, SLOT(dataSetLoaded(const QString&, DataSetPackage*, const QString&)));
	connect(&_loader, SIGNAL(saveComplete(const QString&)), this, SLOT(saveComplete(const QString&)));
	connect(&_loader, SIGNAL(progress(QString,int)), _alert, SLOT(setStatus(QString,int)));
	connect(&_loader, SIGNAL(fail(QString)), this, SLOT(dataSetLoadFailed(QString)));
	connect(&_loader, SIGNAL(saveFail(QString)), this, SLOT(saveFailed(QString)));

	connect(this, SIGNAL(analysisSelected(int)), this, SLOT(analysisSelectedHandler(int)));
	connect(this, SIGNAL(analysisUnselected()), this, SLOT(analysisUnselectedHandler()));
	connect(this, SIGNAL(pushToClipboard(QString, QString)), this, SLOT(pushToClipboardHandler(QString, QString)));
	connect(this, SIGNAL(analysisChangedDownstream(int, QString)), this, SLOT(analysisChangedDownstreamHandler(int, QString)));

	_buttonPanel = new QWidget(ui->pageOptions);
	_buttonPanelLayout = new QVBoxLayout(_buttonPanel);
	_buttonPanelLayout->setSpacing(6);
	_buttonPanelLayout->setContentsMargins(0, 12, 24, 0);
	_buttonPanel->setLayout(_buttonPanelLayout);

	_okButton = new QPushButton(QString("OK"), _buttonPanel);
	_okButton->setDefault(true);
	_runButton = new QPushButton(QString("Run"), _buttonPanel);
	_menuButton = new QPushButton(QString("..."), _buttonPanel);

	QMenu *menu = new QMenu(_menuButton);
	menu->addAction("Remove Analysis", this, SLOT(analysisRemoved()));
	_menuButton->setMenu(menu);

	_buttonPanelLayout->addWidget(_okButton);
	_buttonPanelLayout->addWidget(_runButton);
	_buttonPanelLayout->addWidget(_menuButton);
	_buttonPanelLayout->addStretch();

	_buttonPanel->resize(_buttonPanel->sizeHint());
	_buttonPanel->move(ui->panelMid->minimumWidth() - _buttonPanel->width(), 0);

	connect(_okButton, SIGNAL(clicked()), this, SLOT(analysisOKed()));
	connect(_runButton, SIGNAL(clicked()), this, SLOT(analysisRunned()));

	connect(ui->splitter, SIGNAL(splitterMoved(int,int)), this, SLOT(splitterMovedHandler(int,int)));

	updateUIFromOptions();

	ui->panelMid->hide();

	_tableViewWidthBeforeOptionsMadeVisible = -1;

	QUrl userGuide = QUrl::fromLocalFile(AppDirs::help() + "/index.html");
	ui->webViewHelp->setUrl(userGuide);
	connect(ui->webViewHelp, SIGNAL(loadFinished(bool)), this, SLOT(helpFirstLoaded(bool)));
	ui->panelHelp->hide();

	try {

		_log = new ActivityLog();
		_log->log("Application Start");

		ui->backStage->setLog(_log);
		_engineSync->setLog(_log);

		_log->flushLogToServer();

		QTimer *timer = new QTimer(this);
		timer->setInterval(30000);
		connect(timer, SIGNAL(timeout()), _log, SLOT(flushLogToServer()));
		timer->start();
	}
	catch (std::runtime_error &e)
	{
		_log = NULL;
		_fatalError = tq(e.what());
		QTimer::singleShot(0, this, SLOT(fatalError()));
	}

	setAcceptDrops(true);
}
예제 #14
0
qreal QGLBezierPatch::intersection
    (qreal result, int depth, const QRay3D& ray, bool anyIntersection,
     qreal xtex, qreal ytex, qreal wtex, qreal htex, QVector2D *tc)
{
    // Check the convex hull of the patch for an intersection.
    // If no intersection with the convex hull, then there is
    // no point subdividing this patch further.
    QBox3D box;
    for (int point = 0; point < 16; ++point)
        box.unite(points[point]);
    if (!box.intersects(ray))
        return result;

    // Are we at the lowest point of subdivision yet?
    if (depth <= 1) {
        // Divide the patch into two triangles and intersect with those.
        QTriangle3D triangle1(points[0], points[3], points[12]);
        qreal t = triangle1.intersection(ray);
        if (!qIsNaN(t)) {
            result = combineResults(result, t);
            if (result == t) {
                QVector2D uv = triangle1.uv(ray.point(t));
                QVector2D tp(xtex, ytex);
                QVector2D tq(xtex + wtex, ytex);
                QVector2D tr(xtex, ytex + htex);
                *tc = uv.x() * tp + uv.y() * tq + (1 - uv.x() - uv.y()) * tr;
            }
        } else {
            QTriangle3D triangle2(points[3], points[15], points[12]);
            qreal t = triangle2.intersection(ray);
            if (!qIsNaN(t)) {
                result = combineResults(result, t);
                if (result == t) {
                    QVector2D uv = triangle2.uv(ray.point(t));
                    QVector2D tp(xtex + wtex, ytex);
                    QVector2D tq(xtex + wtex, ytex + htex);
                    QVector2D tr(xtex, ytex + htex);
                    *tc = uv.x() * tp + uv.y() * tq + (1 - uv.x() - uv.y()) * tr;
                }
            }
        }
    } else {
        // Subdivide the patch to find the point of intersection.
        QGLBezierPatch patch1, patch2, patch3, patch4;
        subDivide(patch1, patch2, patch3, patch4);
        --depth;
        qreal hwtex = wtex / 2.0f;
        qreal hhtex = htex / 2.0f;
        result = patch1.intersection
            (result, depth, ray, anyIntersection,
             xtex, ytex, hwtex, hhtex, tc);
        if (anyIntersection && !qIsNaN(result))
            return result;
        result = patch2.intersection
            (result, depth, ray, anyIntersection,
             xtex + hwtex, ytex, hwtex, hhtex, tc);
        if (anyIntersection && !qIsNaN(result))
            return result;
        result = patch3.intersection
            (result, depth, ray, anyIntersection,
             xtex, ytex + hhtex, hwtex, hhtex, tc);
        if (anyIntersection && !qIsNaN(result))
            return result;
        result = patch4.intersection
            (result, depth, ray, anyIntersection,
             xtex + hwtex, ytex + hhtex, hwtex, hhtex, tc);
    }
    return result;
}